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

Add support for notification actions on iOS #773

Merged
merged 5 commits into from
Feb 5, 2018

Conversation

krystofcelba
Copy link
Contributor

@krystofcelba krystofcelba commented Feb 5, 2018

This PR adds support for notification actions on iOS as documented here by Apple.

NotificationActionType.Default NotificationActionType.TextInput
2016-12-02_07-58-59 2016-12-02_07-59-20

resolves #325

@krystofcelba krystofcelba force-pushed the ios-notification-actions branch from 64d5b9b to acf7ca1 Compare February 5, 2018 03:58
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.
@Compulsor-zz
Copy link

This actually is a good fix for the push notifications for Apple devices. When can we expect this to merge?

@evollu
Copy link
Owner

evollu commented Feb 5, 2018

awesome! can you add some example on how to send a notification through FCM and through local notification?
an update in the example project will be nice as well

@krystofcelba
Copy link
Contributor Author

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.

@evollu evollu merged commit 66da4eb into evollu:master Feb 5, 2018
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
if (data[@"_actionIdentifier"] && ![data[@"_actionIdentifier"] isEqualToString:UNNotificationDefaultActionIdentifier]) {
initialNotificationActionResponse = userInfo;
Copy link
Owner

@evollu evollu Feb 12, 2018

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

Copy link
Contributor Author

@krystofcelba krystofcelba Feb 13, 2018

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).

Copy link
Owner

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

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

Successfully merging this pull request may close these issues.

[Question] Action in notifications
3 participants