-
Notifications
You must be signed in to change notification settings - Fork 678
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
Add support for notification actions on iOS #773
Conversation
64d5b9b
to
acf7ca1
Compare
We have to save initial notification action response in case there isn't registered any FCMNotificationReceived event handler yet. For example when the app is killed by a user so JS has to be initialized first. The saved action response will be sent to JS after first FCMNotificationReceived event handler registered.
This actually is a good fix for the push notifications for Apple devices. When can we expect this to merge? |
awesome! can you add some example on how to send a notification through FCM and through local notification? |
I have added simple example to readme. It's very simple as it's only need to set the same category identifier as that we have defined in app before. |
static dispatch_once_t onceToken; | ||
dispatch_once(&onceToken, ^{ | ||
if (data[@"_actionIdentifier"] && ![data[@"_actionIdentifier"] isEqualToString:UNNotificationDefaultActionIdentifier]) { | ||
initialNotificationActionResponse = userInfo; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why do you need to assign initialNotificationActionResponse
here and use it in line 318? can't you just call postNotificationName
?
@krystofcelba
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's because if the app is killed and the user taps an action, the didReceiveRemoteNotification:fetchCompletionHandler:
method gets called right after the app starts so the JS context isn't running and handler for that isn't registered. So the notification is kept here and dispatched again after the appropriate handler is registered in addListener
. I tested it, and it is very robust this way. It works even if the action isn't marked as foreground so the app only have some limited amount of time to do something in the background (30sec I think).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks.
I figured that yesterday.
I added #792 to handle this issue for all types of notification callbacks
should be compatible with you changes
This PR adds support for notification actions on iOS as documented here by Apple.
resolves #325