当我的应用关闭时,重新启动解析推送通知

时间:2015-08-04 20:15:53

标签: android parse-platform xamarin notifications push

请帮帮我...)

当我的应用关闭时,我需要重新发送解析推送通知。当应用程序被破坏时,它可以正常工作,但当我关闭它时,它会崩溃。

我的申请类:

[Application(Name="ffc.droid.ParseApplication")]
    public class ParseApplication : Application
    {
        public ParseApplication (IntPtr javaReference, JniHandleOwnership transfer) : base(javaReference, transfer)
        {
        }

    public override void OnCreate ()
    {
        base.OnCreate ();

        // Initialize the Parse client with your Application ID and .NET Key found on
        // your Parse dashboard

            ParseClient.Initialize("xxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
                "xxxxxxxxxxxxxxxxxxxxx");

            ParsePush.ParsePushNotificationReceived += (object sender, ParsePushNotificationEventArgs e) => {
                // Show notification
            };

            ParsePush.SubscribeAsync (new string[] { "new_video", "new_news", "new_event" });
            ParseInstallation.CurrentInstallation.SaveAsync ();
        }
    }

我的AndroidManiFest文件:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionName="1.4" package="ffc.droid" android:versionCode="4">
    <uses-sdk android:minSdkVersion="17" android:targetSdkVersion="17" />
    <uses-permission android:name="android.permission.SET_WALLPAPER" />
    <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.GET_ACCOUNTS" />
    <uses-permission android:name="android.permission.VIBRATE" />
    <uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
    <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
    <permission android:protectionLevel="signature" android:name="ffc.droid.permission.C2D_MESSAGE" />
    <meta-data android:name="com.parse.push.notification_icon"
            android:resource="@drawable/ic_menu_ffk"/>
    <uses-permission android:name="ffc.droid.permission.C2D_MESSAGE" />

    <application android:label="KFF.KZ" android:icon="@drawable/ic_menu_ffk" android:name="ffc.droid.ParseApplication">
        <service android:name="parse.ParsePushService" />
        <receiver android:name="parse.ParsePushBroadcastReceiver" 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="ffc.droid" />
            </intent-filter>
        </receiver>
    </application>
</manifest>

怎么了?

1 个答案:

答案 0 :(得分:0)

我有同样的问题,但是如果你看到git的回购,你需要在另一个类中初始化parse选项并在androidManifest文件中做引用。