【问题标题】:Error with PushPlugin when the App is in background当应用程序在后台时,PushPlugin 出错
【发布时间】:2014-04-24 22:39:42
【问题描述】:

我正在尝试使用以下代码实现使用 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

【问题讨论】:

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


    【解决方案1】:

    我使用插件“GCMIntentService.java”在第 80 行附近实现了一个解决方案,这是下一条指令

    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

    因为payload.price给我们带来了未定义。

    从这个意义上说,我们必须在JAVA插件中归档

    if (extras.getString ("message")! = null && extras.getString ("message").length ()! = 0) { createNotification(上下文,选项); }

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

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2019-05-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-04-24
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多