原文:http://blog.csdn.net/mangosnow/article/details/7764820
在自己應用中打開其他應用,如yahoo messenger, msn messenger, qq,facebook。
一般apple app運行在沙河里面,不允許相互調用,但是通過rul scheme 可以實現這個功能。
1. 設置url scheme截圖如下
xcode4.2 沒有URL types 這個選項,你要在Main nib file base name 下面個那個選項里面找到URL types。
這里面的todolist就是url scheme。
如果你在模擬器safari 里面打這些字符 todolist:// 只要你運行過一次你的app,就能直接打開了。
2. 常用的url scheme 查詢網站是這個:http://handleopenurl.com/ 里面可以查到qq的接口。
Below is a list of some common non-http URI schemes:
Application | URI Scheme or Protocol | Query Strings |
---|---|---|
Default e-mail application | mailto:<email>?query |
Subject |
CC |
||
BCC |
||
Body |
||
Default phone application | tel:<number> |
N/A |
Default SMS application | sms:<number> |
N/A |
Chat Room client | irc://<url>:query |
port |
channel |
||
password |
||
Syndication feed reader | feed:<url> |
N/A |
Apple FaceTime | facetime:<number> |
N/A |
Skype client | skype:<username|number>?query |
add |
call |
||
chat |
||
sendfile |
||
userinfo |
||
Google Talk client | gtalk:query?<email> |
chat |
call |
||
Windows Live Messenger client | msnim:query?<email> |
add |
chat
|
||
voice
|
||
video
|
||
Yahoo! Messenger client | ymsgr:query?<email|number> |
sendim
|
addfriend
|
||
sendfile
|
||
call
|
||
callPhone
|
||
chat
|
||
im
|
||
customstatus
|
||
getimv
|
||
AOL Instant Messenger client | aim:query?<username> |
goim
|
goaway
|
||
addbuddy |
- /**
- * Added by Bruce Yang on 2012.08.31.09.58~
- * 從一個 app 中跳轉到另外一個 app 中(也可以是網頁地址,會在 safari 中打開)~
- * 要修改 info.plist 中 URL types 鍵所對應的值方才能夠從其他應用中跳轉進來~
- */
- -(void) openAnotherAppInThisApp {
- // NSString* strIdentifier = @"http://www.baidu.com";
- NSString* strIdentifier = @"companyname://com.companyname.bundleidentifier";
- BOOL isExsit = [[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:strIdentifier]];
- if(isExsit) {
- NSLog(@"App %@ installed", strIdentifier);
- [[UIApplication sharedApplication] openURL:[NSURL URLWithString:strIdentifier]];
- }
- }
- /**
- * Added by Bruce Yang on 2012.08.31.09.60~
- * 跳轉到 appStore,並且定位在某個 app 的評論區~
- */
- -(void) jumpToCommentArea {
- NSString* strLoc = @"itms-apps://ax.itunes.apple.com/WebObjects/MZStore.woa/wa/viewContentsUserReviews?type=Purple+Software&id=536226604";
- [[UIApplication sharedApplication] openURL:[NSURL URLWithString:strLoc]];
- }
其他參考:http://blog.csdn.net/james_1010/article/details/8556715