我有一个应用程序,我在其中添加推送通知。我将推送通知显示为aletview.with两个按钮视图和cancell.i需要当用户点击视图按钮我需要去特定的viewcontroller。任何人都可以帮我实现这个目标吗?这就是我如何处理通知。
- (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];
}
}
`
答案 0 :(得分:1)
您只需要实现UIAlertViewDelegate
并调用委托方法
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
switch(buttonIndex) {
case 0: // do something
break;
case 1: // do something else
break;
}
}