gpt4 book ai didi

iphone - 如何向推送通知警报 View 添加操作?

转载 作者:行者123 更新时间:2023-11-29 04:32:25 25 4
gpt4 key购买 nike

我有一个应用程序,在其中添加推送通知。我将推送通知显示为 aletview。有两个按钮 View 和取消。当用户单击 View 按钮时,我需要转到特定的 View Controller 。任何人都可以帮助我实现这一目标吗?这就是我通过通知完成的。`

- (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];



}


}

`

最佳答案

您只需实现UIAlertViewDelegate并调用委托(delegate)方法

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

关于iphone - 如何向推送通知警报 View 添加操作?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11543537/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com