【发布时间】:2019-08-20 01:10:18
【问题描述】:
我在 Iphone 中运行我的 Xamarin Cross 平台,但 Device.OpenUri 无法正常工作,此功能在 Android 平台中按预期工作,但在 iOS 中,当我单击 whatsapp URI 时,它只会重新加载页面而不会打开Whatsapp APP
我尝试在 info.plist 中的 LSApplicationQueriesSchemes 中添加“whatsapp”引用,但未成功
Hipnosoftpage.IsVisible = false;
ErroRede = true;
DisplayAlert("Sem Conexão", "Verifique sua conexão com a internet.", "Tentar Novamente").ContinueWith(t =>
{
Hipnosoftpage.Reload();
}, TaskScheduler.FromCurrentSynchronizationContext());
}
var url = e.Url;
if (url.StartsWith("whatsapp://", StringComparison.InvariantCultureIgnoreCase))
{
try
{
Device.OpenUri(new Uri(url));
Hipnosoftpage.GoBack();
}
// Can not catch Android exception type in NetStd/PCL library, so hack it...
catch (Exception ex) when (ex.Message.StartsWith("No Activity found to handle Intent", StringComparison.InvariantCulture))
{
// WhatsApp not installed : Android.Content.ActivityNotFoundException: No Activity found to handle Intent
Console.WriteLine(ex);
}
}
}
我希望 whatsapp 打开,但 Device.OpenUri 没有正确打开,并且在调试控制台中没有给我任何错误。
【问题讨论】:
-
你能给我们一个 url 可能包含的示例吗?显然它以 whatsapp:// 开头,但后面跟着什么参数
-
是的,类似于api.whatsapp.com/…
-
你的网址应该以whatsapp://开头;所以你的意思是“whatsapp://send?1=pt_BR&phone=TELNUMBER&text=MESSAGE”?
-
你的手机安装Whatsapp了吗?您还必须检查 url 格式。看到这些线程可能会有所帮助:whatsapp 和 open-whatsapp
标签: c# xamarin.forms