Commit 8ffcac97 authored by Libin Lu's avatar Libin Lu

hook on newIntent to broadcast notification clicked when app in background

parent c079acad
......@@ -24,7 +24,7 @@ import java.util.HashMap;
import java.util.Map;
import java.util.Set;
public class FIRMessagingModule extends ReactContextBaseJavaModule {
public class FIRMessagingModule extends ReactContextBaseJavaModule implements LifecycleEventListener {
private final static String TAG = FIRMessagingModule.class.getCanonicalName();
Intent mIntent;
......@@ -33,6 +33,7 @@ public class FIRMessagingModule extends ReactContextBaseJavaModule {
mIntent = intent;
getReactApplicationContext().addLifecycleEventListener(this);
registerTokenRefreshHandler();
registerMessageHandler();
}
......@@ -117,4 +118,26 @@ public class FIRMessagingModule extends ReactContextBaseJavaModule {
}
}, intentFilter);
}
@Override
public void onHostResume() {
Intent newIntent = getCurrentActivity().getIntent();
if(newIntent != mIntent && newIntent != null){
WritableMap params = Arguments.fromBundle(newIntent.getExtras());
WritableMap fcm = Arguments.createMap();
fcm.putString("action", newIntent.getAction());
params.putMap("fcm", fcm);
sendEvent("FCMNotificationReceived", params);
}
mIntent = newIntent;
}
@Override
public void onHostPause() {
}
@Override
public void onHostDestroy() {
}
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment