[iOS] how to access the APNs Token
See original GitHub issueQuestion
Is there any method I can call to access the APNs token?
While testing on the simulator, requesting permissions after a hard device reset, onRegister
does not appear to be called, and invoking requestPermissions
only returns an object containing permissions. My question is:
What method(s), if any, can I call on a simulator or device to reliably return the APNs token once it exists, and what form do those return values take? And is there any way to access the token outside of onRegister
?
e.g. something like requestPermissions().then(results => console.log('token: ', results.token))
Thanks!
Issue Analytics
- State:
- Created 3 years ago
- Reactions:3
- Comments:14
Top Results From Across the Web
Registering Your App with APNs - Apple Developer
Register your app with APNs and receive a globally unique device token, which is effectively the address of your app on the current...
Read more >Get device token for push notification - ios - Stack Overflow
To get Token Device you can do by some steps: 1) Enable APNS (Apple Push Notification Service) for both Developer Certification and ...
Read more >how to get iOS Device token(APNs Token)? - OutSystems
In your implementation of this method, send the contents of the deviceToken parameter to the server that you use to generate remote ...
Read more >How to start using APNS Token-Based Authentication.
Go to Certificates, Identifiers & Profiles . · Click on Keys from the Menu on the left. · Add a new key -...
Read more >Token-based authentication for iOS applications with ... - AWS
Any iOS application that is capable of receiving push notifications must register with APNs. Upon successful registration, APNs returns a device ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
+1 How do we get the token sometime after
onRegister
gets triggered?What if a user denies the system prompt and then later enables push notifications in settings? How do we get the token then? Or what if registering the token with the push notification provider fails? There must be a
getToken
method we can call at any point, right?The Apple documentation recommends we get the token each time as opposed to storing it:
Thanks for the answers, everyone.
@vinagrito-getpocketful my understanding and the testing I’ve done so far lead me to believe that
onRegister
is only invoked after allowing permissions from the system prompt, or allowing them from settings for the first time if the prompt was denied. We are currently callingPushNotificaion.configure
on every app open, which does allow us to define a new, arbitrary callback to pass to theonRegister
method, but it doesn’t forceonRegister
to fire and give access to the token.So that answers @santiagogarza’s first question, however we’ve just tested and found that if the initial
onRegister
method fails due to network issues, it will never fire again. Maybe there’s a way to solve this withonRegistrationError
or some other method but I don’t know when that method will fire so I’ll have to do more testing. As of now it seems there is no way to access the push token if the initial call toonRegister
fails.