【问题标题】:Show multiple push notification in status bar in cordova android在cordova android的状态栏中显示多个推送通知
【发布时间】:2015-01-14 12:49:14
【问题描述】:

我在cordovausing this push plugin中成功实现了推送通知。

一切正常,但如果收到多个通知,则只有最新通知可用。我已经提到了this answer,但它使用的是旧插件。

这是我从答案中尝试的代码。

int notId=0;
try {
  notId = Integer.parseInt(extras.getString("notId"));
}
catch(NumberFormatException e) {
  Log.e(TAG, "Number format exception - Error parsing Notification ID: " + e.getMessage());
}
catch(Exception e) {
  Log.e(TAG, "Number format exception - Error parsing Notification ID" + e.getMessage());
}

notId++;
mNotificationManager.notify((String) appName, notId, mBuilder.build());

【问题讨论】:

  • notId 始终等于 0。因此它不会显示很多通知。将 notId 声明为 globle,它将起作用。
  • 你的意思是声明为全局类变量
  • 在 createNotification 函数之外定义 notId。
  • 我试过但没用
  • 你能展示一个示例代码吗?

标签: android cordova push-notification ionic-framework


【解决方案1】:

Phonegap PushPlugin 使用从 GCM 服务器传递的通知的 notId 属性分隔多个通知。

您需要做的是确保在您的服务器上生成具有唯一 notId 属性的通知,当您将通知发送到 GCM 服务时(不是在手机上!!!)

(notId 属性是通知数据对象上的一个属性,就像messagetitle)。

我还想警告您,当前版本的插件 v2.4.0 存在错误,因此当用户单击通知时,您的应用仍将仅收到最新数据的通知。这里有一个解决这个问题的补丁:https://github.com/phonegap-build/PushPlugin/pull/333

【讨论】:

  • 你救了我……谢谢哥们。我希望我可以对某些答案进行多次投票
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2017-08-26
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多