From 019a147af172fcc8f3fba77bd7b9cefea3908df6 Mon Sep 17 00:00:00 2001 From: Libin Lu Date: Sat, 4 Jun 2016 14:18:39 -0400 Subject: [PATCH] Update README.md --- README.md | 43 ++++++++++++++++++++++++++++++++++--------- 1 file changed, 34 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 8712db2..1fd68b7 100644 --- a/README.md +++ b/README.md @@ -104,17 +104,42 @@ this.fcmTokenLsnr.remove(); } ``` -### Pass `click_action` and `data` when sending notification -When app is not running when user clicks notification, notification data will be passed into -- `FCM.initialAction`(contains `click_action` in notification payload -- `FCM.initialData` (contains `data` payload if you send together with notification) +### Response to `click_action` in Android +To allow android to respond to `click_action`, you need to define Activities and filter on specific intent. Since everything is running in MainActivity, you can have MainActivity to handle actions, however, the activity will be reload everytime. Let me know if you have better idea how to do this. +```xml + + + + + + <--add this line + <--add this line, name should matche click_action + <--add this line + <--add this line + +``` +and pass intent into package, change MainActivity.java +```java +new FIRMessagingPackage(getIntent()), <--add getIntent() +``` + +### Behaviour when sending `click_action` and `data` in notification +- When app is not running when user clicks notification, notification data will be passed into + - `FCM.initialAction`(contains `click_action` in notification payload + - `FCM.initialData` (contains `data` payload if you send together with notification) + +- When app is running in background + - IOS will receive notificaton from `FCMNotificationReceived` event + - Android will reload the whole react app -When app is running in background -- IOS will receive notificaton from `FCMNotificationReceived` event -- Android will reload the whole react app (I'm looking for suggestions to fix that) +- When app is running in foreground + - Both will receive notificaton from `FCMNotificationReceived` event -When app is running in foreground -- Both will receive notificaton from `FCMNotificationReceived` event +NOTE: it is recommend not to reply on extra data for click_action as it can be overwritten. check [this](http://stackoverflow.com/questions/33738848/handle-multiple-notifications-with-gcm) ## Q & A ### My android build is failing -- 2.26.2