【问题标题】:Parse push notifications without gcm不使用 gcm 解析推送通知
【发布时间】:2016-01-25 22:57:59
【问题描述】:

我在我的项目中实现 Parse 推送通知,但由于法律问题,我无法安装 Google Play 服务,因此用于接收通知的广播接收器是 ParsePushBroadcastReceiver,而不是 GcmBroadcastReceiver。首先,我尝试在清单中使用此代码:

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

然后,我尝试了这个:

<service android:name="com.parse.PushService" />
<receiver android:name="com.parse.ParsePushBroadcastReceiver"
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="com.parse.starter" />
  </intent-filter>
</receiver>

因此,设备注册时没有 pushType 和 deviceToken,在两个字段中都显示文本 (undefined)。 当我尝试向所有已注册的设备发送推送时,Parse 会抛出错误,例如:

但安装当前处于活动状态。 谁能帮帮我?

提前致谢。

【问题讨论】:

    标签: android parse-platform push-notification


    【解决方案1】:

    您错过了解析应用程序 ID 和客户端密钥(您会在解析仪表板上找到这些值)

    <application
        ...>
        [...]
    
        <meta-data
            android:name="com.parse.APPLICATION_ID"
            android:value="xxxxxxxxxxxxxxx" />
        <meta-data
            android:name="com.parse.CLIENT_KEY"
            android:value="yyyyyyyyyyyyyyy" />
    
        [...]
    </application>
    

    在接收器内:

    <category android:name="com.parse.starter" />
    

    应该是:

    <category android:name="you.package.name" />
    

    【讨论】:

    • 正如我在帖子中所说,应用程序是在解析中注册的,因此在我的应用程序中设置了 application_id 和 client_key 以及项目名称
    • 我回答的最后一部分呢?
    • 改行很重要
    猜你喜欢
    • 2015-03-08
    • 2012-11-27
    • 2016-07-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-01-01
    • 2013-02-02
    • 2016-01-01
    相关资源
    最近更新 更多