oney / react-native-gcm-android

GCM for React Native Android
MIT License
172 stars 76 forks source link

app closed - find which notification launched app - popInitialNotification equivalent #17

Open jawadrehman opened 8 years ago

jawadrehman commented 8 years ago

I think this module is 90% complete functionality wise. its just an equivalent of popInitialNotification that seems to be missing.

What I have figured out is that we will need to probably put an extra to the intent in onCreateNotification function of GcmModule.java , and probably create a method to give the value of that.

oney commented 8 years ago

Yes, identifying which notification launched app isn't supported yet. Besides putting an extra to the intent in onCreateNotification, we should listen intent when launch the app. In MainActivity.java

protected void onCreate(Bundle savedInstanceState) {
    getIntent(); // check if launch from notification, and send to JS
    ...
}
@Override
protected void onNewIntent(Intent intent) {
    super.onNewIntent(intent);
    // send intent to GcmAndroid module
}

There are some works to do, I think I may not have time to do it this week.

jawadrehman commented 8 years ago

@oney i might have sorted it out - I would like to submit this as a pull request. can you give me details on how to do this.

oney commented 8 years ago

https://github.com/zo0r/react-native-push-notification/blob/b826276e291c0ab011eec80b210d39b63a1c2437/RNPushNotificationAndroid/src/main/java/com/dieam/reactnativepushnotification/modules/RNPushNotification.java#L50 This module already handles the feature. We can use some codes and the idea to do it.

jawadrehman commented 8 years ago

I have done something similar. But also changed a few lines of your code, since with your code only one notification would show up if the app is not open.

oney commented 8 years ago

Can you share codes or create a PR? It will be very useful to me.

jawadrehman commented 8 years ago

pull request here. https://github.com/oney/react-native-gcm-android/pull/19