Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to get the device token even if Push Notification is not enabled?

I need to get the device token because I will use it for autologin. However, if the user did not allow Push Notifications from my App in his/her device, I will not be able to get the device token. I want to know if it's possible to get and store the user's device token even if he/she did not enable APN. Thanks.

like image 786
caribbean Avatar asked Aug 28 '13 02:08

caribbean


People also ask

How do I get a device push token?

Use the getToken method to obtain a push token only after you enable Push Kit in AppGallery Connect. Declare both the getToken and onNewToken methods in the code to ensure that the push token can be returned.

How can we get device token for Android for push notification?

To receive the Device Token (and updates to the token value) and push notifications, you must create a custom class that extends FirebaseMessagingService . The onNewToken callback fires whenever a new token is generated.


1 Answers

Enabling/Disabling the push notification is just a setting. It doesn't stop the device from receiving the access token from APPLE

Check @Kimpoy's answer including the comments.

In my understanding on APNS, it doesn't depend on the user's action (as you mentioned that if when the user clicks on Don't Allow button) for your iOS to receive the Device Token.

If you included in your app:

 - (void)application:didRegisterForRemoteNotificationsWithDeviceToken

    

This means that your iOS-based app is sending a request for Push Notification registration. In return, Apple sends the Device Token to the iOS; then the iOS sends the token to the app and then the app sends it to their service provider.

Not that when the user is asked "Don't Allow" doesn't mean that you're not going to receive the device token. Don't Allow refers to the action to be taken to any notification received by the app that is intended for the user. Say, location. This is a whole different thing. This means that the user doesn't allow the app to use his/her location.

Yes, it still receives the Device Token as what I have discussed in my answer to your question in #1. This is only a setting for your app, which means that you won't be receiving any visible notification (badge, message or a sound) whenever there are updates about any information in relevance to your application. It's like setting your Facebook account to only receive notifications when your friends sends you a private message. Other than that, you won't be notified at all.

The process of enabling APNS is:

  1. Request for certificate Authority
  2. Create app id
  3. Configuring AppId for Push Notifications
  4. Create provisioning profile
  5. Provisioning a device
  6. Enabling the profile in Xcode
  7. Creating push notification provider.

For more understanding on APNS, check out this.

You still can get the device token even if the user disables it.

like image 125
Master Stroke Avatar answered Sep 23 '22 18:09

Master Stroke