When iOS application is opened from some URL AppDelegates's
methods are called in such a sequence:
当从某个URL appdelegate的方法中打开iOS应用程序时,按以下顺序调用:
1. - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
2. - (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url
How to know in didFinishLaunchingWithOptions
method if application was opened from URL or not. May be there are some launching options which I miss?
如何在didFinishLaunchingWithOptions方法中知道应用程序是否从URL打开。可能有一些我错过的发布选项吗?
3 个解决方案
#1
7
You can inspect launchOptions
passed to - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
.
您可以检查传递给- (BOOL)应用程序:(UIApplication *)应用程序didFinishLaunchingWithOptions:(NSDictionary *)launchOptions。
Look for section Launch Options Keys
in reference docs, specifically UIApplicationLaunchOptionsURLKey
在参考文档中查找区域启动选项键,特别是UIApplicationLaunchOptionsURLKey。
#2
6
If your app has been launch from a URL You will find a
如果你的应用是从一个URL启动的,你会找到一个
UIApplicationLaunchOptionsURLKey
in the launchOptions
Dictionary of - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
在- (BOOL)应用程序的launchOptions字典中:(UIApplication *)应用程序didFinishLaunchingWithOptions:(NSDictionary *)launchOptions。
On a related note the handleOpenURL:
method is deprecated, you should use:
有关handleOpenURL:方法不赞成,您应该使用:
-(BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation
#3
0
First, you should implement application:didFinishLaunchingWithOptions:
Check the URL. It should return YES if you can open it or NO if you can't.
首先,您应该实现application:didFinishLaunchingWithOptions:检查URL。如果你能打开它,它应该返回YES;如果不能,它应该返回NO。
And then implement application:handleOpenURL:
Open the URL. It should return YES if successful or NO.
然后实现application:handleOpenURL:打开URL。如果成功或不成功,它应该返回YES。
#1
7
You can inspect launchOptions
passed to - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
.
您可以检查传递给- (BOOL)应用程序:(UIApplication *)应用程序didFinishLaunchingWithOptions:(NSDictionary *)launchOptions。
Look for section Launch Options Keys
in reference docs, specifically UIApplicationLaunchOptionsURLKey
在参考文档中查找区域启动选项键,特别是UIApplicationLaunchOptionsURLKey。
#2
6
If your app has been launch from a URL You will find a
如果你的应用是从一个URL启动的,你会找到一个
UIApplicationLaunchOptionsURLKey
in the launchOptions
Dictionary of - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
在- (BOOL)应用程序的launchOptions字典中:(UIApplication *)应用程序didFinishLaunchingWithOptions:(NSDictionary *)launchOptions。
On a related note the handleOpenURL:
method is deprecated, you should use:
有关handleOpenURL:方法不赞成,您应该使用:
-(BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation
#3
0
First, you should implement application:didFinishLaunchingWithOptions:
Check the URL. It should return YES if you can open it or NO if you can't.
首先,您应该实现application:didFinishLaunchingWithOptions:检查URL。如果你能打开它,它应该返回YES;如果不能,它应该返回NO。
And then implement application:handleOpenURL:
Open the URL. It should return YES if successful or NO.
然后实现application:handleOpenURL:打开URL。如果成功或不成功,它应该返回YES。