I'm starting on Xamarin ant trying to create a simple application with Xamarin.forms. Now I need to add the share button (square + arrow, like on Safari on the iPhone) in my application. As I know, Android and IOS are different from each other, so I use DependencyService. It works fine on Android using Intent, but cannot do it on iOS. could you help me please. Thanks everyone,
this is my code.
PCL
var x = DependencyService.Get<IShareable>();
x.ShareText("any text to share");
Android
public void ShareText(string textToShear)
{
var myIntent = new Intent(Android.Content.Intent.ActionSend);
myIntent.SetType("text/plain");
myIntent.PutExtra("sms_body", textToShear);
Forms.Context.StartActivity(Intent.CreateChooser(myIntent,"Choose an App"));
}
IOS
public void ShareText(string textToShear)
{
}
source
share