Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7050723
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T03:10:43+00:00 2026-05-28T03:10:43+00:00

I’m registering my iPhone application for Remote Notification. Here my scenario: User opens my

  • 0

I’m registering my iPhone application for Remote Notification.

Here my scenario:

  1. User opens my app and register for remote notification
  2. User turns notification off for my app
  3. User open my app
  4. User turns notification on for my app

My questions are:

  1. Is it possible to check if the user has disabled remote notification for my app inside my app’s code?
  2. If I request a new token without user turn off notification for my app, the retrieved token is different or is always the same?
  3. Should I request a new token every time I start my app?
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T03:10:44+00:00Added an answer on May 28, 2026 at 3:10 am

    So you want to know about UIRemoteNotifications? 🙂 Cool, because they’re not really as complex as people often make them out to be. Though, I am going to address your questions in reverse order. It flows better than way.

    Your questions:

    Should I request a new token every time I start my app?

    Sort of. With UIRemoteNotifications, you never really request a token, so much as request permission and receive a token. What you should do is implement application:didRegisterForRemoteNotificationsWithDeviceToken: in your app delegate. This method (along with its error-catching sibling application:didFailToRegisterForRemoteNotificationsWithError:) is the callback for registerForRemoteNotificationTypes:. It’s best practice to call registerForRemoteNotificationTypes: during application:didFinishLaunchingWithOptions:. (Don’t worry about all of the method names flying around. I’ll explain codewise shortly).

    If I request a new token without user turn off notification for my app, the retrieved token is different or is always the same?

    Maybe. The device token is subject to change for security reasons, but in general you shouldn’t need to be too concerned with it changing.

    Is it possible to check if the user has disabled remote notification for my app inside my app’s code?

    Why, yes it is. UIApplicationDelegate has a method called enabledRemoteNotificationTypes, which gets all of the remote notification types requested by you and enabled by your user. More on that shortly.

    Putting it all together:

    At the end of the day, you should end up with something like this:

    #define deviceTokenKey   @"devtok"
    #define remoteNotifTypes UIRemoteNotificationTypeBadge | \
                             UIRemoteNotificationTypeAlert
    
    - (void)applicationDidFinishLaunching:(NSNotification *)aNotification
    {
        //generic setup and whatnot
    
        [[UIApplication sharedApplication] registerForRemoteNotificationTypes: remoteNotifTypes];
        if (([[NSUserDefaults standardUserDefaults] stringForKey: deviceTokenKey]) &&
            ([[UIApplication sharedApplication] enabledRemoteNotificationTypes] != remoteNotifTypes))
        {
            //user has probably disabled push. react accordingly.
        }
    }
    
    - (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)token
    {    
        NSString *deviceToken = [token description];
        deviceToken = [deviceToken stringByReplacingOccurrencesOfString: @"<" withString: @""];
        deviceToken = [deviceToken stringByReplacingOccurrencesOfString: @">" withString: @""];
        deviceToken = [deviceToken stringByReplacingOccurrencesOfString: @" " withString: @""];
        
        if ([[NSUserDefaults standardUserDefaults] stringForKey: deviceTokenKey])
        {
            if (![[[NSUserDefaults standardUserDefaults] stringForKey: deviceTokenKey] isEqualToString: deviceToken])
            {
                [[NSUserDefaults standardUserDefaults] setObject: deviceToken forKey: deviceTokenKey];
                [[NSUserDefaults standardUserDefaults] synchronize];
        
                //user allowed push. react accordingly.
            }
        }
        else
        {
            [[NSUserDefaults standardUserDefaults] setObject: deviceToken forKey: deviceTokenKey];
            [[NSUserDefaults standardUserDefaults] synchronize];
        
            //user allowed push. react accordingly.
        }
    }
    
    - (void)application:(UIApplication *)application didFailToRegisterForRemoteNotificationsWithError:(NSError *)error
    {
        NSLog("application: %@ didFailToRegisterForRemoteNotificationsWithError: %@", application, [error localizedDescription]);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
link Im having trouble converting the html entites into html characters, (&# 8217;) i
We're building an app, our first using Rails 3, and we're having to build
I need to clean up various Word 'smart' characters in user input, including but
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I am writing an app with both english and french support. The app requests
I am using Paperclip to handle profile photo uploads in my app. They upload
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.