oney / react-native-gcm-android

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

react native gcm android clicking on notification not opening the app #22

Closed jojonarte closed 8 years ago

jojonarte commented 8 years ago

Hey I have this issue on our simple app that should let the app receive a GCM Notification when receiving a request from the server. I was able to let the notification show up, but then clicking on the notification won't open the app? Is there any functionality that I can do to make the react-native-gcm-android listen to notification clicks? Is this a known issue? Or is there any known fix to this?

oney commented 8 years ago

You are using v0.1.6, right?

jojonarte commented 8 years ago

Oops, I have been using 0.1.3 I'll try 0.1.6 and let you know.

jojonarte commented 8 years ago

Right now I've tested it, and I'm currently on 0.1.6, I couldn't get the app to show upon clicking the notification received.

oney commented 8 years ago

Can you confirm re-reading README to follow new usage?

jojonarte notifications@github.com 於 2016年1月8日星期五 寫道:

Right now I've tested it, and I'm currently on 0.1.6, I couldn't get the app to show upon clicking the notification received.

— Reply to this email directly or view it on GitHub https://github.com/oney/react-native-gcm-android/issues/22#issuecomment-169901329 .

jojonarte commented 8 years ago

I've re-read and made sure I have put all the right codes and settings, Do I need the 'react-native-system-notification' to be able to listen to clicks on the notification and show the app???

oney commented 8 years ago

No, you don't. I will test to try reproducing later. Have you tried the demo project TestGcm?

jojonarte notifications@github.com 於 2016年1月8日星期五 寫道:

I've re-read and made sure I have put all the right codes and settings, Do I need the 'react-native-system-notification' to be able to listen to clicks on the notification and show the app???

— Reply to this email directly or view it on GitHub https://github.com/oney/react-native-gcm-android/issues/22#issuecomment-169903042 .

jojonarte commented 8 years ago

Demo project works fine. Alright let me know. As of now I can't open the app by tapping notification.

iambernie3 commented 8 years ago

hi @oney , I have the same problem with @jojonarte if I tapping the notification I just want directly open the app.

jojonarte commented 8 years ago

Update:

I've retested the sample, the sample works right out from cloning. i wonder if the multidex true issue on our gradle file could be triggering the problem on not listening to clicks on notification??

ps: We definitely need the multidex as our app requires a huge amount of dependencies. Do you have any known workaround on this?

babalustu commented 8 years ago

Hi @jojonarte,

Have you tried sending the push notification to your app using oneys test code (but replacing with your server API key and device token)? I was having exactly the same issue (also using multidex true) and it turned out to be the structure of the gcm object I was sending from my server.

I did have the subject and message in the notification node: notification: { title: "Hello, World", icon: "ic_launcher", body: "This is a notification that will be displayed ASAP." }

but moved it to the data node as per oney:

"data": { "info": { "subject": "Hello GCM2", "message": "Hello from the server side!" } }

Not sure it's the ideal workaround but it works well enough for me.

chinloongtan commented 8 years ago

it works for me when I remove android:exported="false" from

<receiver
  android:exported="false"
  android:name="com.oney.gcm.GcmBroadcastReceiver">
  <intent-filter>
  <action android:name="com.oney.gcm.GCMReceiveNotification" />
    </intent-filter>
</receiver>

Since it wasn't there for the demo app's AndroidManifest.xml

mtford90 commented 8 years ago

Experiencing this too. I've implemented all the advice in this issue but no luck! I'm running gcm 0.2.0 and system-notification 0.1.8.

savioseb commented 8 years ago

I commented out the GcmAndroid.stopService();

and it's worked well for me.

My change: `if (GcmAndroid.launchNotification) { console.log('Before entering function:', GcmAndroid.launchNotification); //GcmAndroid.stopService(); console.log('GcmAndroid.launchNotification:', GcmAndroid.launchNotification); var notification = GcmAndroid.launchNotification; var info = JSON.parse(notification.info); Notification.create({ subject: info.subject, message: info.message, });

//GcmAndroid.stopService(); } else { class Savio extends Component { .....`

savioseb commented 8 years ago

Also fixed this problem #51

xphaul commented 8 years ago

@jojonarte how did you fix this issue? i've tried following savioseb fix but i still cant get to open the app upon clicking the notification . thanks