Permalink
Browse files

Add ISocial iOS implementation.

  • Loading branch information...
ilanolkies committed Jun 6, 2018
1 parent b9f2f51 commit c8a18df9829d5e770c0b33db47e0ec8510ddfe88
@@ -54,7 +54,7 @@
<PackageReference Include="Xamarin.Android.Support.v7.CardView" Version="27.0.2" />
<PackageReference Include="Xamarin.Android.Support.v7.MediaRouter" Version="27.0.2" />
<PackageReference Include="Xamarin.Forms">
<Version>3.0.0.530893</Version>
<Version>3.0.0.550146</Version>
</PackageReference>
</ItemGroup>
<ItemGroup>
@@ -0,0 +1,18 @@
using Foundation;
using UIKit;
using Xamarin.Forms;
using XamarinSocial.iOS;

[assembly: Dependency(typeof(SocialService))]
namespace XamarinSocial.iOS
{
public class SocialService : ISocial
{
public void Share(string content)
{
var activityViewController = new UIActivityViewController(new NSString[] { new NSString(content) }, null);

UIApplication.SharedApplication.KeyWindow.RootViewController.PresentViewController(activityViewController, true, null);
}
}
}
@@ -94,6 +94,7 @@
<None Include="Entitlements.plist" />
<None Include="Info.plist" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="SocialService.cs" />
</ItemGroup>
<ItemGroup>
<InterfaceDefinition Include="Resources\LaunchScreen.storyboard" />
@@ -148,7 +149,7 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="Xamarin.Forms">
<Version>3.0.0.530893</Version>
<Version>3.0.0.550146</Version>
</PackageReference>
</ItemGroup>
<Import Project="$(MSBuildExtensionsPath)\Xamarin\iOS\Xamarin.iOS.CSharp.targets" />
@@ -16,15 +16,7 @@ public MainPage()
void Handle_Clicked(object sender, System.EventArgs e)
{
string content = "Following 'Xamarin Social Example' by @ilanolkies https://ilanolkies.github.io";

try
{
DependencyService.Get<ISocial>().Share(content);
}
catch (Exception)
{
DisplayAlert("Keep moving!", string.Format("Just the dependency injection missing!\nContent: {0}",content), "OK");
}
DependencyService.Get<ISocial>().Share(content);
}
}
}
@@ -5,6 +5,6 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Xamarin.Forms" Version="3.0.0.446417" />
<PackageReference Include="Xamarin.Forms" Version="3.0.0.550146" />
</ItemGroup>
</Project>

0 comments on commit c8a18df

Please sign in to comment.