在Android中未收到任何解析推送通知

时间:2015-11-12 16:16:55

标签: android parse-platform push-notification

所以我一直试图设置Parse的推送通知。我已经按照教程以及SO上的其他主题进行了操作,但却无法使用它。任何帮助都会很棒。我有多种产品口味,所以我不能静态地放入包装名称(或者我可以吗......)。我能够从解析仪表板发送推送通知,但我手机上没有收到任何通知。

Application.class

ParseACL defaultACL = new ParseACL();
        ParseACL.setDefaultACL(defaultACL, true);

        ParseCrashReporting.enable(this);

        Parse.initialize(this, "xxxxxxxxxxxx", "xxxxxxxxxxx");


        ParseUser.enableAutomaticUser();
        ParseUser.getCurrentUser().saveInBackground();


        ParseInstallation.getCurrentInstallation().saveInBackground();
        ParsePush.subscribeInBackground("", new SaveCallback() {
            @Override
            public void done(ParseException e) {
            }
        });

清单

 <!--
  IMPORTANT: Change "com.parse.starter.permission.C2D_MESSAGE" in the lines below
  to match your app's package name + ".permission.C2D_MESSAGE".
-->
<permission android:protectionLevel="signature"
    android:name="${applicationId}.permission.C2D_MESSAGE" />
<uses-permission android:name="${applicationId}.permission.C2D_MESSAGE" />

  <service android:name="com.parse.PushService" />
    <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="${applicationId}" />
        </intent-filter>
    </receiver>

    <meta-data android:name="com.parse.push.notification_icon"
        android:resource="@drawable/ic_launcher"/>

1 个答案:

答案 0 :(得分:0)

所以我终于想出了如何让它发挥作用,但是 - 我无法解释原因。我从这个帖子Working Answer得到了答案。

@Juven_v答案是对的。