5

I am working on an iPhone app with Apple Push Notification integration. I have some doubts on this.

  1. If the user clicked "Dont Allow" button in the APNS registration alert, will our code still receives the Device Token from APNS?

  2. I have tested that when the user switched off the notification in iPhone notification, still the app receives the Device Token from APNS? It is correct?

Can anyone please clarify these doubts?

Kimpoy
  • 1,974
  • 3
  • 21
  • 38
Gopinath
  • 5,392
  • 21
  • 64
  • 97

2 Answers2

9
  1. 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.

    Note 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.

  2. 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 this out.

Lord Zsolt
  • 6,492
  • 9
  • 46
  • 76
Kimpoy
  • 1,974
  • 3
  • 21
  • 38
  • Thanks for your answer. From your answer i understand that If user cancelled the Apple Push Notification Request, our app automatically receive the device token from the apns. Am i right? In both cases, allow and don't allow the app will receive the device token from APNS. Please tell this is right or wrong? Thanks. – Gopinath Jun 15 '12 at 07:12
  • That's right. "Don't Allow" will not stop the app from receiving the device token from Apple. – Kimpoy Jun 15 '12 at 07:25
  • Thanks a lot for your spot answer and helping hand. But, the user won't receive any notifications from APNS right? How we can find the user cancelled the Apple Push Notification service? Thanks in advance. – Gopinath Jun 15 '12 at 07:30
  • You can log the notifications. Actually, it's just for a particular user. That means if your app is installed to another user, that user will be able to receive notifications. – Kimpoy Jun 16 '12 at 21:06
  • Kimpoy is correct. I created sample applicatio with push notification. When my app launch first time , I clicked on "Don't allow" still `didRegisterForRemoteNotificationsWithDeviceToken` gets called I got the device token. After that I killed the app & started again still I got the device token. So as per sample app we will still get the device token even user selected "Don't allow". As Kimpoy mentioned "Don't Allow" refers to the action to be taken to any notification received by the app that is intended for the user. Thanks Kimpoy for your explanation. – iOSAppDev Oct 04 '13 at 04:57
  • @Kimpoy have u even tried to check this ? I have checked. this is wrong for me. When user will tap on "Don't allow" user will not get the devicetoken and didRegisterForRemoteNotificationsWithDeviceToken not called. – darshan Jul 08 '15 at 12:33
  • @Kimpoy Did I get the device token if user "Don't Allow" for IOS 8? – Radix Sep 01 '15 at 09:38
  • @Kimpoy your link is broken - also are you sure your answer is still up to date with iOS 10? – Mick Dec 13 '16 at 22:03
5

I have tested with Xcode 6.1, ios8.1.2. Currently the device token will be generated only in two cases

  1. Apple's default consent with "Ok" option
  2. After "Dont allow", manual change in Setting->Notifications->app->AllowNotification(On)

By declining first time with apple's consent, will not generate device token, till manually change the value in settings page.