iOS 如何在一個應用程序中調用另一個應用程序

分兩步:
步驟一:
首先在程序A的plist中添加url types
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleURLName</key>
<string>AAAAA</string>
<key>CFBundleURLSchemes</key>
<array>
<string>testA</string>
</array>
</dict>
</array>

步驟二:
在程序B中調用A程序的地方添加代碼
// @"testA:" --> URLScheme
NSURL *myURL_APP_A = [NSURL URLWithString:@"testA://AAAAA"];
if ([[UIApplication sharedApplication] canOpenURL:myURL_APP_A]) {
    NSLog(@"canOpenURL");
    [[UIApplication sharedApplication] openURL:myURL_APP_A];
}

注:
這裏通過canOpenURL就可以通過URL檢查機器是否安裝有程序A
通過openURL打開程序A


發佈了13 篇原創文章 · 獲贊 12 · 訪問量 35萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章