Skip to content
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

iOS foreground notification always calls onMessageReceived #48

Closed
yoldar opened this issue Jul 18, 2019 · 4 comments
Closed

iOS foreground notification always calls onMessageReceived #48

yoldar opened this issue Jul 18, 2019 · 4 comments

Comments

@yoldar
Copy link

yoldar commented Jul 18, 2019

Hi! First of all thank you man for that great plugin! Take a donate for a cup of beer :)

Is that possible for foreground notification on iOS behave the same as on Android? I mean when app on iOS is foreground and push comes with notification_foreground=true just to show notification and if user taps it only then call onMessageReceived?

Because now when iOS is foreground there is no notification appears and onMessageReceived called. But it would be great to call onMessageReceived only when user taps notification in background(that works) and foreground modes.

@dpa99c
Copy link
Owner

dpa99c commented Jul 18, 2019

I think it best that a notification message is always passed to onMessageReceived(), regardless if notification_foreground: true to ensure that, if the notification message contains an additional data payload, the app always receives it. So I think I will change Android to behave the same as iOS - on receiving a notification message in the foreground, always pass the message to onMessageReceived().

However, I see that this could end up with onMessageReceived() being called twice if notification_foreground: true: once when the message arrives and once again if the user taps the foreground notification dialog.
So I propose that the value of tap is used to distinguish this and leave it up to the app logic to determine how to handle to the calls to onMessageReceived():

  • notification message arrives while app is in foreground: tap is not set since user did not tap notification message
  • notification message arrives while app is in background and user taps notification: tap: "background"
  • notification message arrives while app is in foreground with notification_foreground: true and user taps foreground notification: tap: "foreground".

This would be implemented on both platforms to allow managing all scenarios coherently cross-platform.

@dpa99c dpa99c added the TODO Something needs doing label Jul 18, 2019
@dpa99c dpa99c closed this as completed in 2a141c4 Jul 18, 2019
@dpa99c
Copy link
Owner

dpa99c commented Jul 18, 2019

This has been rationalised in v6.0.0 which has been published to npm

@yoldar
Copy link
Author

yoldar commented Jul 20, 2019

This has been rationalised in v6.0.0 which has been published to npm

@dpa99c I have updated plugin and unfortunately on iOS on foreground mode there is no system push notification. Only onMessageReceived method called.

@dpa99c
Copy link
Owner

dpa99c commented Jul 20, 2019

See this screencapture of a notification message being received in the foreground and displayed as a system notification on iOS.

This is using the example project app to sent the notification.json message.

Please clone and build the example project, customise as necessary (i.e. change the app package ID to one under your control) and send the same message to confirm.

tommy-hartz pushed a commit to tommy-hartz/cordova-plugin-firebasex that referenced this issue Nov 22, 2019
@dpa99c dpa99c removed the TODO Something needs doing label Jun 26, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants