Skip to content
This repository was archived by the owner on Jan 10, 2020. It is now read-only.

Commit 069f84f

Browse files
committed
Fixes for Android GCM. Should also fix issue #8
1 parent fd342e5 commit 069f84f

File tree

6 files changed

+35
-6
lines changed

6 files changed

+35
-6
lines changed

DependencyInjection/DABSquaredPushNotificationsExtension.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ protected function setAndroidConfig(array $config)
130130
// GCM
131131
$this->container->setParameter("dab_push_notifications.android.gcm.enabled", isset($config["android"]["gcm"]));
132132
if (isset($config["android"]["gcm"])) {
133-
$this->container->setParameter("dab_push_notifications.android.gcm.api_key", $config["android"]["gcm"]["api_key"]);
133+
$this->container->setParameter("dab_push_notifications.android.gcm.api_keys", $config["android"]["gcm"]["api_keys"]);
134134
}
135135
}
136136

Resources/doc/1-setting_up_the_bundle.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,11 @@ dab_squared_push_notifications:
4242
apps:
4343
your_app_free: {name: 'Your App Free', internal_app_id: 0000001 }
4444
your_app_premium: {name: 'Your App Premium', internal_app_id: 0000002 }
45+
android:
46+
gcm:
47+
api_keys:
48+
your_app_free: { api_key: 'YOUR ANDROID SERVER KEY HERE', internal_app_id: 0000001 }
49+
your_app_premium: { api_key: 'YOUR ANDROID SERVER KEY HERE', internal_app_id: 0000002 }
4550
ios:
4651
certificates:
4752
dev_free: { sandbox: true, pem: %kernel.root_dir%/../pushcerts/dev/certificate.pem, passphrase: ~, internal_app_id: 0000001}

Resources/doc/5-integration_with_ios.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
Step 5: Integration With iOS
22
=======================================
3+
4+
### Accepting pull requests with better iOS Docs.
5+
6+
37
In the AppDelegate file do the following:
48

59

@@ -158,5 +162,5 @@ In the AppDelegate file do the following:
158162
}
159163
```
160164

161-
[Step 6: Integration with Safari](6-integration_with_safari.md).
165+
[Step 6: Integration with Android](6-integration_with_android.md).
162166

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
Step 6: Integration With Android
2+
=======================================
3+
4+
5+
### Accepting pull requests with better Android Docs.
6+
7+
8+
### A) Register For Notifications:
9+
10+
Make a call to the GCM Google Play services with a unique device identifier
11+
12+
13+
### B) Register With Server:
14+
15+
When you register with the server you use the gcm Registration ID as the deviceToken and a custom set unique device id as the deviceIdentifier.
16+
17+
18+
[Step 7: Integration with Safari](7-integration_with_safari.md).

Resources/doc/6-integration_with_safari.md renamed to Resources/doc/7-integration_with_safari.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Step 6: Integration With Safari (Requires FOSUserBundle or Some Type Of User System)
1+
Step 7: Integration With Safari (Requires FOSUserBundle or Some Type Of User System)
22
=======================================
33

44

@@ -44,4 +44,4 @@ document.body.onload = function() {
4444

4545
```
4646

47-
Once that is in the webservices routing should cover the rest. Make sure you imported the safari routing files.
47+
Once that is in the webservices routing should cover the rest. Make sure you imported the safari routing files.

Service/OS/AndroidGCMNotification.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ public function send(MessageInterface $message)
7070

7171
foreach($this->apiKeys as $anAPIKey) {
7272
if($message->getDevice()->getAppId() == $anAPIKey['internal_app_id']) {
73-
$apiKey = $anAPIKey;
73+
$apiKey = $anAPIKey['api_key'];
7474
break;
7575
}
7676
}
@@ -80,19 +80,21 @@ public function send(MessageInterface $message)
8080
"Authorization: key=" . $apiKey,
8181
"Content-Type: application/json",
8282
);
83+
8384
$data = array_merge(
8485
$message->getGCMOptions(),
8586
array("data" => $message->getMessageBody())
8687
);
8788

8889
$device = $message->getDevice();
8990
// Chunk number of registration IDs according to the maximum allowed by GCM
90-
$chunks = array_chunk(array($device->getDeviceIdentifier()), $this->registrationIdMaxCount);
91+
$chunks = array_chunk(array($device->getDeviceToken()), $this->registrationIdMaxCount);
9192

9293
// Perform the calls (in parallel)
9394
$this->responses = array();
9495
foreach ($chunks as $registrationIDs) {
9596
$data["registration_ids"] = $registrationIDs;
97+
9698
// Open connection
9799
$ch = curl_init();
98100
// Set the url, number of POST vars, POST data

0 commit comments

Comments
 (0)