Xamarin Forms: Share Picture on Instgram [closed]

对着背影说爱祢 提交于 2021-02-17 07:05:46

问题


I am developing a Xamarin Forms application with Android and iOS solutions. I am desperately searching for a full example to allow a user to share on Instagrama picture taken from my app.

Anyone can point to some good tutorial/example/github repo/etc. ?


回答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.



来源:https://stackoverflow.com/questions/45505655/xamarin-forms-share-picture-on-instgram

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!