0

Hi i have self hosted parse server on digital ocean, it is sending notifications on iOS but not on android. my index.js file looks like this:

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
    }
  }
});

when i send a push from the parse dashboard (also self hosted), this is the response i get with verbose: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": {}
  },

When i send push on android from FCM, it works. Im really lost here with android push, can someone please point me in the right direction.

Here is the output from the log:

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]

1 Answers1

0

It appears you're not assigning the Sender Id properly. You're passing an objectId that doesn't seem to be correct. Make sure you use ParseInstallation.getCurrentInstallation() when you set your GCM sender id rather than trying to get the installation by any other means.

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

Jake T.
  • 4,308
  • 2
  • 20
  • 48
  • im not using GCM, im using FCM senderId and apiKey in my index.js file as shown on top of the question. I dont see this line `ParseInstallation.getCurrentInstallation()` anywhere in that file. Will this in the app? I think app is fine as notifications do go when sent from FCM dashboard – Jawad Sadiq Jun 13 '17 at 17:37
  • Read your log output. The error is because no object is found with the right ObjectId you're passing, and you're also setting the GCMSenderId in the PUT request. You're trying to save an object that doesn't exist. – Jake T. Jun 13 '17 at 18:06
  • You're trying to save _Installation object with id zKIp8LLOWr (which doesn't seem to exist, is that a User's objectId perhaps?), and you're passing GCMSenderId: diMV6Hm3j07dbqVPEsZRgqNzDo3YvA5zNdUmtO6Q4ka5ijRyyIRHiWCWOBVBDA22OIls-4bO06kxDPuOKFwJUZuMD3Xt41WuKUoOJwBlW7cKdqv9llj7Me0uiWFLWDwS7V . The message in the error says "Object not found", which implies that no _Installation object has objectId zKIp8LLOWr – Jake T. Jun 13 '17 at 18:08
  • still no luck, i dont get that object missing error anymore, this is the response i am getting now: `results=[objectId=jVctUq1lKv, pushTime=2017-06-14T10:18:19.030Z, query={"UniqueId":"c34f81f49de788ce","deviceType":{"$in":["android"]}}, payload={"alert":"Tabib"}, source=rest, status=succeeded, numSent=0, pushHash=25e44ea99f48ca8a9c54ff1ef578bdbc, createdAt=2017-06-14T10:18:19.030Z, updatedAt=2017-06-14T10:18:19.233Z, numFailed=16, android=16, ]` it says failed 16 but doesnt say why it failed – Jawad Sadiq Jun 14 '17 at 10:20
  • You're sure you've got the sender id and api key in there right? You would get failures for uninstalls. If you run a push from the local server, it shows the error for each send attempt, so you can see specifically what went wrong. I would clear your installations, reinstall your app fresh, and try again with fresh data. – Jake T. Jun 14 '17 at 15:43