I need to launch another app from within my own app, but I don't have its URL. So my question is: Is there a way to find out another app's url programmatically based on its bundle identifier, or trackid?
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
No, there is no way to determine an app's custom URL scheme programmatically. An app's custom scheme, if there even is one, can be completely unrelated to anything else you may know about the app.
The only way to determine the scheme is to access the app's Info.plist file, and unless you are on a jailbroken device, this can't be done at runtime.
回答2:
If you just want to launch other apps, you can use ios private api.
@interface PrivateApi_LSApplicationWorkspace
- (bool)openApplicationWithBundleID:(id)arg1; //LSApplicationWorkspace
- (NSArray*)privateURLSchemes; //LSApplicationWorkspace
- (NSArray*)publicURLSchemes;
@end
PrivateApi_LSApplicationWorkspace* _workspace;
_workspace = [NSClassFromString(@"LSApplicationWorkspace") new];
[_workspace openApplicationWithBundleID:bundleIdentifier];
NSArray* privateUrls = [_workspace privateURLSchemes];
NSArray* publicUrls = [_workspace publicURLSchemes];
check https://github.com/wujianguo/iOSAppsInfo