应用程序关闭时Appcelerator Android通知未收到

时间:2017-10-19 22:02:09

标签: android push-notification titanium appcelerator

我使用appcelerator开发了一个新的Android应用程序。我使用ti.cloudpush来使用来自firebase的推送通知,如example;如果应用程序处于后台,则通知会成功发送并显示在设备的通知栏中,但是当应用程序处于前台或关闭时未收到通知,尽管发送过程的结果是“成功”#34;。

我需要将其设为facebook messenger,如果应用程序关闭,则会在设备屏幕中显示。我尝试了其他几个模块,如" ti.goosh"和" nl.vanvianen.android.gcm",我发现在Android世界中我应该写" START_STICKY"在应用程序的某个地方,即使应用程序已关闭,也要强制执行服务以保持处理。

我尝试开发单独的服务并在tiapp.xml中调用它,但是如果应用程序关闭,服务也会被终止。

修改 是否必须安装任何sdk工具,appcelerator需要在构建过程中使用

2 个答案:

答案 0 :(得分:0)

如果Android设备安装了Google Play服务,则无需任何操作即可使推送通知在后台或前台工作。我正在使用ti.goosh模块,它的工作正常。 我认为您向设备发送了错误的数据以正确显示通知,我正在发送此数据:

data: {
    "data":
        {
            'title': 'Notification title',
            'alert': 'Short user notification text, when it is shown as pop up after receiving notification',
            'big_text': 'Long notification text, when user expanding it',
            'sound': 'default', //notification sound (here is default to user android settings)
            'force_show_in_foreground': true, //is notification must be shown when application in foreground
            'color': '#0dd149' //background color of notification icon
        }
}

答案 1 :(得分:0)

我如下解决了。

文件/app/platform/android/res/values/strings.xml
是必需的

,并且具有firebase项目的google_app_id

<?xml version="1.0" encoding="UTF-8"?>
    <resources>
        <string name="google_app_id">1:11111111111:android:aaaaaaaaa</string>
</resources>

此文件与Firebase模块通信。