gpt4 book ai didi

ios - 当 iOS 应用程序在前台时处理小部件单击操作

转载 作者:行者123 更新时间:2023-12-01 19:44:11 25 4
gpt4 key购买 nike

单击小部件时,如果应用程序未运行,我可以使用以下方法进行处理-

(BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url 

但是如果app在后台怎么处理呢?

最佳答案

handleOpenURL无论 App 是否处于后台模式都会被调用。

Official document:
If a URL arrives while your app is suspended or running in the background, the system moves your app to the foreground prior to calling this method.



以及影响调用的因素:

This method is not called if the delegate returns NO from both the application:willFinishLaunchingWithOptions: and application:didFinishLaunchingWithOptions: methods. (If only one of the two methods is implemented, its return value determines whether this method is called.) If your app implements the applicationDidFinishLaunching: method instead of application:didFinishLaunchingWithOptions:, this method is called to open the specified URL after the app has been initialized.



从iOS9.0开始最好使用以下方法:
- (BOOL)application:(UIApplication *)app openURL:(NSURL *)url options:(NSDictionary<UIApplicationOpenURLOptionsKey, id> *)options NS_AVAILABLE_IOS(9_0); 

关于ios - 当 iOS 应用程序在前台时处理小部件单击操作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50461123/

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