解析通知无法在Android中运行

时间:2015-04-16 10:47:59

标签: android

解析通知未从Parse Server的Android应用程序中接收。

在下面的链接中,显示的通知不会通过解析服务

上的Push sent 0发送

https://www.parse.com/apps/bluejay-test/push_notifications/mmBUWvc8US

同样在解析帐户中,启用客户端推送是“是”。

我发送来自解析云服务器的推送通知,它没有在Android APP中接收但是在ios APP中接收。它有时会进入Android手机。

请告诉我这是什么问题?

在登录用户时间,我正在使用此代码

ParseInstallation.getCurrentInstallation().put("uuid",user.getUuid());
ParseInstallation.getCurrentInstallation().put("email",parseUser.getEmail());
ParseInstallation.getCurrentInstallation().put("uuid",user.getUuid());
ParseInstallation.getCurrentInstallation().saveInBackground(new SaveCallback() {
@Override
                public void done(ParseException arg0) {

                                 }});

并且还遵循所有故障排除步骤并在AndroidManifest.xml中添加了配置

<permission
        android:name="com.redblink.bluejay.permission.C2D_MESSAGE"
        android:protectionLevel="signature" />

    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.GET_ACCOUNTS" />
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.WAKE_LOCK" />
    <uses-permission android:name="android.permission.READ_PHONE_STATE" />
    <uses-permission android:name="android.permission.VIBRATE" />
    <uses-permission android:name="com.redblink.bluejay.permission.C2D_MESSAGE" />
    <uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />

<receiver
            android:name="com.redblink.bluejay.CustomParsePushBroadcastReceiver"
            android:exported="false" >
            <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" />
            </intent-filter>
        </receiver>

        <service android:name="com.parse.PushService" />

        <receiver android:name="com.parse.ParseBroadcastReceiver">
            <intent-filter>
                <action android:name="android.intent.action.BOOT_COMPLETED" />
                <action android:name="android.intent.action.USER_PRESENT" />
            </intent-filter>
        </receiver>

        <receiver
            android:name="com.parse.GcmBroadcastReceiver"
            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.redblink.bluejay" />


            </intent-filter>
        </receiver>

我添加了CustomParsePushBroadcastReceiver来接收通知

public class CustomParsePushBroadcastReceiver extends ParsePushBroadcastReceiver {
    private String TAG ="CustomParsePushBroadcastReceiver"    ;
    BlueJayApplication application;
    @Override
    public void onReceive(Context context, Intent intent) {
        BlueJayApplication application = (BlueJayApplication) context.getApplicationContext();

        Bundle e = intent.getExtras();

        for (String key : e.keySet()) {

            BluejayDebug.Log(TAG, "Extra: " + key);
            BluejayDebug.Log(TAG, "" + e.getString(key));
        }

        BluejayNotificationManager.Init(context);
        BluejayNotificationManager.getInstance().sendGenericNotification("BlueJay", "New bluejay event");

    }

    public void setApplication(){


    }
}

2 个答案:

答案 0 :(得分:0)

修改此

   <receiver
        android:name="com.redblink.bluejay.CustomParsePushBroadcastReceiver"
        android:exported="false" >
        <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" />
        </intent-filter>
    </receiver>

到此

<receiver android:name="com.redlink.bluejay.CustomParsePushBroadcastReceiver">
        <intent-filter>
            <action android:name="android.intent.action.BOOT_COMPLETED" />
            <action android:name="android.intent.action.USER_PRESENT" />
        </intent-filter>
    </receiver>

答案 1 :(得分:0)

你应该重写的函数是onPushReceive()而不是onReceive()。更改功能,这将解决问题。

文档解释了这一点。 https://parse.com/docs/android/api/com/parse/ParsePushBroadcastReceiver.html