【问题标题】:Xamarin Forms - How to make it so that a user that clicks on a email link will open the email app in the deviceXamarin Forms - 如何使单击电子邮件链接的用户在设备中打开电子邮件应用程序
【发布时间】:2021-12-29 19:04:38
【问题描述】:

我想这样当我在 Xamarin Forms 中单击(电子邮件链接)和(电话号码)时, 在用户设备上启动(电子邮件应用程序)和(电话应用程序)。

Xaml

<Label HorizontalTextAlignment="Start"
       Style="{StaticResource DescriptionLabelStyle}">
       <Label.FormattedText>
             <FormattedString>
                   <Span Text="{x:Static resources:Lang.AccessibilityRepDesc}" />
                         <Span Text="goteborg@goteborg.se" 
                               TextColor="{DynamicResource HyperLink}">
                                    <Span.GestureRecognizers>
                                        <TapGestureRecognizer Command="{Binding EmailCommand}" />
                                        </Span.GestureRecognizers>
                                    </Span>

                                    <Span Text="{helpers:Translate OrCall}" />

                                    <Span Text="031-3650000" 
                                          TextColor="{DynamicResource HyperLink}">
                                        <Span.GestureRecognizers>
                                            <TapGestureRecognizer Command="{Binding PhoneCommand}"/>
                                        </Span.GestureRecognizers>
                                    </Span>
                                </FormattedString>
                            </Label.FormattedText>
                        </Label>

代码背后

private void EmailClicked(object obj)
{
     Console.WriteLine("Sending Email");
}

private void PhoneClicked(object obj)
{
     Console.WriteLine("Making a phonecall");
}

【问题讨论】:

  • 检查 Xamarin.Essentials、emailphone call
  • 通过您发送给我的链接,我能够修复“电子邮件”按钮。我仍在尝试解决电话按钮问题
  • 当我根据文档 PhoneDialer.Open(phoneNumber); 使用此代码时 - 我收到错误消息 Exception while opening dialer: Specified method is not supported.

标签: c# android ios xamarin.forms mobile


【解决方案1】:

我可以通过闲置this post来修复它

在 Nuget 上使用 (Xam.Plugins.Messaging) 非常容易修复。 我已经在 Android 上测试过,我还没有在 iOS 上测试过。

【讨论】:

    【解决方案2】:

    您可能正在寻找 Xamarin Essentials 之类的东西。它有很多好的 API。有一个E-mail API,你可以阅读它in these Docs

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2012-01-14
      • 2017-12-25
      • 2016-03-22
      • 2012-07-30
      • 2013-08-30
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多