Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to read One Signal Push Notification Message in android?

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?

like image 813
Parama Sudha Avatar asked Apr 12 '16 08:04

Parama Sudha


Video Answer


2 Answers

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.

like image 143
Gdeglin Avatar answered Nov 15 '22 09:11

Gdeglin


Add

compile 'com.onesignal:OneSignal:[3.7.1, 3.99.99]'

add this code under android

manifestPlaceholders = [onesignal_app_id: "app_id Enter here",
                         onesignal_google_project_number: "REMOTE"]
like image 22
Rachit Mishra Avatar answered Nov 15 '22 08:11

Rachit Mishra