Skip to content

Commit

Permalink
Update receiving-notifications.md
Browse files Browse the repository at this point in the history
For the current latest version (5.x) of RN Firebase, calling `requestPermission` also calls the `registerForRemoteNotifications` method. This is required for the fcm token retrieved to be associated to a valid APNS token, and for push notifications to be delivered correctly to the device. (invertase/react-native-firebase#1203 (comment))

I have been debugging an issue with push notifications and consistently calling the `requestPermission` method even when the user already granted permissions was the only fix.
There is also a `firebase.messaging().ios.registerForRemoteNotifications()` method available, but I found that when I called it from the JS thread, a warning popped up in Xcode saying that this method (the underlying `[RCTSharedApplication() registerForRemoteNotifications]` call) should only be made from the main thread.

This does not prompt the user on iOS after the first time the user responds to the dialog, so the user experience is not hurt by running this code over and over.
  • Loading branch information
david-arteaga authored and mikehardy committed Oct 19, 2019
1 parent 18a771a commit 12f6920
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions docs/notifications/receiving-notifications.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Receiving Notifications

You must call `firebase.messaging().hasPermission()` even if the user has already granted permissions for notifications in order to register the device to receive push notifications.

## 1) Check permissions

Before you are able to send and receive Notifications, you need to ensure that the user has granted the correct permissions:
Expand Down

2 comments on commit 12f6920

@TimMun
Copy link

@TimMun TimMun commented on 12f6920 Oct 20, 2019

Choose a reason for hiding this comment

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

Am I missing something here? The commit message says to call requestPermission but the readme now says to call hasPermission()

@mikehardy
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please sign in to comment.