简体   繁体   中英

Push notifications ios

If my app is closed , and the iphone receives a push notification for that app, will it receive it and open the app?

Thanks

No if the message is received it will not open the app.

You app wil get launched if the user selects to view the notification. Thus if the user does not react to the notifications your app will not be launched.

If your app is already running and in the foreground than the app delegate will receive the notification directly.

Yes it will launch if "View" button is clicked and application will call the delegate method. If clicked on "close" button it will discard the notification.

 - (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo {  

    }

For more info http://www.raywenderlich.com/3443/apple-push-notification-services-tutorial-part-12 and http://mobiforge.com/developing/story/programming-apple-push-notification-services

Yes, when you receive push - it appears as an alert on the screen on appears in the top (you can choose a way in Settings) as a message which will disappear after some seconds. If you click on push notification - it'll open App. But when you receive push, App will not be opened automatically with a receiving a push. Only after user clicks on push.

when the notification aries that time you open the application that for you can use the following code.

- (void)applicationDidEnterBackground:(UIApplication *)application
{
  UILocalNotification *localNotification = [[[UILocalNotification alloc] init] autorelease];

  // Current date
  NSDate *date = [NSDate date]; 

  // Add one second to the current time
  NSDate *dateToFire = [date dateByAddingTimeInterval:1];

  // Set the fire date/time
  [localNotification setFireDate:dateToFire];
  [localNotification setTimeZone:[NSTimeZone defaultTimeZone]];    

  // Setup alert notification
  [localNotification setAlertBody:@"Tap to return to TestApp" ];
  [localNotification setAlertAction:@"Open TestApp"];
  [localNotification setHasAction:YES];

  [[UIApplication sharedApplication] scheduleLocalNotification:localNotification];
}

And more information regarding this thing you can use Refer the Reference.

May this code helping to you.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM