【问题标题】:My app does not receive Parse push notifications我的应用没有收到 Parse 推送通知
【发布时间】:2015-11-06 17:29:44
【问题描述】:

我已经为 Parse 通知设置了我的应用程序并严格按照说明进行操作,但不知何故我没有收到任何通知。这里有什么问题?

更新:我刚刚尝试在 Parse.com 网站上发送测试推送通知。这应该可以在不订阅频道的情况下工作(见评论)

我的 AndroidManifest.xml(仅相关部分):

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

    <permission android:protectionLevel="signature"
        android:name="co.bla.bla.permission.C2D_MESSAGE" />
    <uses-permission android:name="co.bla.bla.permission.C2D_MESSAGE" />

<!-- Push notification setup -->
        <service android:name="com.parse.PushService" />
        <receiver android:name="co.bla.bla.ParsePushReceiver"
            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" />

                <category android:name="co.bla.bla" />
            </intent-filter>
        </receiver>

    </application>

我已经扩展了ParsePushBroadcastReceiver:

public class ParsePushReceiver extends com.parse.ParsePushBroadcastReceiver{

    @Override
    protected void onPushReceive(Context context, Intent intent ) {

        ParseAnalytics.trackAppOpenedInBackground(intent);

        String s = intent.getStringExtra("alert");
        Log.d("Push received", s);
        // do your stuff here
        if(SugarSnapApplication.INACTIVE)
            super.onPushReceive(context, intent);
    }

    @Override
    protected void onPushOpen(Context context, Intent intent) {
        // TODO Auto-generated method stub
        Intent i = new Intent(context, SugarActivity.class);
        i.putExtras(intent.getExtras());
        i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        context.startActivity(i);
    }

    @Override
    protected Notification getNotification(Context context, Intent intent) {
        // TODO Auto-generated method stub
        return super.getNotification(context, intent);
    }

    @Override
    protected void onPushDismiss(Context context, Intent intent) {
        // TODO Auto-generated method stub
        super.onPushDismiss(context, intent);
    }
}

【问题讨论】:

  • 您订阅了您发送的频道吗?
  • @IliiazAkhmedov 我刚刚尝试在 Parse.com 网站上发送测试推送通知。
  • 我的意思是在您的应用程序的应用程序类中,您是否调用 ParsePush.subscribeInBackground("");
  • @IliiazAkhmedov 不,我没有在我的应用程序类中调用它。当我通过网站发送给“所有人”时,这真的有必要吗?如果有必要,该频道的名称是什么?顺便说一句,我在设置说明中没有看到任何必要的地方。

标签: android parse-platform push-notification


【解决方案1】:

我终于找到了问题所在。几天前我已经重命名了我的应用程序的整个包名,显然没有在任何地方进行更改,我的build.gradle 文件中的 applicationId 仍然是旧的。所以很自然地,我的 AndroidManifest.xml 中的包名称与我的 Installation 类中保存的包名称不同。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-05-22
    • 1970-01-01
    • 2020-05-25
    相关资源
    最近更新 更多