-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
No Notification for Data Message #62
Comments
Commenting on my own issue because I found a workaround for sending data from a notification to the app. Please comment on the viability of this workaround as I can only test it for 3.0.0-beta1 on iOS 11.1.1 (iPhone 7). WorkaroundAs mentioned in my original post, 'data' messages aren't actually showing any notifications, so we are forced to use a 'notification' message. According to the documentation, tapping on a 'notification' message does not forward the notification data to the app; however, this is not the case. curl -X POST -H "Authorization: key=$key" -H "Content-Type: application/json" -d "{
\"to\": \"$token\",
\"notification\": {
\"title\": \"title\",
\"data\": {\"key1\":\"val1\",\"key2\":\"val2\"}
}
}
" https://fcm.googleapis.com/fcm/send
# Response in terminal: {..."success":1,"failure":0,...} If the app is open, then the following prints: > Received message data: { 'gcm.notification.data': '{"key1":"val1","key2":"val2"}', aps: { alert: { title: 'title' } }, ...}` If the app is closed, then a notification shows up. When it's tapped, the app opens and the following is printed: > Received message data: { 'gcm.notification.data': '{"key1":"val1","key2":"val2"}', aps: { alert: { title: 'title' } }, ...}
> launchData after timeout: { 'gcm.notification.data': '{"key1":"val1","key2":"val2"}', aps: { alert: { title: 'title' } }, ...} Note: It prints twice because of #60 So, as you can see, the notification data is indeed passed to the app, and can be accessed by I will leave this issue open, and please comment on the viability of this workaround as the functionality it relies on seems to be contradictory with the documentation. |
Thanks, we are aware of the issue, and we will post the update here after solving it. |
Hello @raphaelpreston. You are right that current behaviour is not as we have described in our documentation. However I believe that our documentation is wrong and needs to be updated. In I consider current behaviour correct and in line with native iOS behaviour. We will update our documentation. I will leave this issue open until our docs are updated. |
Oh okay, wonderful. Then my 'workaround' is how I should be implementing it in the first place. Thanks! |
Problem description
When I send a 'data' message, no notification is shown if the app isn't open. I took a look at #9, but I'm fairly certain I'm composing the message correctly.
Expected behavior
The documentation states that a 'data' message is "a notification that also delivers its data to the app", so, I would expect a notification to appear.
Environment
Code snippet
In-app Javascript:
Command Line Notification Composition:
If the app is open, then the following prints:
Received message data: {payload: 'custom data', title: 'Title', body: 'Body',...}
But if the app is closed, then nothing prints.
The text was updated successfully, but these errors were encountered: