【问题标题】:How to add action to pushnotification alertview?如何向推送通知警报视图添加操作?
【发布时间】:2012-07-18 14:20:39
【问题描述】:

我有一个应用程序,我在其中添加推送通知。我将推送通知显示为 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];



    }


}

`

【问题讨论】:

    标签: iphone ios ipad push-notification


    【解决方案1】:

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

    - (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
    {
      switch(buttonIndex) {
        case 0: // do something
          break;
        case 1: // do something else
          break;
      }
    }
    

    【讨论】:

    • 我是在 appdelegate 中做的。是否可以在那里添加?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-09-05
    • 2011-12-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多