react-native-push-notification / ios

React Native Push Notification API for iOS.
MIT License
741 stars 285 forks source link

Fix issue #120 Remote notification listener does not occur. (iOS) #194

Closed Axenu closed 1 year ago

Axenu commented 3 years ago

This solution makes sure that the delegate is set after the user has permission, without asking for permissions when the app is first started. The users unfortunately needs to edit their appDelegate.m file for this new change to work.

It might not be the prettiest solution, but it is simple and it works.

vonovak commented 3 years ago

hello @Axenu

This solution makes sure that the delegate is set after the user has permission

why is this important? How does it fix the problem?

I do not think this will work for responding to notification actions - when https://developer.apple.com/documentation/usernotifications/unusernotificationcenterdelegate/1649501-usernotificationcenter?language=objc is implemented, the delegate needs to be set right upon app start so that this method can be called ("If you do not implement this method, your app never responds to custom actions."). With this PR, the delegate will be set too late to handle notification action responses.

Axenu commented 3 years ago

Hi!

The reason why I believe that is important is because of the solution suggested in issues #120. Their solution requests notification permissions immediately when the application starts, and then sets the delegate. That is why my pull request only sets the delegate when it is known that the app has notification permissions and delays setting the delegate until the app has requested permissions.

The function userNotificationCenter:didReceiveNotificationResponse:withCompletionHandler: would only be called if the app already has permissions and in that case the code in AppDelegate.m would set the delegate immediately.