Push notification delivered twice when the delay to next notif is around 1-10min ish

i have the push notification problem being delivered twice . it occurs when i publish notification for example at 11 am, its working normal. but when i publish another message in the next some minutes(dont know exactly until what minutes, but i input is next 2-3 minutes) that notification being sent twice. but if i wait quite long time to publish another notification(not exactly sure until what minute) its delivered only once.
so here is the code, im using custom for adding sound on notification,
MyReceiver.java
public class MyReceiver extends BackendlessBroadcastReceiver {
@Override
public Class<? extends BackendlessPushService> getServiceClass()
{
return MyService.class;
}
}
MyService.java
public class MyService extends BackendlessPushService {
@Override
public void onRegistered(Context context, String registrationId )
{
Log.v(“onRegistered”,“registered”);
//Toast.makeText( context, “registered” + registrationId, Toast.LENGTH_SHORT).show();
}
@Override
public void onUnregistered( Context context, Boolean unregistered )
{
Log.v(“onUnregistered”,“unregistered”);
//Toast.makeText( context, “unregistered”, Toast.LENGTH_SHORT).show();
}
@Override
public boolean onMessage( Context context, Intent intent )
{
//String message = intent.getStringExtra( “message” );
CharSequence tickerText = intent.getStringExtra( PublishOptions.ANDROID_TICKER_TEXT_TAG );
CharSequence contentTitle = intent.getStringExtra( PublishOptions.ANDROID_CONTENT_TITLE_TAG );
CharSequence contentText = intent.getStringExtra( PublishOptions.ANDROID_CONTENT_TEXT_TAG );
String message = intent.getStringExtra( PublishOptions.MESSAGE_TAG );
android.support.v4.app.NotificationCompat.Builder mBuilder =
new android.support.v4.app.NotificationCompat.Builder(context)
.setSmallIcon(R.mipmap.ic_launcher)
.setContentTitle(contentTitle)
.setContentText(contentText)
.setTicker(tickerText)
.setAutoCancel(true)
.setOngoing(true)
.setSound(RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION));
NotificationManager mNotificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
mNotificationManager.notify(1, mBuilder.build());
Log.v(“ticker value”,String.valueOf(tickerText)+"\n"+String.valueOf(contentTitle)+"\n"+String.valueOf(contentText));
return true;
}
@Override
public void onError( Context context, String message )
{
Toast.makeText( context, message, Toast.LENGTH_SHORT).show();
}
}
Manifest.xml: https://gist.github.com/anonymous/efabaecfe775cffc5c12bf53eaaf35dc

class that publish notiftication :
PublishOptions publishOptions = new PublishOptions();
publishOptions.putHeader( “android-ticker-text”, “You just got a notification!” );
publishOptions.putHeader( “android-content-title”, title );
publishOptions.putHeader( “android-content-text”, content );

DeliveryOptions deliveryOptions = new DeliveryOptions();
Date publishDate = expireDate;
deliveryOptions.setPublishAt( publishDate );
deliveryOptions.addPushSinglecast(deviceId);
Backendless.Messaging.publish((Object)“tes”, publishOptions, deliveryOptions, new AsyncCallback<MessageStatus>() {
@Override
public void handleResponse(MessageStatus response) {
messageId=response.getMessageId();
Log.v(“Status success”,"sukses, messageId = "+messageId);

}
@Override
public void handleFault(BackendlessFault fault) {
Log.v(“Status fail”,fault.getMessage());
}
});

Is it the first notification coming twice or the second one? Also, please provide your application ID.

its the second notification, first notification working fine

app id : 7ED10098-C113-C7B1-FF0F-65BAA6D62800

Have you checked whether the same behavior is observed when you don’t override BackendlessPushService?

hey what u mean is using default backendless receiver n service? i change manifest to original like this:


<intent-filter>

<category android:name=“com.example.vayne.snapit”/>
</intent-filter>
</receiver>
<service android:name=“com.backendless.push.BackendlessPushService” />and the bug doesnt show. is there any wrong code i put on custom push?

OK, so it seems there’s no bug in Android SDK. In this case, can you please prepare a sample application which reproduces the problem and which we can just launch without much setting up?

hey sergey here is the sample app, i dont know why but now even first push notification already delivered twice

Sample.rar (21.67MB)

Thanks for the sample!
Internal task BKNDLSS-13281 has been created to investigate the issue. We shall notify you here as soon as we have any news.

hey sergey is there any update?

Hi,

The task is still in progress.

In your Receiver’s onMessage() handler you need to return false in case you show the notification by yourself. If you leave “return true;”, the notification will be displayed automatically by Android SDK, that’s why you were receiving a duplicate.

We shall also add this information to the documentation. Thank you for help in investigating!

ty sergey, that solve the problem!