How to read One Signal Push Notification Message in android?

Parama Sudha picture Parama Sudha · Apr 12, 2016 · Viewed 7.2k times · Source

I need to read One Signal's Push Notification information.Depends on that I need to change the delivery status of a product in my eCommerce app.

How to read it?

Answer

Gdeglin picture Gdeglin · Apr 12, 2016

Here is the OneSignal guide on how to run custom code when a notification is received:

  1. Turn on the content-available (iOS) or silent-notification (Android) fields. This will cause your application to be automatically woken up in the background whenever a notification is received (even if it's not clicked). Your custom code must be write with native code, Java on Android and Swift or Objective-C on iOS. See Apple's content-available for iOS and our Android Background Data guides for details on receiving and processing the event.
  2. In your app, we provide an API that you can use to run custom code when the above occurs. Your custom code can then save a copy of the notification content on the device in order to be displayed in an activity feed when the app is next launched. Or it could save a copy of it on your servers.

Notifications can contain metadata (supplied as "data" in the OneSignal API) that will be passed to your custom code.