zayn1991
zayn1991

Reputation: 172

PUSH-notification duplicated with empty content

Dispatched test push into my device.

When the application is active, push comes normally with sound, but when the app is minimized, comes 2 empty pushes and without sound.

Even if onMessageReceived left empty, still displays two empty push-notifications.

The class receiving PUSH:

    public class MyGcmListenerService extends GcmListenerService implements MyLocation, DownloadListner {

    @Override
    public void onMessageReceived(String from, Bundle data) {
    sendNotificationPushNewMessages();
    }

    private void sendNotificationPushNewMessages() {

    Intent intent = new Intent(this, MainInfoActivity.class);
    PendingIntent contentIntent = PendingIntent.getActivity(this, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);

    NotificationCompat.Builder b = new NotificationCompat.Builder(this);
         b.setAutoCancel(true)
        .setDefaults(Notification.DEFAULT_ALL)
        .setWhen(System.currentTimeMillis())
        .setSmallIcon(R.mipmap.ic_launcher)
        .setTicker("Hearty365")
        .setContentTitle("Default notification")
        .setContentText("Lorem ipsum dolor sit amet, consectetur adipiscing elit.")
        .setDefaults(Notification.DEFAULT_LIGHTS| Notification.DEFAULT_SOUND)
        .setContentIntent(contentIntent)
        .setContentInfo("Info");

    NotificationManager notificationManager = (NotificationManager) this.getSystemService(Context.NOTIFICATION_SERVICE);
    notificationManager.notify(1, b.build());

}

Text PUSH:

    {"to":"cHj0nruQddQ:APA91bHZZ4i02rZA7s8qyEIWtBJE-5PUry-mhAUlUWE0z3XVa4kX4CTxwD9cwWLnp-FbAAwc9zBQMf9Hghwz5B7ym51NVSt_S-9ChHW09E2LfHQyT6mtCgjMkF1fNyvQIAKfguH63ze9","content_available":true,"priority":"high","data":{"type":"push_new_messages","text":"\u041f\u0440\u043e\u0432\u0435\u0440\u043a\u0430"}}

content available and the priority uses for ios version

What could be the trouble? Can the class does not receive something when Activiti minimized?

Upvotes: 2

Views: 390

Answers (1)

zayn1991
zayn1991

Reputation: 172

content available and the priority for ios version in api was source of mistakes for push-notifications.

I wanted to use same api for android and ios devices, but when i deleted that 2 strings from api, it became ok in android.

Upvotes: 1

Related Questions