开发者

Having issues in calling didReceiveRemoteNotification

I am using following code,

- (void)application:(UIApplication *)application didRecei开发者_运维问答veRemoteNotification:(NSDictionary *)userInfo {
  //code here to handle call
  //[[UIApplication sharedApplication] openURL:
  // [NSURL URLWithString:@"tel:1-408-555-5555"]];
  UIAlertView *alert1=[[UIAlertView alloc]initWithTitle:@"Teshjhjkhhjkhjkhjkhkjhkhkhkjhjkhjkkkjhjhhjhjkjt" message:@"Test" delegate:self cancelButtonTitle:@"ok" otherButtonTitles:nil];
  [alert1 show];
  [alert1 release];
}

but when application is open I can see the alert, but I want this alert when I press the view button in push message.


Try to implement in this format:

- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo {
    application.applicationIconBadgeNumber = 0;
    self.textView.text = [userInfo description];

    // We can determine whether an application is launched as a result of the user tapping the action
    // button or whether the notification was delivered to the already-running application by examining
    // the application state.

    if (application.applicationState == UIApplicationStateActive) 
    {
        // Nothing to do if applicationState is Inactive, the iOS already displayed an alert view.
        UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Did receive a Remote Notification"
                        message:[NSString stringWithFormat:@"The application received this remote notification while it was running:\n%@",
                                 [[userInfo objectForKey:@"aps"] objectForKey:@"alert"]]
                                  delegate:self
                                  cancelButtonTitle:@"OK"
                                  otherButtonTitles:nil];
        [alertView show];
        [alertView release];
    }
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜