gpt4 book ai didi

ios - 在应用程序处于后台时获取本地通知

转载 作者:塔克拉玛干 更新时间:2023-11-02 07:59:59 26 4
gpt4 key购买 nike

当应用程序在后台时,不会调用 didReceiveLocalNotification。

所以我尝试从 didFinishLaunchingWithOptions 获取通知

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

但我的应用启用了后台模式(使用外部附件通信)单击通知时,不会调用 didFinishLaunchingWithOptions。

还有其他方法可以获取通知吗?

最佳答案

通过检查Apple's document关于通知,它说:

iOS Note: In iOS, you can determine whether an application is launchedas a result of the user tapping the action button or whether thenotification was delivered to the already-running application byexamining the application state. In the delegate’s implementation ofthe application:didReceiveRemoteNotification: orapplication:didReceiveLocalNotification: method, get the value of theapplicationState property and evaluate it. If the value isUIApplicationStateInactive, the user tapped the action button; if thevalue is UIApplicationStateActive, the application was frontmost whenit received the notification.

据我所知,当你的应用程序处于后台运行状态,并且有本地通知时,你不会收到任何方法调用,通知将显示给用户,但如果用户点击通知并因此响应您的应用程序,您将收到 -didReceiveLocalNotification: 电话。

关于ios - 在应用程序处于后台时获取本地通知,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25356064/

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