-
Notifications
You must be signed in to change notification settings - Fork 152
Firebase Cloud Messaging support #141
base: master
Are you sure you want to change the base?
Conversation
@@ -95,13 +95,27 @@ protected function setAndroidConfig(array $config) | |||
$this->container->setParameter("rms_push_notifications.android.c2dm.password", $password); | |||
$this->container->setParameter("rms_push_notifications.android.c2dm.source", $source); | |||
|
|||
// DEFINE PARAMETERS | |||
$this->container->setParameter("rms_push_notifications.android.gcm.api_key", null); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are these being set as null and then directly overwritten further down?
@@ -136,7 +150,9 @@ public function setDeviceIdentifier($identifier) | |||
*/ | |||
public function getTargetOS() | |||
{ | |||
return ($this->isGCM ? Types::OS_ANDROID_GCM : Types::OS_ANDROID_C2DM); | |||
if($this->isGCM) return Types::OS_ANDROID_GCM; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please reformat this as per PSR-2 if possible - makes it a bit easier to read :-)
@@ -44,6 +44,9 @@ only be available if you provide configuration respectively for them. | |||
api_key: <string_android_gcm_api_key> # This is titled "Server Key" when creating it | |||
use_multi_curl: <boolean_android_gcm_use_multi_curl> # default is true | |||
dry_run: <bool_use_gcm_dry_run> | |||
fcm: | |||
api_key: <string_android_fcm_api_key> # This is titled "Server Key" when creating it |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not that familiar with FCM - is the comment still relevant here about "Server Key" being how the Firebase control panels name the API key?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's still called "Server Key"
@@ -35,7 +35,6 @@ public function send(MessageInterface $message) | |||
if (!$this->supports($message->getTargetOS())) { | |||
throw new \RuntimeException("OS type {$message->getTargetOS()} not supported"); | |||
} | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please revert this change
|
||
to send as a GCM message rather than C2DM. | ||
to send as a FCM message rather than GCM or C2DM. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is slightly unclear I think, as you should be specifying only one of GCM or FCM - you don't need to specify both. Could you reword this so that it's clear you only need to use one of the set*()
methods, depending on your use case?
Firstly, thanks for this PR! :-) Aside from the inline comments above, could you also please add some detail or external reference about the And is the |
@siwymilek Very interested with this PR, thank you ! Do you plan to finalize it ? |
@siwymilek Did you test it for real ? Currently, the data format is : According to the FCM doc, it should be : {"notification": {"body": "My message"}} https://firebase.google.com/docs/cloud-messaging/http-server-ref |
@EmmanuelVella As far as I understand the |
That sound right ! Thank you 👍 |
@richsage could I please you to review this PR? |
$this->container->setParameter("rms_push_notifications.android.gcm.use_multi_curl", $config["android"]["gcm"]["use_multi_curl"]); | ||
$this->container->setParameter('rms_push_notifications.android.gcm.dry_run', $config["android"]["gcm"]["dry_run"]); | ||
} | ||
// if (isset($config["android"]["gcm"])) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure on the reasoning behind this.
If the user is not interested in GCM configuration (for example, they are only using iOS push notifications), this forces them to supply configuration options. That is why the conditional check is in place, to enable them to leave out the android.gcm key and similar (see the Configuration
class which permits the key to be unset/not supplied if not needed).
Commenting this check out will force the user to supply dummy details. Therefore I'd like this to be left in.
This is the same for the FCM change on line 108.
@siwymilek interested in your PR, do you plan to finalize it? |
); | ||
$data = array_merge( | ||
$message->getFCMOptions(), | ||
array("data" => $message->getData()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I checked with the FCM documentation and also tried it out. The Key here must be called "notification" instead of the old "data"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and also in this case of FCM the $message->getData() method should return an array with the 'body' key instead of 'message'.
No description provided.