Parse.com推送通知不发送

时间:2015-08-03 08:46:06

标签: android parse-platform push-notification

我已经在两个设备上运行我的应用程序,在屏幕上发送推送通知,它告诉我将有2个收件人。但是,当我发送通知时,手机上没有任何内容。

屏幕上的

显示发送的推送通知列表我可以看到我的通知,目标“Everyone”和“Pushes Sent”字段为“0”

这是我的应用程序类;

import android.app.Application;
import android.util.Log;

import com.parse.Parse;
import com.parse.ParseException;
import com.parse.ParseInstallation;
import com.parse.ParsePush;
import com.parse.PushService;
import com.parse.SaveCallback;


/**
 * Created by andrew on 31/07/15.
 */
public class android extends Application {

    @Override
    public void onCreate() {
        Parse.initialize(this, "KEY HERE", "KEY HERE");
        Parse.setLogLevel(Parse.LOG_LEVEL_VERBOSE);
        ParseInstallation.getCurrentInstallation().saveInBackground();

        ParsePush.subscribeInBackground("", new SaveCallback() {
            @Override
            public void done(ParseException e) {
                if (e == null) {
                    Log.d("com.parse.push", "successfully subscribed to the broadcast channel.");
                } else {
                    Log.e("com.parse.push", "failed to subscribe for push", e);
                }
            }
        });

        PushService.setDefaultPushCallback(this, LoginActivity.class);


        System.out.println(ParseInstallation.getCurrentInstallation().toString());
        super.onCreate();

    }
}

这是我的清单;

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.my.app.android" >

    <uses-permission android:name="android.permission.INTERNET" />
    <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="com.google.android.c2dm.permission.RECEIVE" />
    <uses-permission android:name="android.permission.VIBRATE" />
    <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />

    <permission android:protectionLevel="signature"
        android:name="com.my.app.android.permission.C2D_MESSAGE" />

    <uses-permission android:name="com.my.app.android.permission.C2D_MESSAGE" />


    <application
        android:allowBackup="true"
        android:hardwareAccelerated="true"
        android:icon="@drawable/launcherid"
        android:label="mEnquirer"
        android:name=".android"
        android:screenOrientation="portrait"
        android:theme="@style/AppTheme" >

<!-- Activitys where here -->

        <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.ParsePushBroadcastReceiver"
            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.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" />

                <!--
                  IMPORTANT: Change "com.parse.starter" to match your app's package name.
                -->
                <category android:name="com.my.app.android" />
            </intent-filter>
        </receiver>
    </application>

</manifest>

1 个答案:

答案 0 :(得分:0)

我设法解决了这个问题,事实证明我在某些时候更改了清单中的软件包名称,这让人感到困惑。

我创建了一个新项目并将我的代码复制到它,现在一切正常。

相关问题