应用程序处于后台时,PushPlugin出错

时间:2014-04-24 22:39:42

标签: android cordova notifications push-notification phonegap-pushplugin

我尝试使用以下方法实现使用Cordava 3.3创建的推送通知应用:https://github.com/phonegap-build/PushPlugin;基于我的教程:www.androidhive.info/2012/10/android-push-notifications-using-google-cloud-messaging-gcm-php-and-mysql 但我有两个基本问题,第一个是如果应用程序处于后台或关闭时通知不会导致通知不会导致应用程序在前台打开时消息达到未定义,可能会有所帮助,就我而言读取可能是由于JSON响应的格式或在其中发送的参数。

这是我的代码不用多久: https://github.com/jedidas/Push

1 个答案:

答案 0 :(得分:1)

我在第80行附近插件“GCMIntentService.java”实现了一个存档的解决方案

else {
    extras.putBoolean("foreground", false);

            // Send a notification if there is a message
            if (extras.getString("message") != null && extras.getString("message").length() != 0) {
                createNotification(context, extras);
            }
        }

发现你可以改变你想要的“价格”,例如改变“消息”的“价格”,一切都解决了milagorsamente,解释:

我们有这个: 。 1 $ message = array(“deprive”=> $ message);

当我读到它时阅读: 1. E.payload.message

因为有效载荷而导致我们未定义。

从这个意义上说,我们必须提交JAVA插件

if(extras.getString(“message”)!= null&& extras.getString(“message”)。length()!= 0){ createNotification(context,options); }

如果没有运行,因为它以“价格”而不是“消息”的形式出现。当我将SEND_MESSAGE.PHP的“价格”更改为“消息”时,一切都解决了。因此甚至不需要修改JAVA。

相关问题