Xamarin表单:在Instgram上共享图片

时间:2017-08-04 11:27:49

标签: xamarin.ios xamarin.android xamarin.forms instagram share

我正在使用Android和iOS解决方案开发Xamarin Forms应用程序。 我正在拼命寻找一个完整的例子,允许用户分享从我的应用程序中拍摄的Instagrama照片。

任何人都可以指向一些好的教程/示例/ github repo /等。 ?

1 个答案:

答案 0 :(得分:1)

You can't directly post to an Instagram API as that is private, but you can Share a photo, with the Instagram app, if the user has that installed on their phone. Which is what I think you are trying to achieve. I don't know of any repo or sample, hence will need to do a bit of work yourself on this.

To do this you can use the Instagram Uri Scheme. For iOS you will need to use the Document Interaction section, in Android, you start a new activity and pass the media through.

You will need to code these natively and use Dependency Injection, to pass it into your Xamarin Forms app. An example on how to start an Activity in Android is as such:

public Task<bool> LaunchApp(string uri)
{
    bool result = false;

    try
    {
        var aUri = Android.Net.Uri.Parse(uri.ToString());
        var intent = new Intent(Intent.ActionView, aUri);
        Xamarin.Forms.Forms.Context.StartActivity(intent);
        result = true;
    }
    catch (ActivityNotFoundException)
    {
        result = false;
    }

    return Task.FromResult(result);
}

Modify Instagram's example to suit.