-
Notifications
You must be signed in to change notification settings - Fork 76
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Notification does not disappear on status bar after it's clicked #12
Comments
The configuration of notification is in here. |
@oney Rather than requiring users to write their own Java wrappers, which I think some people might be uncomfortable with (since they're on React Native), would it be possible to add methods for removing notifications from status bar and such behaviour inside the JS API? That might lower barriers to entry and make this library usable for a wider audience. |
Of course it is possible. Because the bridge of JS and native will be paused by default when the app enters background(onPause), we can't handle notifications in JS code. GcmAndroid.Setting.setAutoCancel(true); In java, store the setting using SharedPreferences SharedPreferences preferences = context.getSharedPreferences("MyPreferences", Context.MODE_PRIVATE);
SharedPreferences.Editor editor = preferences.edit();
editor.putBoolean("GcmAndroid.Setting.autoCancel", autoCancel);
editor.commit(); And get the setting when getting notification. SharedPreferences preferences = context.getSharedPreferences("MyPreferences", Context.MODE_PRIVATE);
NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this)
.setAutoCancel(preferences.getBoolean("GcmAndroid.Setting.autoCancel", false)) May do it in the future and also welcome a PR! |
Hello, First of all, awesome plugin, thanks a lot for making it. I got the notifications working, I can now send notifications and they pop up. However, I think I'm having the same problem as above:
And I have another issue, which I'm not sure is related:
I'm having some trouble getting this to work. I have no Java experience so it's kinda hard. I tried implementing your commit: oney/TestGcm@5fa3614 and also created a listener and added the change in my AndroidManifest.xml. But it does not work for me. To see if it changes anything at all, I tried setting ContentTitle/ContentText to something else like:
Am I overlooking something? What am I doing wrong? |
@TxiX Which this module version you use? |
@oney Thanks for your reply. I use the following node modules:
|
@TxiX |
@oney First of: Thanks alot for the update! However, I'm unable to get it to work. I've copied the exact code from the README.md and put it in my index.android.js I then changed all the things you mentioned in the README (looked at the commit). The thing that works is registering, receiving a token and sending notifications. However I'm still unable to click them (I'm using the default RNGcmListenerService now, but I tried changing it and it had no effect). I also see no console message from the 'notification' eventListener when I'm receiving the notification inside the app. |
It's ok. |
Run |
Hey. So I tried to run the TestGCM package. The TestGCM package does not show me the notification though. This is what I get when running
I'll see what adb logcat says on my own app. |
Yeah, the source of the issue is |
Alright. Both the TestGcm and my own app crash when they're closed and not running in the background. My own app gives the same kinda log when it's open. When it's closed, this is the log:
Thanks again for your time. |
Oh, crash when they're closed and not running in the background is due to lack of
|
Alright! Got the following working now:
It still shows a dialog my app is crashed though. Even though the app opens after clicking on the notification.
When the app is open, I see the following (only after I opened it and do nothing):
And after a reload of the JS:
Hope this helps! |
Very useful. Thanks for helping solve the problem. About crash of
Does it mean after clicking notification the app launches and crashed? |
I see you added 0.1.12. I tested the app with this and the messages inside the app work! They now get properly console logged, even when I reload the JS afterwards and send a new notification. Basically everything works now, except that the app still crashes after I receive a notification (when the app is closed and not running in the background). The notification and the error dialog pop up at the same time. I can dismiss the dialog, click the notification and the app starts properly. It's only the dialog showing up what's the problem now. You're correct that I'm running this in my own app instead of the TestGcm app. If you want, I can test it and see if that one also crashes for me? |
Good!
About above issue, react native version of |
That's correct! I'm using the following node modules now:
|
Just update 0.1.3 to npm. It should work on react native 0.17.0.
Thanks! |
You are awesome! Everything works. Notification when the app is in the foreground Notification when the app is in the background and alive Notification when app is closed Clicking notification will open the app Reload JS and send notifications One bug (it's a far fetched one)
Results in isForGround = false, even though the app is running. |
0.1.5 should solve it. Please try it! |
Heyo. Sorry for my late reply! A use case like that would be extremely rare for my app, but perhaps other people will profit from it. Thanks for taking a look at it. I just tested it and it does not seem to work yet. I followed the exact same steps, and I end up with GcmAndroid.isInForeground = false This is with version 0.1.6 and react-native 0.17.0 |
@oney i am experiencing this issue . it seems that |
The notification stays at the tool bar and sometimes freezes it. I am placing the addEventListener and requestPermissions() methods at index.android.js file and under componentWillMount() method. I am using RN0.15 and Android 4.2.2 on Genymotion. Is it because I use it wrong or similar cases are encountered by others as well? Thanks a lot!
The text was updated successfully, but these errors were encountered: