RocketChat / RocketChat/Rocket.Chat
iOS Test Push Notification: Could not send notification id: \"undefined\", Error: Cannot read property 'send' of undefined
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 46.1k
- Forks
- 13.9k
- Avg merge
- 3d 3h
- Merged PRs (30d)
- 130
Description
Description:
I have a own RocketChat server running. Therefore I configured Push notifications with own Google Firebase Cloud Messaging.
For Android it works fine.
For iOS not.
Steps to reproduce:
Prerequisit: Proper setup for Cloud Messaging in Google console. I only configured APN/Apple for Production. No need for develop.
- Go to Admin Settings Push Notifications
- Enable push notification
- Disable Gateway
- Enable Production
- Insert APN-Passphrase
- Insert APN-Key
- Insert APN-Cert
- Leave APN Dev settings empty
- Insert GCM-API-Key
- Insert GCM-Projectnumber
- Save Settings (maybe insert Password if requested)
- Restart Rocketchat
- Login on a Android Device (as same admin uer which is logged currently)
- Login on a iOS Device (as same admin uer which is logged currently)
- Click on "Send test push notification"
- You will not recieve any Push notification
Expected behavior:
I expected that a Test Push notification was send to my iOS phone and on my Android phone.
Even if sending push notification to iOS fails, I expected, that Android will still get Notifications.
Actual behavior:
Even on iOS or Android this admin user will not get any Push notification.
Others with only Android will still recieve Notifications.
Also when getting normal messages, this user will not get any notification on iOS or Android.
Server Setup Information:
- Rocket.Chat Version: 4.0.4
- NodeJS Version: 12.22.1 - x64
- MongoDB Version: 5.0.3
- MongoDB Engine: wiredTiger
- Platform: linux
- Process Port: 3000
- ReplicaSet OpLog: Enabled
- Commit Hash: 17db61995c
- Commit Branch: HEAD
- Deployment Method: docker
- Number of Running Instances: 1
Client Setup Information
- Desktop App or Browser Version: Firefox 93
- Operating System: MacOS
Additional context
If I remove the APN tokens in Database from this User directly in MongoDB:
// take care: Will remove ALL iOS tokens.
db.getCollection('_raix_push_app_tokens').deleteMany({ appName: "IOS_APP_NAME" })
db.getCollection('_raix_push_app_tokens').find()
db.getCollection('_raix_push_app_tokens').find({userId: "USER_ID"})
Then this admin user can recieve push notifications again on Android
Relevant logs:
rocketchat_1 | {"level":35,"time":"2021-10-26T17:58:08.118Z","pid":12,"hostname":"b5f052d979d3","name":"Meteor","method":"push_test","userId":"USER_ID","userAgent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:93.0) Gecko/20100101 Firefox/93.0","referer":"https://DOMAIN_NAME/admin/Push","remoteIP":"SERVER_IP","instanceId":"ixSWZfkv4kdtLyC4A"}
rocketchat_1 | {"level":20,"time":"2021-10-26T17:58:08.125Z","pid":12,"hostname":"b5f052d979d3","name":"Push","msg":"Sending notification {\"createdAt\":\"2021-10-26T17:58:08.125Z\",\"createdBy\":\"<SERVER>\",\"sent\":false,\"sending\":0,\"from\":\"push\",\"title\":\"@USER_NAME\",\"text\":\"This is a push test message\",\"userId\":\"USER_ID\",\"sound\":\"default\",\"apn\":{\"text\":\"@USER_NAME:\
This is a push test message\"}}"}
rocketchat_1 | {"level":20,"time":"2021-10-26T17:58:08.126Z","pid":12,"hostname":"b5f052d979d3","name":"Push","msg":"send message \"@USER_NAME\" to userId 'USER_ID'"}
rocketchat_1 | {"level":20,"time":"2021-10-26T17:58:08.128Z","pid":12,"hostname":"b5f052d979d3","name":"Push","msg":"send to token {\"gcm\":\"TOKEN_1\"}"}
rocketchat_1 | {"level":20,"time":"2021-10-26T17:58:08.128Z","pid":12,"hostname":"b5f052d979d3","name":"Push","msg":"send to token {\"gcm\":\"TOKEN_1\"}"}
rocketchat_1 | {"level":20,"time":"2021-10-26T17:58:08.129Z","pid":12,"hostname":"b5f052d979d3","name":"Push","msg":"sendGCM [\"TOKEN_1\"] {\"createdAt\":\"2021-10-26T17:58:08.125Z\",\"createdBy\":\"<SERVER>\",\"sent\":false,\"sending\":0,\"from\":\"push\",\"title\":\"@USER_NAME\",\"text\":\"This is a push test message\",\"userId\":\"USER_ID\",\"sound\":\"default\",\"apn\":{\"text\":\"@USER_NAME:\
This is a push test message\"}}"}
rocketchat_1 | {"level":20,"time":"2021-10-26T17:58:08.129Z","pid":12,"hostname":"b5f052d979d3","name":"Push","msg":"For devices running Android 8.0 or later you are required to provide an android_channel_id. See https://github.com/raix/push/issues/341 for more info"}
rocketchat_1 | {"level":20,"time":"2021-10-26T17:58:08.129Z","pid":12,"hostname":"b5f052d979d3","name":"Push","msg":"Create GCM Sender using \"GCM_TOKEN\""}
rocketchat_1 | {"level":20,"time":"2021-10-26T17:58:08.129Z","pid":12,"hostname":"b5f052d979d3","name":"Push","msg":"A:Send message to: TOKEN_1"}
rocketchat_1 | {"level":20,"time":"2021-10-26T17:58:08.130Z","pid":12,"hostname":"b5f052d979d3","name":"Push","msg":"send to token {\"apn\":\"APPLE_TOKEN_1\"}"}
rocketchat_1 | {"level":20,"time":"2021-10-26T17:58:08.130Z","pid":12,"hostname":"b5f052d979d3","name":"Push","msg":"send to token {\"apn\":\"APPLE_TOKEN_1\"}"}
rocketchat_1 | {"level":20,"time":"2021-10-26T17:58:08.131Z","pid":12,"hostname":"b5f052d979d3","name":"Push","msg":"Could not send notification id: \"undefined\", Error: Cannot read property 'send' of undefined"}
rocketchat_1 | {"level":20,"time":"2021-10-26T17:58:08.135Z","pid":12,"hostname":"b5f052d979d3","name":"Push","msg":"TypeError: Cannot read property 'send' of undefined
at sendAPN (app/push/server/apn.js:48:16)
at PushClass.sendNotificationNative (app/push/server/push.js:87:5)
at app/push/server/push.js:208:16
at SynchronousCursor.forEach (packages/mongo/mongo_driver.js:1141:16)
at Cursor.<computed> [as forEach] (packages/mongo/mongo_driver.js:920:44)
at PushClass.sendNotification (app/push/server/push.js:201:35)
at PushClass.send (app/push/server/push.js:325:9)
at MethodInvocation.push_test (server/lib/pushConfig.js:56:8)
at MethodInvocation.methodsMap.<computed> (app/lib/server/lib/debug.js:66:34)
at maybeAuditArgumentChecks (packages/ddp-server/livedata_server.js:1771:12)
at packages/ddp-server/livedata_server.js:1689:15
at Meteor.EnvironmentVariable.EVp.withValue (packages/meteor.js:1234:12)
at packages/ddp-server/livedata_server.js:1687:36
at new Promise (<anonymous>)
at Server.applyAsync (packages/ddp-server/livedata_server.js:1686:12)
at Server.apply (packages/ddp-server/livedata_server.js:1625:26)
at Server.call (packages/ddp-server/livedata_server.js:1607:17)
at Object.post (app/api/server/v1/misc.js:240:26)
at app/api/server/api.js:406:82
at Meteor.EnvironmentVariable.EVp.withValue (packages/meteor.js:1234:12)
at Object._internalRouteActionHandler [as action] (app/api/server/api.js:406:39)
at Route.share.Route.Route._callEndpoint (packages/nimble_restivus/lib/route.coffee:150:32)"}
rocketchat_1 | {"level":35,"time":"2021-10-26T17:58:08.136Z","pid":12,"hostname":"b5f052d979d3","name":"API","method":"POST","url":"/api/v1/method.call/push_test","userId":"USER_ID","userAgent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:93.0) Gecko/20100101 Firefox/93.0","length":"87","host":"DOMAIN_NAME","referer":"https://DOMAIN_NAME/admin/Push","remoteIP":"SERVER_IP","status":200,"responseTime":18}
rocketchat_1 | {"level":20,"time":"2021-10-26T17:58:08.237Z","pid":12,"hostname":"b5f052d979d3","name":"Push","msg":"ANDROID: Result of sender","result":{"multicast_id":3915736355400703500,"success":1,"failure":0,"canonical_ids":0,"results":[{"message_id":"0:1635271088214377%cfce24ca0034af1a"}]}}
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at app/push/server/apn.js:48 and trace how push.js handles the APN token after the push_test method in server/lib/pushConfig.js. Reproduce with the listed production APN settings and verify that iOS and Android test and normal notifications work without preventing Android delivery.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- firebase, javascript, node.js
- Domain
- backend, mobile-dev
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 28/100