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

  • Home
  • SEARCH
  • 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 8145385
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T13:38:52+00:00 2026-06-06T13:38:52+00:00

I am successfully able to receive push notification on my device which is of

  • 0

I am successfully able to receive push notification on my device which is of type alert.

1. Active State OR App is in foreground

didReceiveRemoteNotification method is getting called of the app. Here I can access received notification message.

2. In-Active State OR App is in background

Message of the Push notification is displayed in alert box with “View” & “Close” button.

a. On click of “view” button didReceiveRemoteNotification method is getting called. Again I can access received notification message.

b. On click of “Close” button, message will be disappeared. In this case I do not have any handler regarding the last received push notification.

3. App is not in background OR App is not running

Same as case 2.

4. iPhone is in sleep mode

Alert is displayed with message but no “View” or “Close” button.

a. On UI it will display “Slide to View”. If user interacts with phone it will open the app. I can access received notification message.

b. If user do not interacts and allow phone to go in sleep mode or manually put phone in sleep mode then for the next time iOS displays “Slide to unlock” message. Here again I don’t have any handler for the last push notification.

How can I access the last push notification of case 2.b and 4.b, Is there any method which best called which I am missing to implement.

EDIT 1: Below is my code of appDelegate

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];
    // Override point for customization after application launch.
    self.viewController = [[[Test1ViewController alloc] initWithNibName:@"Test1ViewController" bundle:nil] autorelease];
    self.window.rootViewController = self.viewController;
    [self.window makeKeyAndVisible];

    // For PUSH NOTIFICATION
    [[UIApplication sharedApplication] registerForRemoteNotificationTypes:
     (UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeSound | UIRemoteNotificationTypeAlert)];

    if (launchOptions != nil)
    {
        NSDictionary* dictionary = [launchOptions objectForKey:UIApplicationLaunchOptionsRemoteNotificationKey];
        if (dictionary != nil)
        {
            NSLog(@"Launched from push notification: %@", dictionary);
        }
    }


    return YES;
}

- (void)application:(UIApplication*)application didReceiveRemoteNotification:(NSDictionary*)userInfo
{
    NSLog(@"Received notification: %@", userInfo);
    // Received Notification at here ....
    // Now based on response further to do ...
}

- (void)application:(UIApplication*)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData*)deviceToken
{
    NSLog(@"My token is: %@", deviceToken);
}

- (void)application:(UIApplication*)application didFailToRegisterForRemoteNotificationsWithError:(NSError*)error
{
    NSLog(@"Failed to get token, error: %@", error);
}

Thanks,
J61

  • 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-06-06T13:38:54+00:00Added an answer on June 6, 2026 at 1:38 pm

    The OS will take care of badges. But if the user dismisses your push notification, your app could take a look at messages on your server and handle it the appropriate way if it has missed any notifications the user dismissed.

    Taken from here, this is the way you can handle the notifications:

    - (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo {
       // get state
       UIApplicationState state = [application applicationState];
       if (state == UIApplicationStateActive) {
          // App is in foreground
       } else {
          // App is suspended
       }
    
       application.applicationIconBadgeNumber = 0;
    }
    

    Edit:
    If you want to auto-increment your badge number, you need to keep track of the count for yourself. You could do this on your server. If your push message doesn’t contain a badge count, iOS will remove it from your application.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hi I'm able to successfully integrate iphone app with facebook framework. But I need
I am using this tutorial to learn push notification. <?php // Put your device
I have been able to successfully create push notifications and I have also received
I am successfully able to authenticate Facebook and Google accounts using my Oauth2 servlets.
Hi I am working on TCP/IP in Windows Azure and am successfully able to
I've created my own WCF service and I've successfully been able to talk to
I am able to successfully call a function with ctypes in Python. I now
I am able to successfully execute this on windows: builder = new ProcessBuilder(cmd.exe, /c,
I've been able to successfully play with the touchstart, touchmove, and touchend events on
Using the following code, I'm able to successfully open a raw disk on my

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.