How to make a phone call in Xamarin Forms by clicking on a label? I know this question is cliche because someone already asked it here,
How to make a phone call in Xamarin.Forms by clicking on a label?
I can't ask in that post because it requires 50 reputation to comment. But I still need to know the answer because that post didn't show the final code. So here's my code,
RequestorPage.xaml
<StackLayout Orientation="Horizontal" HorizontalOptions="FillAndExpand" Margin="10,0,10,0">
<StackLayout Orientation="Vertical" HorizontalOptions="Start">
<Image Source="detail_mobile" HeightRequest="20" WidthRequest="20" />
</StackLayout>
<StackLayout Orientation="Vertical" VerticalOptions="Center">
<Label FontSize="Small" Text="{Binding RequestorHp}" x:Name="reqHp" />
</StackLayout>
</StackLayout>
RequestorPage.xaml.cs
public RequestorPage()
{
InitializeComponent();
var tapGestureRecognizer = new TapGestureRecognizer();
tapGestureRecognizer.Tapped += (s, e) =>
{
// handle the tap
var phoneDialer = CrossMessaging.Current.PhoneDialer;
if (phoneDialer.CanMakePhoneCall)
{
phoneDialer.MakePhoneCall(reqHp.Text);
}
};
// attache the gesture to your label
reqHp.GestureRecognizers.Add(tapGestureRecognizer);
}
When I run in the simulator, error appears when I click RequestorHp label. Here's the error,
System.NotImplementedException has been thrown
This functionality is not implemented in the portable version of this assembly. You should reference the NuGet package from your main application project in order to reference the platform-specific implementation.
Which part did I miss? Please help me. Thank you in advanced.