gpt4 book ai didi

objective-c - UILocalNotification

转载 作者:搜寻专家 更新时间:2023-10-30 20:06:43 24 4
gpt4 key购买 nike

我有 UILocalNotification,它有两个按钮,一个是取消按钮,一个是查看按钮,当应用程序在后台时出现警报,我单击查看按钮,它在应用程序上打开,但我有一个方法调用,如果启动选项有一个不工作的 UILocalNotification 对象

 - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
//notifcation key
UILocalNotification *notifcation = [launchOptions objectForKey:UIApplicationLaunchOptionsLocalNotificationKey];


if (notifcation) {
NSLog(@"working");
}
}

最佳答案

当您的应用程序在后台时,didFinishLaunchingWithOptions 将不会在这种情况下调用使用 -

- (void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification

此处 userInfoUIApplicationLaunchOptionsLocalNotificationKey 相同。

关于objective-c - UILocalNotification,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9409064/

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