Вопрос

I am implement ios APNS , I write the code in AppDelegate.m, and pass the device token to my view controller( Use NSUserDefaults) .

Then there are a button in view controller, when user click the button , it will send device token to my server.

But the question is coming. If the user is not connect Internet, the button action will detect the device token is null or not.

When the device token is null, the app have to detected network and request device token.

But the device token is wrote in AppDelegate.m, how to implement registered device token in the class alone?

Thank you very much.

Это было полезно?

Решение 3

I found the resolve.

Setting the code in applicationDidBecomeActive.

Другие советы

I think every time your app launch , you should register to get the device token and send to your server, if network is disconnected, you should do above when the network is access. (if no network, it is no use for you to get the token, because you can not send it to your sever, by the way , system will store the device token and you may get the device token immediately after you register)

Device Token will not get generate when internet is offline. To generate device token device must required internet connection.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top