问题描述
我正在尝试从我的xamarin表单ios应用程序打开ios应用程序.我为此功能引用了
在视图中
ar appname ="App Bundle Identifier";var result = await DependencyService.Get< IAppHandler>().LaunchApp(appname);如果(!结果){Device.OpenUri(new Uri("Appstore link")));}
当我尝试打开应用程序时,我得到的是 2020-09-05 13:41:30.761 ProjectName.iOS [1128:451468] -canOpenURL:URL失败:捆绑标识符";-错误:输出框中的输入URL无效"
.我在此实现中缺少什么?
您设置了无效的网址方案.
在第二个应用程序中
在info.plist
中 < key> CFBundleURLTypes</key>< array>< dict>< key> CFBundleURLName</key>< string> URL类型1</string>< key> CFBundleURLSchemes</key>< array>< string> lucas</string></array>< key> LSApplicationQueriesSchemes</key>< array>< string> lucas</string></array>< key> CFBundleTypeRole</key>< string>编辑器</string></dict></array>
在第一个应用程序中
您可以通过调用行来打开它
var canOpen = UIApplication.SharedApplication.CanOpenUrl(new NSUrl("lucas://")));如果(!canOpen)返回Task.FromResult(false);返回Task.FromResult(UIApplication.SharedApplication.OpenUrl(new NSUrl("lucas://"))));
I am trying to open an ios app from my xamarin forms ios app. I have referred this thread for this feature, but I am getting error: "Invalid input URL"
message on the output box.
Interface on Main project
public interface IAppHandler
{
Task<bool> LaunchApp(string uri);
}
IOS
[assembly: Dependency(typeof(OpenAppImplementation))]
namespace Projectname.iOS.Renderer
{
public class OpenAppImplementation : IAppHandler
{
public Task<bool> LaunchApp(string uri)
{
try
{
var canOpen = UIApplication.SharedApplication.CanOpenUrl(new NSUrl(uri));
if (!canOpen)
return Task.FromResult(false);
return Task.FromResult(UIApplication.SharedApplication.OpenUrl(new NSUrl(uri)));
}
catch (Exception ex)
{
return Task.FromResult(false);
}
}
}
}
Info.plist: App Bundle Identifier details added here.
In the view
ar appname = "App Bundle Identifier";
var result = await DependencyService.Get<IAppHandler>().LaunchApp(appname);
if (!result)
{
Device.OpenUri(new Uri("Appstore link"));
}
When I am trying to open the app I am getting 2020-09-05 13:41:30.761 ProjectName.iOS[1128:451468] -canOpenURL: failed for URL: "Bundle Identifier" - error: "Invalid input URL"
on the output box. What I am missing in this implementation?
You set the invalid Url Schemes .
in the second App
in info.plist
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleURLName</key>
<string>URL Type 1</string>
<key>CFBundleURLSchemes</key>
<array>
<string>lucas</string>
</array>
<key>LSApplicationQueriesSchemes</key>
<array>
<string>lucas</string>
</array>
<key>CFBundleTypeRole</key>
<string>Editor</string>
</dict>
</array>
in the first app
You can open it by invoke the line
var canOpen = UIApplication.SharedApplication.CanOpenUrl(new NSUrl("lucas://"));
if (!canOpen)
return Task.FromResult(false);
return Task.FromResult(UIApplication.SharedApplication.OpenUrl(new NSUrl("lucas://")));
这篇关于Xamarin表单:从Xamarin Forms App启动IOS App的问题(无效的输入URL)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!