app之间交付后

一、Scheme

启动App主要用到是自定义Scheme.

Scheme就类似确定了这个App所在的位置,程序就能找到它。

添加Scheme:

app之间交付后_第1张图片

二、其他配置

iOS9之后需要在发起端添加白名单(即AppOne 唤起AppTwo在AppOne中添加)

app之间交付后_第2张图片

LSApplicationQueriesSchemes

三、代码

NSURL *appBUrl = [NSURL URLWithString:@"/*自定义的Scheme*/://"];if ([[UIApplication sharedApplication] canOpenURL:appBUrl]) {

// 3. 打开应用程序App-B

[[UIApplication sharedApplication] openURL:appBUrl

options:@{}//传空即可

completionHandler:^(BOOL success) {

NSLog(@"打开成功");

}];

} else {

NSLog(@"没有安装");

}/*iOS10之前用的是 [[UIApplication sharedApplication] openURL:appBUrl];

不过被弃用了

- (BOOL)canOpenURL:(NSURL *)url NS_AVAILABLE_IOS(3_0);

// Options are specified in the section below for openURL options. An empty options dictionary will result in the same这里也说的很清楚了字典传空就和以前的方法一样了。

// behavior as the older openURL call, aside from the fact that this is asynchronous and calls the completion handler rather

// than returning a result.

// The completion handler is called on the main queue.

- (void)openURL:(NSURL*)url options:(NSDictionary*)options completionHandler:(void (^ __nullable)(BOOL success))completion NS_AVAILABLE_IOS(10_0) NS_EXTENSION_UNAVAILABLE_IOS("");*/

四、具体调到某一个控制器

NSURL *appBUrl = [NSURL URLWithString:@"AppTwoScheme://starSecondContrller"];//添加后面的就可以区分了

//在AppTwo中 AppDelegate.m

- (BOOL)application:(UIApplication *)app openURL:(NSURL *)url options:(NSDictionary*)options

{

UINavigationController *rootNav = (UINavigationController *)self.window.rootViewController;NSLog(@"%@",url.absoluteString);//就能得到URLreturn YES;

}


转载 http://www.th7.cn/Program/IOS/201711/1277338.shtml

你可能感兴趣的:(app之间交付后)