0

嗨,我在数字海洋上有自托管解析服务器,它在 iOS 上发送通知,但在 android 上不发送。我的 index.js 文件如下所示:

var api = new ParseServer({
  databaseURI: databaseUri || 'mongodb://1.1.1.1"1/app_name',
  cloud: process.env.CLOUD_CODE_MAIN || __dirname + '/cloud/main.js',
  appId: 'abc',
  masterKey: 'def', 
  serverURL: 'http://1.1.1.1:1337/parse' || 'http://localhost:1337/parse',  
  verbose: true,
  push: {
    android:{
      senderId: 'my FCM id',
      apiKey: 'my FCM key'
    },
    ios: {
      pfx: '1',
      bundleId: '2',
      production: true
    }
  }
});

当我从解析仪表板(也是自托管的)发送推送时,这是我得到的详细响应:true:

"results": [
  {
    "objectId": "bNtZqwY8",
    "pushTime": "2017-06-13T10:49:06.095Z",
    "query": "{\"UniqueId\":\"c49de788ce\",\"deviceType\":{\"$in\":[\"android\"]}}",
    "payload": "{\"alert\":\"Thank you for using my app.\"}",
    "source": "rest",
    "status": "succeeded",
    "numSent": 0,
    "pushHash": "266b6b637152b36040830",
    "createdAt": "2017-06-13T10:49:06.095Z",
    "updatedAt": "2017-06-13T10:49:06.214Z",
    "numFailed": 15,
    "failedPerType": {
      "android": 15
    },
    "ACL": {}
  },
  {
    "objectId": "rsYinvGG",
    "pushTime": "2017-06-13T10:48:42.449Z",
    "query": "{\"UniqueId\":\"7A0A-9AEA-5870FDEC42A3\"}",
    "payload": "{\"alert\":\"one\",\"link_key\":1,\"sound\":\"default\"}",
    "source": "rest",
    "status": "succeeded",
    "numSent": 2,
    "pushHash": "246431e019c0357dcb180c7",
    "createdAt": "2017-06-13T10:48:42.449Z",
    "updatedAt": "2017-06-13T10:48:43.282Z",
    "numFailed": 0,
    "sentPerType": {
      "ios": 2
    },
    "ACL": {}
  },

当我从 FCM 发送 android 推送时,它可以工作。我真的迷失在这里与android push,有人可以指出我正确的方向。

这是日志的输出:

ESC[36mverboseESC[39m: REQUEST for [PUT] /parse/classes/_Installation   /zKIp8LLOWr: {
                                                                              "GCMSenderId":"diMV6Hm3j07dbqVPEsZRgqNzDo3YvA5zNdUmtO6Q4ka5ijRyyIRHiWCWOBVBDA22OIls-4bO06kxDPuOKFwJUZuMD3Xt41WuKUoOJwBlW7cKdqv9llj7Me0uiWFLWDwS7V",
  "UniqueId": "a59020fff8ca30d00",
  "appVersion": "2.3.3",
  "objectId": "zKIp8LLOWr"
} method=PUT, url=/parse/classes/_Installation/zKIp8LLOWr, x-parse-  app-display-version=2.3.3, x-parse-installation-id=29918e2f-8bbd-4ab7-975f-f854e1f43689, user-agent=Parse Android SDK 1.13.1 (com.mrfizzy/18) API Level 21, connection=Keep-Alive, accept-encoding=gzip, x-parse-os-version=5.0, x-parse-app-build-version=18, content-type=application/json, x-parse-client-key=, x-parse-client-version=a1.13.1, host=46.101.199.219:1337, content-length=245, x-parse-application-id=JHyfl9YhXCQ24r6J8ohdVlHLt1hfWhB4MF2jQAQn, GCMSenderId=diMV6HmLH3I:APA91bFQS4Sq9G5wlej07dbqVPEsZRgqNzDo3YvA5zNdUmtO6Q4ka5ijRyyIRHiWCWOBVBDA22OIls-4bO06kxDPuOKFwJUZuMD3Xt41WuKUoOJwBlW7cKdqv9llj7Me0uiWFLWDwS7V, UniqueId=a59020a48ca30d00, appVersion=2.3.3, objectId=zKIp8LLOWr
ESC[31merrorESC[39m: Error generating response. ParseError { code: 101, message: 'Object not found for update.' } code=101, message=Object not found for update.
[object Object]
4

1 回答 1

0

看来您没有正确分配发件人 ID。您传递的 objectId 似乎不正确。确保ParseInstallation.getCurrentInstallation()在设置 GCM 发件人 ID 时使用,而不是尝试通过任何其他方式进行安装。

http://parseplatform.org/Parse-SDK-Android/api/com/parse/ParseInstallation.html#getCurrentInstallation()

于 2017-06-13T17:19:39.207 回答