Onesignal-android-sdk: Getting Two Push Notification.

Created on 11 Apr 2016  路  8Comments  路  Source: OneSignal/OneSignal-Android-SDK

I have Implemented my own Push receiver class. But I am getting two push notification. One is my and the other one is default with the messages which I am sending from OneSignal.
I have declared my Receiver in the manifest.
Please help.
device-2016-04-11-164321

Question

Most helpful comment

@Ghayyas There are only two causes that could create duplicated notifications for Android.

  1. You have another notification plugin in your app. Run cordova plugin list to list them.
  2. If you are using our REST API and send more than one with the same contains by mistake.

All 8 comments

To keep our SDK from displaying a notification you will need to omit 'contents' from the notification.

Thanks.

Can I turn off notifications that arrive through the sdk and pocesar all notifications through BroadcastReceiver?

Thanks

Hey Aronmoles,

You can not turn off notification that arrive through the SDK. If you want to turn off then you need to send push notification from OneSingal without Content.
Then, the content you want to send you need to put that content in the additional field.
Below is the example for the same.

Just put your json in the Value filed with a key.

Then use below mentioned code to parse that JSON in your broadcast receiver.
Bundle dataBundle = intent.getBundleExtra("data");
String alert = dataBundle.getString("custom");
JSONObject obj = new JSONObject(alert);
if (obj.has("a")) {
JSONObject o1 = obj.getJSONObject("a");
JSONObject o = new JSONObject(o1.getString("custom"));
}

I am assuming 'custom' is the key in the additional data field.

Also check background data enabled.

Hope this help.
Thanks.
Junaid

@aronmoles
junaidstalkbylove's suggestion above will work. If need to have contents set on your notification we are working on adding a broadcast receiver option.
https://github.com/one-signal/OneSignal-Android-SDK/pull/32#issuecomment-215533646

I also faced that issue in my android 6.0

@Ghayyas There are only two causes that could create duplicated notifications for Android.

  1. You have another notification plugin in your app. Run cordova plugin list to list them.
  2. If you are using our REST API and send more than one with the same contains by mistake.

@jkasten2 Thanks. The issue was multiple push plugins in my file. So Just Remove all Plugins and Platform folder and make build again and it works.

@jkasten2 dude.. you saved a ton of time for me!! cheers.

Was this page helpful?
0 / 5 - 0 ratings