如何使用 "appname://openApp?" 打开 iOS 中的 App?
How to open App in iOS using "appname://openApp?"?
我需要使用 iOS 应用程序的参数打开另一个应用程序。
我有应用开发者提供的特定URL方案,必须打开:
secondApp://openApp?param1=XXX¶m2=YYY
我尝试搜索 Google 如何以这种方式打开应用程序,但我没有找到任何示例如何使用此构造。
能不能提供一下link或者一行代码如何这样打开App?
您可以查看 Inter-App Communication provided by Apple. Also, you can look into this tutorial. Here, they are sending text to another app. Also, another detailed answer to your question can be found in here 的文档。
本教程中的以下代码会对您有所帮助:
-(IBAction) openReceiverApp {
// Opens the Receiver app if installed, otherwise displays an error
UIApplication *ourApplication = [UIApplication sharedApplication];
NSString *ourPath = @"secondApp://openApp?param1=XXX";
NSURL *ourURL = [NSURL URLWithString:ourPath];
if ([ourApplication canOpenURL:ourURL]) {
[ourApplication openURL:ourURL];
}
}
要从您的 iOS 应用打开第二个应用,只需使用:
NSURL *url = [NSURL URLWithString:@"secondApp://openApp?param1=XXX¶m2=YYY"]; //fill your params
if ([[UIApplication sharedApplication] canOpenURL:url]) {
[[UIApplication sharedApplication] openURL:url];
}
我需要使用 iOS 应用程序的参数打开另一个应用程序。
我有应用开发者提供的特定URL方案,必须打开:
secondApp://openApp?param1=XXX¶m2=YYY
我尝试搜索 Google 如何以这种方式打开应用程序,但我没有找到任何示例如何使用此构造。
能不能提供一下link或者一行代码如何这样打开App?
您可以查看 Inter-App Communication provided by Apple. Also, you can look into this tutorial. Here, they are sending text to another app. Also, another detailed answer to your question can be found in here 的文档。
本教程中的以下代码会对您有所帮助:
-(IBAction) openReceiverApp {
// Opens the Receiver app if installed, otherwise displays an error
UIApplication *ourApplication = [UIApplication sharedApplication];
NSString *ourPath = @"secondApp://openApp?param1=XXX";
NSURL *ourURL = [NSURL URLWithString:ourPath];
if ([ourApplication canOpenURL:ourURL]) {
[ourApplication openURL:ourURL];
}
}
要从您的 iOS 应用打开第二个应用,只需使用:
NSURL *url = [NSURL URLWithString:@"secondApp://openApp?param1=XXX¶m2=YYY"]; //fill your params
if ([[UIApplication sharedApplication] canOpenURL:url]) {
[[UIApplication sharedApplication] openURL:url];
}