gpt4 book ai didi

ios - 在调用 didReceiveRemoteNotification 时遇到问题

转载 作者:行者123 更新时间:2023-11-28 20:47:17 25 4
gpt4 key购买 nike

我正在使用以下代码,

- (void)application:(UIApplication *)application didReceiveRemoteNotification:(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];
}

但是当应用程序打开时我可以看到警报,但是当我在推送消息中按下查看按钮时我想要这个警报。

最佳答案

尝试以这种格式实现:

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

关于ios - 在调用 didReceiveRemoteNotification 时遇到问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4781313/

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