【问题标题】:Not receiving push notification on android with parse.com使用 parse.com 在 android 上未收到推送通知
【发布时间】:2015-02-28 00:11:36
【问题描述】:

我对 Android 应用程序开发非常陌生。我使用 parse.com 作为我的后端,并按照教程https://www.parse.com/tutorials/android-push-notifications 设置推送通知。但是,每当我使用解析通知控制台(在网站上)或从 Android 设备发送通知时,我都不会收到任何通知。其次,在解析通知控制台上,每个通知显示 0 作为推送发送。当我在应用程序当前 ParseInstallation 的 deviceToken 字段中检查注册 ID 时,它是空的。甚至 GCMSenderID 也是空的。所以我怀疑我的应用程序没有正确注册,但 installationID 字段不为空。我已在清单文件中添加了所有权限和凭据。

请帮助我。这将是一个很大的帮助。谢谢你:)

这是我的清单文件:

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />

<!--
  IMPORTANT: If you change the package name of this sample app, change
  "com.parse.tutorials.pushnotifications.permission.C2D_MESSAGE" in the
  lines below to match the new package name.
-->
<permission
    android:name="com.parse.swipeit.permission.C2D_MESSAGE"
    android:protectionLevel="signature" />

<uses-permission android:name="com.parse.swipeit.permission.C2D_MESSAGE" />

<application
    android:name="com.parse.swipeit.Application"
    android:allowBackup="true"
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/AppTheme" >
    <activity
        android:name="com.parse.swipeit.MainActivity"
        android:label="@string/app_name" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>

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

            <!--
              IMPORTANT: If you change the package name of this sample app,
              change "com.parse.tutorials.pushnotifications" in the lines
              below to match the new package name.
            -->
            <category android:name="com.parse.swipeit" />
        </intent-filter>
    </receiver>
</application>

【问题讨论】:

  • 请发布您的清单
  • @StephanBranczyk 请检查清单

标签: android parse-platform push-notification


【解决方案1】:

这部分很重要。

<!-- IMPORTANT: Change "com.parse.starter" to match your app's package
 name. -->

您需要使用 Google 开发者控制台为您启用 Google Cloud Messaging api。为此,您需要使用自己唯一的有效包名称(仅属于您,不属于其他任何人)。

【讨论】:

  • 我已经输入了我的应用程序包名。 “com.parse.starter”是包名,但它仍然不起作用
  • 不,那个包名“com.parse.starter”不属于你。它属于 parse.com,谷歌知道这一点。您必须在整个应用程序中使用不同的包名称。
  • 我用不同的包名开始了一个新项目。当我再次运行它时,该应用程序确实注册了自己,但 deviceToken 字段仍然为空。所以当我发送推送通知时,它显示 0 作为推送发送。我已将问题中的清单更改为新清单。所以你可以再检查一遍
  • 它正在工作。你是对的。我完全改变了我的包名,它正在工作:)谢谢:)
  • @user2709885 你能分享一下你是怎么解决的吗?我仍然无法在设备上收到通知
猜你喜欢
  • 1970-01-01
  • 2013-10-08
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2022-07-27
  • 1970-01-01
相关资源
最近更新 更多