首先在程序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程序的地方添加代碼
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