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

Replace deprecated local notification methods on iOS #1751

Merged

Conversation

nbolender
Copy link
Contributor

@nbolender nbolender commented Nov 21, 2020

As of push-notification-ios@v1.7.0, these iOS methods are deprecated:

  • presentLocalNotification
  • scheduleLocalNotification
  • cancelAllLocalNotifications
  • getScheduledLocalNotifications

This PR replaces those methods appropriately on iOS without changing the API of react-native-push-notification.

This fixes #1716

2 Breaking Changes

alertAction is deprecated as of iOS 10 and is not available in the new addNotificationRequest method.

It should also be noted that push-notification-ios@v1.4.1 had an unmentioned breaking change, requiring users to update their AppDelegate to use UNUserNotificationCenter and to stop using application:didReceiveLocalNotification: to receive notifications (this caused undefined notification details similar to #1488). I opened an issue over there to hopefully update their documentation.

These changes will require the same update, so it should be mentioned as a breaking change (though this has been true since 8/18/2020)

Depends on update to push-notification-ios

This depends on react-native-push-notification/ios#237 so I have this marked as draft for now.

jeremybarbet and others added 6 commits November 10, 2020 09:03
[other] Reduce npm package size
…Notification from react-native-push-notification-ios/push-notification-ios; alertAction has been deprecated as of iOS 10
…ests on iOS; swap getScheduledLocalNotifications for getPendingNotificationRequests on iOS
@Dallas62
Copy link
Collaborator

Hi @nbolender

Thanks for this PR !
This is really helpful !

@nbolender nbolender marked this pull request as ready for review November 22, 2020 20:25
@nbolender
Copy link
Contributor Author

This is now ready for review; Requires @react-native-community/push-notification-ios@^1.7.4

@Dallas62 Dallas62 changed the base branch from master to dev November 23, 2020 15:47
index.js Outdated Show resolved Hide resolved
index.js Outdated
soundName: soundName,
category: details.category,
userInfo: details.userInfo,
repeatInterval: details.repeatType,
Copy link
Collaborator

@Dallas62 Dallas62 Nov 24, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This parameter doesn't exist in the iOS library, it's repeats now but it's not the same thing 😞

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I changed it to repeats, and updated the documentation to state that 'day' is the only available option for repeatType on iOS. This would be another breaking change.

It is possible for the iOS library to specify other repeat intervals, but as explained here it is not as straightforward. For example, I could not set a fire date of 8 days from now and a weekly repeat; it would instead start firing 1 day from now.

@Dallas62
Copy link
Collaborator

Dallas62 commented Nov 24, 2020

Will wait for an answer for this issue, there is no way to cancel a notification request by the id:
react-native-push-notification/ios#239

Nice work, this is working great !
I will also look for other PR such as #612 which is now available on iOS.

@Dallas62
Copy link
Collaborator

Hi,
The version 1.8.0 is available with the missing method:
react-native-push-notification/ios#242

https://github.com/react-native-push-notification-ios/push-notification-ios#removependingnotificationrequests

Just an error in the exemple code to take care.

@nbolender
Copy link
Contributor Author

I've made this change, but also noted the documentation for cancelAllLocalNotifications. The docs say that this cancels all pending and delivered notifications. When using notification requests, it now cancels only pending notifications. There is another method to cancel delivered notifications; should we call this as well within cancelAllLocalNotifications?

I'm just not sure of the behavior on the Android side.

@Dallas62
Copy link
Collaborator

I will dig into it this week-end 😉

@Dallas62
Copy link
Collaborator

Dallas62 commented Dec 1, 2020

Thanks for allo these changes !
Awesome 🙌

Will look to another PR for Android and release a new version ASAP

@Dallas62 Dallas62 merged commit f2ffd97 into zo0r:dev Dec 1, 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

Successfully merging this pull request may close these issues.

cancelAllLocalNotifications has been deprecated from iOS 10.
4 participants