迁移到 Heroku 上的解析服务器后无法接收(或发送?)Android 的推送通知
Cannot receive (or send?) Push notifications for Android after migrating to parse-server on Heroku
每次向 Android 客户端发送推送时,我都会得到以下信息:
03-22 17:15:21.751 1585-2213/? I/GCM: GCM 消息 0:1458663322082941%5774d2def9fd7ecd
03-2217:15:21.803 1585-1585/? W/GCM-DMM:广播意图回调:result=CANCELLED forIntent { act=com.google.android.c2dm.intent.RECEIVE pkg=(有额外的)}
我向清单文件添加了所有必要的权限和元数据。在迁移之前,我在接收推送通知(通过云代码或 REST API 发送)时没有遇到任何问题。
是否有人也遇到过这种情况,您找到解决方案了吗?
编辑:
来自清单文件的代码:
...
<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" />
<category android:name="com.unicorn.app" />
</intent-filter>
</receiver>
<receiver
android:name=".functions.CustomParseBroadcastReceiver"
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>
...
自定义广播接收器class:
public class CustomParseBroadcastReceiver extends ParsePushBroadcastReceiver {
protected void onPushReceive(Context context,
Intent intent) {....
编辑:这是 _PushStatus 集合中文档的样子:
{
"_id": {
"$oid": "some-other-id"
},
"objectId": "some-id",
"pushTime": "2016-03-19T17:51:12.235Z",
"_created_at": {
"$date": "2016-03-19T17:51:12.235Z"
},
"query": "{\"deviceType\":{\"$in\":[\"ios\",\"android\"]}}",
"payload": {
"title": "The Shining",
"alert": "All work and no play makes Jack a dull boy."
},
"source": "rest",
"title": null,
"expiry": null,
"status": "succeeded",
"numSent": 0,
"pushHash": "f41355801d168ad58b479075e9a8576e",
"_wperm": [],
"_rperm": [],
"numFailed": 0
}
所以 numSent 显然意味着没有发送推送,不是吗?另一方面,我收到了 gcm 消息,因此似乎收到了推送 不知何故。
我设法 "solve" 通过将 parse-server npm 包降级到版本 1.6 来做到这一点。
另请参阅:https://github.com/ParsePlatform/parse-server/issues/1151
似乎缺少推送 ID。
每次向 Android 客户端发送推送时,我都会得到以下信息:
03-22 17:15:21.751 1585-2213/? I/GCM: GCM 消息 0:1458663322082941%5774d2def9fd7ecd 03-2217:15:21.803 1585-1585/? W/GCM-DMM:广播意图回调:result=CANCELLED forIntent { act=com.google.android.c2dm.intent.RECEIVE pkg=(有额外的)}
我向清单文件添加了所有必要的权限和元数据。在迁移之前,我在接收推送通知(通过云代码或 REST API 发送)时没有遇到任何问题。
是否有人也遇到过这种情况,您找到解决方案了吗?
编辑: 来自清单文件的代码:
...
<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" />
<category android:name="com.unicorn.app" />
</intent-filter>
</receiver>
<receiver
android:name=".functions.CustomParseBroadcastReceiver"
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>
...
自定义广播接收器class:
public class CustomParseBroadcastReceiver extends ParsePushBroadcastReceiver {
protected void onPushReceive(Context context,
Intent intent) {....
编辑:这是 _PushStatus 集合中文档的样子:
{
"_id": {
"$oid": "some-other-id"
},
"objectId": "some-id",
"pushTime": "2016-03-19T17:51:12.235Z",
"_created_at": {
"$date": "2016-03-19T17:51:12.235Z"
},
"query": "{\"deviceType\":{\"$in\":[\"ios\",\"android\"]}}",
"payload": {
"title": "The Shining",
"alert": "All work and no play makes Jack a dull boy."
},
"source": "rest",
"title": null,
"expiry": null,
"status": "succeeded",
"numSent": 0,
"pushHash": "f41355801d168ad58b479075e9a8576e",
"_wperm": [],
"_rperm": [],
"numFailed": 0
}
所以 numSent 显然意味着没有发送推送,不是吗?另一方面,我收到了 gcm 消息,因此似乎收到了推送 不知何故。
我设法 "solve" 通过将 parse-server npm 包降级到版本 1.6 来做到这一点。
另请参阅:https://github.com/ParsePlatform/parse-server/issues/1151
似乎缺少推送 ID。