[英]PUSH-notification duplicated with empty content
將測試推送到我的設備中。
當應用程序處於活動狀態時,推送會正常發出聲音,但當應用程序最小化時,會出現 2 次空推送且沒有聲音。
即使onMessageReceived
空,仍會顯示兩個空推送通知。
接收 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());
}
文字推送:
{"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
和ios版本priority
使用
可能有什么問題? 當 Activiti 最小化時,類是否可以不接收一些東西?
content available
和 api 中 ios 版本的priority
是推送通知錯誤的來源。
我想對 android 和 ios 設備使用相同的 api,但是當我從 api 中刪除那 2 個字符串時,它在 android 中就可以了。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.