PushNotification不与在背景中的应用程式的工作 [英] PushNotification not working with the app in background

查看:165
本文介绍了PushNotification不与在背景中的应用程式的工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的是开发一个iOS和Android应用程序的离子/科尔多瓦,然后我试图让在推送通知工作在这两个平台上的 PushPlugin 库。

问题是我收到的推送通知的适用于iOS 工作正常,但Android是一个有点怪异到底是怎么回事,当应用程序的在前台,通知到达成功,但如果应用程序是在后台(应用程序是接近),该通知从未收到...

这个有什么想法? 权限

我跟着这个教程用于获取GCM工作的通知(我的code是相似的),还我与genymotion测试通知。

下面是我的Andr​​oidManifest.xml

 < XML版本='1.0'编码='UTF-8'&GT?;
<表明机器人:hardwareAccelerated =真正的安卓版code =1机器人:=的versionName0.0.1包=com.CohereHealth.CeliacCare的xmlns:机器人=HTTP://模式。 android.com/apk/res/android\">
    <支持屏安卓anyDensity =真正的机器人:largeScreens =真正的机器人:normalScreens =真正的机器人:调整大小=真正的机器人:smallScreens =真正的机器人:xlargeScreens =真/>
    <使用许可权的android:NAME =android.permission.INTERNET对/>
    <应用机器人:hardwareAccelerated =真正的机器人:图标=@绘制/图标机器人:标签=@字符串/ APP_NAME>
        <活动机器人:configChanges =方向| keyboardHidden |键盘|屏幕尺寸|区域机器人:标签=@字符串/ ACTIVITY_NAME机器人:launchMode =singleTop机器人:名字=应用程序安卓主题=@机器人:风格/ Theme.Black.NoTitleBar机器人:windowSoftInputMode =adjustResize>
            <意向过滤器的android:标签=@字符串/ LAUNCHER_NAME>
                <作用机器人:名字=android.intent.action.MAIN/>
                <类机器人:名字=android.intent.category.LAUNCHER/>
            &所述; /意图滤光器>
        < /活性GT;
        <活动机器人:出口=真正的机器人:名字=com.plugin.gcm.PushHandlerActivity/>
        <接收机器人:名字=com.plugin.gcm.CordovaGCMBroadcastReceiver机器人:权限=com.google.android.c2dm.permission.SEND>
            &所述;意图滤光器>
                <作用机器人:名字=com.google.android.c2dm.intent.RECEIVE/>
                <作用机器人:名字=com.google.android.c2dm.intent.REGISTRATION/>
                <类机器人:名字=com.app/>
            &所述; /意图滤光器>
        < /接收器>
        <服务机器人:名字=com.plugin.gcm.GCMIntentService/>
    < /用途>
    <采用-SDK安卓的minSdkVersion =10机器人:targetSdkVersion =19/>
    <使用许可权的android:NAME =android.permission.ACCESS_NETWORK_STATE/>
    <使用许可权的android:NAME =android.permission.GET_ACCOUNTS/>
    <使用许可权的android:NAME =android.permission.WAKE_LOCK/>
    <使用许可权的android:NAME =android.permission.VIBRATE/>
    <使用许可权的android:NAME =com.google.android.c2dm.permission.RECEIVE/>
    <允许机器人:名字=com.app.permission.C2D_MESSAGE安卓的ProtectionLevel =签名/>
    <使用许可权的android:NAME =com.app.permission.C2D_MESSAGE/>
    <使用许可权的android:NAME =android.permission.WRITE_EXTERNAL_STORAG​​E/>
    <使用许可权的android:NAME =android.permission.RECORD_AUDIO/>
    <使用许可权的android:NAME =android.permission.MODIFY_AUDIO_SETTINGS/>
    <使用许可权的android:NAME =android.permission.READ_PHONE_STATE/>
< /清单>


解决方案

尝试,如果你发送这个结构载荷的通知看

  {
   消息:消息
}

I'm developing an iOS and android app using ionic/cordova, and I'm trying to get the push notifications working on both platforms with the PushPlugin library.

The thing is I'm getting the push notifications working OK for iOS, but in android is a little weird what is going on, when the app is in foreground, the notification arrives successfully, but when the app is in background (the app is close), the notification never arrives...

Any thoughts about this? Permissions?

I followed this tutorial for getting the gcm notifications working (my code is similar) and also I'm testing the notifications with genymotion.

Here's my AndroidManifest.xml

<?xml version='1.0' encoding='utf-8'?>
<manifest android:hardwareAccelerated="true" android:versionCode="1" android:versionName="0.0.1" package="com.CohereHealth.CeliacCare" xmlns:android="http://schemas.android.com/apk/res/android">
    <supports-screens android:anyDensity="true" android:largeScreens="true" android:normalScreens="true" android:resizeable="true" android:smallScreens="true" android:xlargeScreens="true" />
    <uses-permission android:name="android.permission.INTERNET" />
    <application android:hardwareAccelerated="true" android:icon="@drawable/icon" android:label="@string/app_name">
        <activity android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale" android:label="@string/activity_name" android:launchMode="singleTop" android:name="app" android:theme="@android:style/Theme.Black.NoTitleBar" android:windowSoftInputMode="adjustResize">
            <intent-filter android:label="@string/launcher_name">
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity android:exported="true" android:name="com.plugin.gcm.PushHandlerActivity" />
        <receiver android:name="com.plugin.gcm.CordovaGCMBroadcastReceiver" android:permission="com.google.android.c2dm.permission.SEND">
            <intent-filter>
                <action android:name="com.google.android.c2dm.intent.RECEIVE" />
                <action android:name="com.google.android.c2dm.intent.REGISTRATION" />
                <category android:name="com.app" />
            </intent-filter>
        </receiver>
        <service android:name="com.plugin.gcm.GCMIntentService" />
    </application>
    <uses-sdk android:minSdkVersion="10" android:targetSdkVersion="19" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.GET_ACCOUNTS" />
    <uses-permission android:name="android.permission.WAKE_LOCK" />
    <uses-permission android:name="android.permission.VIBRATE" />
    <uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
    <permission android:name="com.app.permission.C2D_MESSAGE" android:protectionLevel="signature" />
    <uses-permission android:name="com.app.permission.C2D_MESSAGE" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.RECORD_AUDIO" />
    <uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
    <uses-permission android:name="android.permission.READ_PHONE_STATE" />
</manifest>

解决方案

Try to look if you are sending the notification payload with this structure:

{
   message : "message"
}

这篇关于PushNotification不与在背景中的应用程式的工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆