ios URL Scheme

Add Row  URL types,然后按照上面的设置,URL identifier   自定义,item(todolist部分) 自定义;

上面显示item1实际为item0;

下面的为接收到外部调用的时候程序启动,响应方法,在safari输入:todolist://com.acme.ToDoList ,

- (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url {
    
    if ([[url scheme] isEqualToString:@"todolist"]) {
        NSLog(@"外部调用成功");
    }
    return YES;
}

下面的为自身调用safari浏览器,运行谷歌地图:

NSString* searchQuery = @"1 Infinite Loop, Cupertino, CA 95014";
searchQuery = [addressText stringByAddingPercentEscapesUsingEncoding: NSUTF8StringEncoding];
NSString* urlString = [NSString stringWithFormat:@"http://maps.google.com/maps?q=%@", searchQuery];
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:urlText]];


调用谷歌地图(Google Maps)

URL模式:http://maps.google.com/maps?q=<strong>${QUERY_STRING}</strong>
代码示例:

NSString* searchQuery = @"1 Infinite Loop, Cupertino, CA 95014";
searchQuery = [addressText stringByAddingPercentEscapesUsingEncoding: NSUTF8StringEncoding];
NSString* urlString = [NSString stringWithFormat:@"http://maps.google.com/maps?q=%@", searchQuery];
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:urlText]];

 

调用邮件客户端(Apple Mail)

URL模式:mailto://<strong>${EMAIL_ADDRESS}</strong>
代码示例:

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"mailto://[email protected]"]];

 

拨号(Phone Number)

URL模式:tel://<strong>${PHONE_NUMBER}</strong>
代码示例:

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"tel://10086"]];

 

调用短信(SMS)

URL模式:sms:<strong>${PHONENUMBER_OR_SHORTCODE}</strong>
代码示例:

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"sms:10086"]];

 

调用浏览器(Safari Browser)

代码示例:

NSURL *url = [NSURL URLWithString:@"http://eyecm.com"];
[[UIApplication sharedApplication] openURL:url];

 

调用应用商店(AppStore)

URL模式:http://phobos.apple.com/WebObjects/MZStore.woa/wa/viewSoftware?id=291586600&mt=8
代码示例:

NSURL *appStoreUrl = [NSURL URLWithString:@"http://phobos.apple.com/WebObjects/MZStore.woa/wa/viewSoftware?id=291586600&amp;mt=8"];
[[UIApplication sharedApplication] openURL:appStoreUrl];



猜你喜欢

转载自blog.csdn.net/reylen/article/details/8424150