Appcelerator关闭应用程序时未收到Android通知
问题描述:
我使用appcelerator开发新的Android应用程序。我使用ti.cloudpush来使用来自firebase的推送通知,如example;如果应用程序处于后台,通知将成功发送并显示在设备的通知栏中,但当应用程序处于前台或未关闭状态时,即使发送处理结果为“成功”,也不会收到通知。Appcelerator关闭应用程序时未收到Android通知
我需要使它像facebook messenger一样,如果应用程序已关闭,则会显示在设备屏幕中。我尝试了其他几个模块,例如“ti.goosh”和“nl.vanvianen.android.gcm”,我发现在Android世界中,我应该在应用程序的某个地方编写“START_STICKY”以强制执行该服务,以便即使应用程序已关闭。
我试图开发单独的服务并在tiapp.xml中调用它,但如果应用程序关闭,服务也会被终止。
编辑 有任何SDK工具必须安装该Appcelerator的需要在构建过程中使用
答
如果Android设备已谷歌Play服务,安装,不需要任何行动,使推notificatons工作在背景或前景。我正在使用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
}
}
你确定你是不是在应用程序的关闭状态下接收PN?因为如果你在后台模式下收到它们,那么你也必须以杀死状态接收它们。如果您使用ti.cloudpush,则无需编写任何其他服务代码。欲了解更多信息,你可以分享你的项目环境的细节和一些代码片段,说明你如何编写PN代码? –
在杀人状态下接收推送没有任何进展。我一直在很多应用程序中使用ti.cloudpush,没有任何打嗝。你还可以分享你正在使用什么样的GCM或FCM? –
我使用FCM,我创建了一个名为notification.js的文件并将其保存在app/lib中,我需要这个文件在index.js中并初始化它,这个文件与名为android的通道一起保存。 –