IOS -- 利用URL Scheme启动第三方应用

启动Instagram为例


Custom URL Scheme

Opening instagram://, followed by one of the following parameters, will open our app and perform a custom action. For example, for camera, you would direct users on the iPhone to the custom URL instagram://camera.

URL OPENS
app The Instagram app
camera The camera (or photo library on non-camera devices)
media?id=MEDIA_ID Media with this ID
user?username=USERNAME User with this username
location?id=LOCATION_ID Location feed for this location ID
tag?name=TAG Tag feed for this tag

The Objective-C call to open one of these URLs is as follows:

NSURL *instagramURL = [NSURL URLWithString:@"instagram://location?id=1"];
if ([[UIApplication sharedApplication] canOpenURL:instagramURL]) {
    [[UIApplication sharedApplication] openURL:instagramURL];
}

//开启浏览器打开某网页
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"https://instagram.com/"]];</span>


https://instagram.com/developer/mobile-sharing/iphone-hooks/#

郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。