ios 开发中 注册并使用个性化URL Schema

- (BOOL)openURL:(NSURL *)url

 

 

An object representing a URL (Universal Resource Locator). UIKit supports the http:, https:, tel:, and mailto: schemes.

 

在你的应用中,调用api可以直接打开这些作为前缀的一些URL(注意:URL的本意<统一资源定位>,不仅仅是网址)

而且这些Schema都是Apple-registered ,也就是苹果内置注册的Schema,比方你在你的应用程序中OpenURL  http://www.baidu.com

那么就会自动调用safari浏览器打开这个网址,同样使用 [email protected] 会打开邮件程序发送邮件。。。。这些都是苹果已经做好的,

好了,那么这个Schema是不是可以个性化呢,也就是custom呢,答案是肯定的,比方:

制作了a应用,想在别人<别的应用程序>openurl:@“myapp://”时自动打开你的a应用,那么这个是可以实现的,也就是注册自己的Schema给系统,系统到时候接收到别人openurl你的schema时就会调用你的应用。

下面详细图文说明如何实现




 

Now that the URL has been registered. Anyone can start the application by opening a URL using your scheme.

 

 

Here are a few examples …

myapp://

 

myapp://some/path/here

 

myapp://?foo=1&amp;bar=2

 

myapp://some/path/here?foo=1&amp;bar=2

The iPhone SDK, when launching the application in response to any of the URLs above, will send a message to the UIApplicationDelegate.

 

转自:http://hi.baidu.com/chenfalei/item/ba8cd03e7c2591f2e7bb7ac6

猜你喜欢

转载自duchengjiu.iteye.com/blog/1972479