简体   繁体   English

在iOS应用中使用自定义网址方案打开应用

[英]Opening app with custom url scheme in ios app

I have two url scheme, say, openView1:// and openView2:// . 我有两个URL方案,例如,openView1://和openView2://。 Now, when i click to openView1://, i want to pen view1. 现在,当我单击打开openView1://时,我想输入view1。 When i click to openView2://, i want to pen view2. 当我单击以打开openView2://时,我想使用view2。

I did like following at appDelegate.m 我确实喜欢在appDelegate.m上关注

 #import "Welcome_ResetPassword.h"
 @implementation AppDelegate

 - (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:     (NSString *)sourceApplication annotation:(id)annotation { 
 isopenView1= FALSE; //    isopenView1 is global varaible define in appDelegate.h 
 isopenView2= FALSE; // isopenView1 is global varaible define in appDelegate.h 
 if ([[url scheme] isEqualToString:@"openView1"]) {
    isopenView1= TRUE;
    return isopenView1; 
}
else{
    isopenView2= TRUE;
    return isopenView2; 
}

} }

now, 现在,

 - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
 {
 if ( isopenView1) {
    //show view1 as app start 
 }else{
   //show view2 as app start 
 }
}

This is not working. 这是行不通的。 How can I achieve it? 我该如何实现?

我相信自iOS 5.0起,网址格式不区分大小写(小写)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM