Reputation: 1702
I want to save push notification for my application on Android in following scenarios so that I can later display it in my apps message center.
1) Notification received when app is not running (neither in background nor foreground)
2) Notification is received by the device but is accidentally dismissed by the user.
I am aware that device maintains a a log of notifications (history). How can I fetch the notifications for my application from this log?
Upvotes: 0
Views: 289
Reputation: 1121
If GCM is properly set up in the app, each time user's device receives a push notification, Android OS will trigger your implementation of GcmListenerService (see example https://github.com/google/gcm/blob/master/samples/android/gcm-demo/src/main/java/com/google/android/gcm/demo/service/GcmService.java) and thus start your app.
If you want to store the received messages for the future reference, then do it in your implementation of onMessageReceived(String from, Bundle data)
.
Upvotes: 1