android - 在 cordova android 的状态栏中显示多个推送通知

标签 android cordova push-notification ionic-framework

我在 cordova 中成功实现了推送通知 using 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());

最佳答案

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

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

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

我还想警告你,当前版本的插件,v2.4.0,有一个错误,所以当用户点击通知时,你的应用程序仍然只会收到最新的数据通知。这里有针对该问题的补丁:https://github.com/phonegap-build/PushPlugin/pull/333

关于android - 在 cordova android 的状态栏中显示多个推送通知,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26975558/

相关文章:

android - Kotlin - 通过 Intent 将函数作为参数传递

javascript - meteor -Cordova :How To add permissions?

cordova - PhoneGap 到底有什么用?

cordova - 无法将推送通知插件添加到 cordova 中

iOS 将通知对象发送到 UserNotificationCenter 和 didFinishLaunchingWithOptions

javascript - 网络推送通知未显示

android - 加速 SQLite 数据库 android

android - 如何确定在android上按下了哪个按钮

android - Android 上的方位角/偏航和滚动方向传感器值不一致

svn - Cordova 准备/构建从源代码管理 (SVN) 取消绑定(bind) WWW 文件夹