在Android上杀死应用程序时,解析推送通知不起作用

时间:2016-01-26 09:23:39

标签: android parse-platform xamarin push-notification

我从Parse.com下载了一个Xamarin.Android推送通知示例项目,当应用程序处于前台或最小化时,它可以正常工作。 如果我从“最近的应用程序”屏幕中删除应用程序,则应用程序将不会显示将来的通知。

我的清单:

<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.parse.parsexamarinpushsample" android:versionCode="1" android:versionName="1.0" android:installLocation="auto">
<uses-sdk android:minSdkVersion="10" android:targetSdkVersion="21" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<permission android:protectionLevel="signature" android:name="com.parse.parsexamarinpushsample.permission.C2D_MESSAGE" />
<uses-permission android:name="com.parse.parsexamarinpushsample.permission.C2D_MESSAGE" />
<application android:name="parsexamarinpushsample.ParseApplication" android:label="ParseXamarinPushSample" android:icon="@drawable/Icon" android:theme="@android:style/Theme.Light">
    <receiver android:name="parse.ParsePushBroadcastReceiver" android:permission="com.google.android.c2dm.permission.SEND">
        <intent-filter>

    <action android:name="com.parse.push.intent.RECEIVE" />
    <action android:name="com.parse.push.intent.DELETE" />
    <action android:name="com.parse.push.intent.OPEN" />        
            <action android:name="com.google.android.c2dm.intent.RECEIVE" />
            <action android:name="com.google.android.c2dm.intent.REGISTRATION" />
            <category android:name="com.parse.parsexamarinpushsample" />
        </intent-filter>
    </receiver>
    <service android:name="parse.ParsePushService" />
</application>

我的代码:

public override StartCommandResult OnStartCommand(Intent intent, StartCommandFlags flags, int startId)
    {
        ParseClient.Initialize("appid", "clientid");
        ParsePush.ParsePushNotificationReceived += ParsePush.DefaultParsePushNotificationReceivedHandler;
        ParsePush.ParsePushNotificationReceived += ParsePushOnParsePushNotificationReceived;

        ParseInstallation installation = ParseInstallation.CurrentInstallation;

        installation.SaveAsync();

        return StartCommandResult.Sticky;
    }

发送通知后,我在Parse Dashboard上注意到通知被标记为“成功”,所以我有理由相信我的手机正在接收通知,但没有可以处理通知的应用程序。

我是否需要对广播接收器采取一些意图行动或我的清单出现问题?

提前致谢

1 个答案:

答案 0 :(得分:0)

从menifiest文件中删除删除权限。改变你这样的许可

<service android:name="com.parse.PushService" /> 
<service android:name="com.performtec.notification.PushHandler" />
<receiver android:name="com.parse.GcmBroadcastReceiver" android:permission="com.google.android.c2dm.permission.SEND">
<intent-filter>
 <action android:name="com.google.android.c2dm.intent.REGISTRATION" />
 <action android:name="com.google.android.c2dm.intent.RECEIVE" /> 
  <category android:name="com.PackageName.packageName" />