Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

call "registerForRemoteNotificationTypes" in "applicationDidBecomeActive"

Is it bad practice to call registerForRemoteNotificationTypes in applicationDidBecomeActive? I was calling it in applicationDidFinishLoading, but with multitasking, the registration was not happening for days to weeks for some users.

I'd like to call the registration more often, but don't want to call it this often if it's bad practice.

like image 570
gurenski Avatar asked May 07 '11 21:05

gurenski


2 Answers

It is not bad practice.

In fact Apple documentation says this: Apple documentation

If your application has previously registered, calling registerForRemoteNotificationTypes: results in iOS passing the device token to the delegate immediately without incurring additional overhead.

like image 175
JugsteR Avatar answered Sep 27 '22 17:09

JugsteR


Device tokens can change.

Your app needs to reregister every time it is launched in iOS by calling the registerForRemoteNotificationTypes: method of UIApplication.

Based on Local and Push Notification Programming Guide

like image 30
Rafa de King Avatar answered Sep 27 '22 18:09

Rafa de King



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!