C# iOS手机链接打开信息应用程序而不是拨打电话号码
我需要文本视图中的电话号码,以便在单击时拨打该电话号码: 我面临的问题是,当点击链接时,消息应用程序正在打开。我在iOS 12中尝试了下面的代码,效果如预期,但当我在iOS 13和14上尝试时,消息应用程序打开,而不是使用“电话拨号器应用程序”拨打电话 暂定1:C# iOS手机链接打开信息应用程序而不是拨打电话号码,c#,ios,xamarin,C#,Ios,Xamarin,我需要文本视图中的电话号码,以便在单击时拨打该电话号码: 我面临的问题是,当点击链接时,消息应用程序正在打开。我在iOS 12中尝试了下面的代码,效果如预期,但当我在iOS 13和14上尝试时,消息应用程序打开,而不是使用“电话拨号器应用程序”拨打电话 暂定1: textView.Editable = false; textView.DataDetectorTypes = UIDataDetectorType.PhoneNumber; 暂定2: var phoneNumberLink = n
textView.Editable = false;
textView.DataDetectorTypes = UIDataDetectorType.PhoneNumber;
暂定2:
var phoneNumberLink = new Dictionary<string, string>(){ { "(855) 757-7328","tel:8557577328" } }
textView.Editable = false;
textView.SetAttributedTextForLinks("Please call us at (855) 757-7328", phoneNumberLink);
var phoneNumberLink=newdictionary(){{(855)757-7328”,“电话:8557577328}
textView.Editable=false;
SetAttributedTextForLinks(“请致电(855)757-7328”,电话号码链接);
如前所述
打开拨号器的正确方法是
telprompt://0123456789
确保没有空格。实际上,
telpromt://0123456789
也不起作用。我必须拦截与URL的交互,建议的ShouldInteractWithUrl
不起作用(ShouldInteractWithUrl
未被触发或调用),因此我必须使用allowurinteraction
。代码如下所示:
var description = new KiteEmbeddedLinkTextView()
{
Editable = false,
DataDetectorTypes = UIDataDetectorType.PhoneNumber,
Text = message.MessageText
};
description.AllowUrlInteraction += AllowUrlInteraction;
private bool AllowUrlInteraction(UITextView textView, NSUrl url, NSRange characterRange, UITextItemInteraction interaction)
{
UIApplication.SharedApplication.OpenUrl(url);
return false;
}
出于某种原因,除了这个,以前的选择都不适合我
见:
看,我明白了,在找到这个讨论之后,我实际上只是在尝试:但是说实话,“DataDetectorType”不能满足我的需要,这真是令人恼火(我不得不添加一些东西来设置SetAttributedTextForLinks。虽然DataDetectorType只是一行简单的代码……无论如何……非常感谢!很高兴提供帮助!)