This repository was archived by the owner on Jan 10, 2020. It is now read-only.
File tree Expand file tree Collapse file tree 8 files changed +39
-17
lines changed Expand file tree Collapse file tree 8 files changed +39
-17
lines changed Original file line number Diff line number Diff line change 1
1
.idea
2
2
vendor
3
3
composer.phar
4
+ atlassian-ide-plugin.xml
Original file line number Diff line number Diff line change @@ -105,11 +105,18 @@ protected function addAndroid()
105
105
scalarNode ("source " )->defaultValue ("" )->end ()->
106
106
end ()->
107
107
end ()->
108
- arrayNode ("gcm " )->
109
- canBeUnset ()->
110
- children ()->
111
- scalarNode ("api_key " )->isRequired ()->cannotBeEmpty ()->end ()->
112
- end ()->
108
+ arrayNode ("gcm " )
109
+ ->children ()
110
+ ->arrayNode ('api_keys ' )
111
+ ->isRequired ()
112
+ ->requiresAtLeastOneElement ()
113
+ ->useAttributeAsKey ('name ' )
114
+ ->prototype ('array ' )
115
+ ->children ()
116
+ ->scalarNode ('api_key ' )->isRequired ()->end ()
117
+ ->scalarNode ('internal_app_id ' )->isRequired ()->end ()
118
+ ->end ()->
119
+ end ()->
113
120
end ()->
114
121
end ()->
115
122
end ()->
Original file line number Diff line number Diff line change @@ -86,7 +86,7 @@ abstract class Message implements MessageInterface
86
86
/**
87
87
* Collapse key for data
88
88
*
89
- * @var int
89
+ * @var string
90
90
*/
91
91
protected $ collapseKey = self ::DEFAULT_COLLAPSE_KEY ;
92
92
@@ -234,6 +234,7 @@ public function getMessageBody()
234
234
"registration_id " => $ this ->device ->getDeviceidentifier (),
235
235
"collapse_key " => $ this ->collapseKey ,
236
236
"data.message " => $ this ->message ,
237
+ "data.content_available " => $ this ->contentAvailable ? 1 : 0 ,
237
238
);
238
239
if (!empty ($ this ->customData )) {
239
240
$ data = array_merge ($ data , $ this ->customData );
@@ -388,7 +389,7 @@ public function getTargetOS()
388
389
* Android-specific
389
390
* Returns the collapse key
390
391
*
391
- * @return int
392
+ * @return string
392
393
*/
393
394
public function getCollapseKey ()
394
395
{
Original file line number Diff line number Diff line change 4
4
5
5
interface MessageInterface
6
6
{
7
- const DEFAULT_COLLAPSE_KEY = 1 ;
7
+ const DEFAULT_COLLAPSE_KEY = " 1 " ;
8
8
9
9
/**
10
10
* @return mixed database ID for this device
Original file line number Diff line number Diff line change 20
20
21
21
<!-- Android (GCM) -->
22
22
<service id =" dab_push_notifications.android.gcm" class =" %dab_push_notifications.android.gcm.class%" public =" false" >
23
- <argument >%dab_push_notifications.android.gcm.api_key %</argument >
23
+ <argument >%dab_push_notifications.android.gcm.api_keys %</argument >
24
24
<tag name =" dab_push_notifications.handler" osType =" dab_push_notifications.os.android.gcm" />
25
25
<argument type =" service" id =" dab_push_notifications.manager.device" />
26
26
</service >
Original file line number Diff line number Diff line change 31
31
32
32
<field name =" contentAvailable" type =" boolean" />
33
33
34
+ <field name =" collapseKey" type =" string" nullable =" true" />
35
+
36
+ <field name =" customData" type =" array" nullable =" true" />
37
+
34
38
<field name =" createdAt" type =" datetime" />
35
39
36
40
<field name =" updatedAt" type =" datetime" />
Original file line number Diff line number Diff line change @@ -17,11 +17,11 @@ class AndroidGCMNotification implements OSNotificationServiceInterface
17
17
protected $ apiURL = "https://android.googleapis.com/gcm/send " ;
18
18
19
19
/**
20
- * Google GCM API key
20
+ * Array of used api keys
21
21
*
22
22
* @var string
23
23
*/
24
- protected $ apiKey ;
24
+ protected $ apiKeys ;
25
25
26
26
/**
27
27
* @var \DABSquared\PushNotificationsBundle\Model\DeviceManager
@@ -47,9 +47,9 @@ class AndroidGCMNotification implements OSNotificationServiceInterface
47
47
*
48
48
* @param $apiKey
49
49
*/
50
- public function __construct ($ apiKey , \DABSquared \PushNotificationsBundle \Model \DeviceManager $ deviceManager )
50
+ public function __construct ($ apiKeys , \DABSquared \PushNotificationsBundle \Model \DeviceManager $ deviceManager )
51
51
{
52
- $ this ->apiKey = $ apiKey ;
52
+ $ this ->apiKeys = $ apiKeys ;
53
53
$ this ->deviceManager = $ deviceManager ;
54
54
}
55
55
@@ -66,8 +66,18 @@ public function send(MessageInterface $message)
66
66
throw new InvalidMessageTypeException (sprintf ("Message type '%s' not supported by GCM " , get_class ($ message )));
67
67
}
68
68
69
+ $ apiKey = null ;
70
+
71
+ foreach ($ this ->apiKeys as $ anAPIKey ) {
72
+ if ($ message ->getDevice ()->getAppId () == $ anAPIKey ['internal_app_id ' ]) {
73
+ $ apiKey = $ anAPIKey ;
74
+ break ;
75
+ }
76
+ }
77
+
78
+
69
79
$ headers = array (
70
- "Authorization: key= " . $ this -> apiKey ,
80
+ "Authorization: key= " . $ apiKey ,
71
81
"Content-Type: application/json " ,
72
82
);
73
83
$ data = array_merge (
Original file line number Diff line number Diff line change 8
8
DABSquared \PushNotificationsBundle \Device \Types ,
9
9
DABSquared \PushNotificationsBundle \Model \Device ;
10
10
11
- use Buzz \Browser ;
12
11
use DABSquared \PushNotificationsBundle \Message \MessageStatus ;
13
12
use DABSquared \PushNotificationsBundle \Model \DeviceManagerInterface ;
14
13
use DABSquared \PushNotificationsBundle \Model \MessageManagerInterface ;
@@ -108,9 +107,9 @@ public function send(MessageInterface $message)
108
107
* Send a bunch of notification messages
109
108
*
110
109
* @param array $messages
111
- * @throws \RuntimeException
110
+ * @return bool|void
111
+ * @throws \Symfony\Component\DependencyInjection\Exception\RuntimeException
112
112
* @throws \DABSquared\PushNotificationsBundle\Exception\InvalidMessageTypeException
113
- * @return int
114
113
*/
115
114
public function sendMessages (array $ messages )
116
115
{
You can’t perform that action at this time.
0 commit comments