0

我有一个应用程序,我在其中添加推送通知。我将推送通知显示为 aletview。有两个按钮视图和取消。当用户单击视图按钮时,我需要转到特定的视图控制器。任何人都可以帮忙我实现了这一点?这就是我处理通知的方式。

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

    NSLog(@"########################################didReceiveRemoteNotification****************************###################### %@",userInfo);
    //check application in forground or background
    if(application.applicationState == UIApplicationStateActive)
    {
        //NSLog(@"FOreGround");
        //////NSLog(@"and Showing %@",userInfo)
    }
    else {

        NSDictionary *curDict= [userInfo objectForKey:@"aps"];
        UIAlertView *connectionAlert = [[UIAlertView alloc] initWithTitle:@"app" message:[NSString stringWithFormat:@"%@",[curDict objectForKey:@"alert"]] delegate:self cancelButtonTitle:@"View" otherButtonTitles:@"Cancel",nil];
        [connectionAlert show];
        [connectionAlert release];
        [UIApplication sharedApplication].applicationIconBadgeNumber =[[curDict objectForKey:@"badge"] intValue];



    }


}

`

4

1 回答 1

1

您只需要实现UIAlertViewDelegate并调用委托方法

- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
  switch(buttonIndex) {
    case 0: // do something
      break;
    case 1: // do something else
      break;
  }
}
于 2012-07-18T14:23:44.717 回答