Android 通知点击负载上的 PushPlugin 保持不变

Android PushPlugin on notification tap payload stays the same

我用 PushPlugin

制作了一个应用

到目前为止一切顺利,我收到了预期的通知。但是,如果我同时推送 2+ 个通知,它会在状态栏中正常显示通知。但是,如果我点击第二个 (+),我将收到第一个通知的有效负载。

我找了一整天都没找到:(

希望有人能帮帮我

科尔多瓦 5

插件:Link

顺便说一句:这发生在 1 个事件上 "coldstart"

此问题的原因在于 GCMIntentService.java,代码是通过以下方式启动应用程序:

PendingIntent contentIntent =  
  PendingIntent.getActivity(this, 0, notificationIntent, PendingIntent.FLAG_UPDATE_CURRENT);

这意味着它始终使用相同的 requestCode。所以应用程序总是使用第一个通知负载。解决方法是更改​​每个通知的 requestCode

int requestCode = new Random().nextInt();
PendingIntent contentIntent = PendingIntent.getActivity(this, requestCode,
  notificationIntent, PendingIntent.FLAG_UPDATE_CURRENT);

我们已经在新版本的 PushPlugin 中解决了这个问题,可以在以下位置找到:

https://github.com/phonegap/phonegap-plugin-push

这是我们在 PhoneGap Day EU 上宣布的 PushPlugin 版本,它将得到维护,而不是您当前使用的插件版本。

在此处找到修复:https://github.com/phonegap-build/PushPlugin/issues/328

notId 的处理方式有所不同