简体   繁体   English

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

[英]Not receiving any parse push notifications in Android

So I've been trying to set up Parse's push notifications. 因此,我一直在尝试设置Parse的推送通知。 I've followed the tutorial as well as other threads on SO but just can't get it to work. 我已经按照本教程以及SO上的其他线程进行了学习,但无法使其正常工作。 Any help would great. 任何帮助都很好。 I have multiple product flavors so I can't statically put the package name (or can I?.....). 我有多种产品口味,所以我不能静态输入包装名称(或者可以吗?)。 I'm able to send push notifications from the parse dashboard, but I am not receiving any notifications on my phone. 我可以从解析仪表板发送推送通知,但是我的手机没有收到任何通知。

Application.class 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) {
            }
        });

Manifest 表现

 <!--
  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"/>

So I finally figured out how to get it to work, BUT - I can't explain why. 因此,我终于想出了如何使其工作的方法,但是-我无法解释原因。 I got the answer from this thread Working Answer . 我从该线程工作答案中得到了答案。

@Juven_v answer was correct. @Juven_v的答案是正确的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM