Tracking what links a user is sharing from my app.

SteveGrixtiSteveGrixti Member
edited August 30 in Xamarin.Forms

Hi All,

Could anybody help me out with a small issue i'm having? I am using the method below in order to share uri's from my app.

ShareTextRequest share = new ShareTextRequest
{
    Uri = uri,
    Title = "Share Link"
};

await Share.RequestAsync(share);

All is working fine on both Android and iOS, however I am running into an issue as I would like to track and log to what applications the users are sharing the link, for security purposes as per company policy.

An example of the log would be something like;

{
   'UserId': '999',
   'Link': 'http://example.com',
   'SharedTo': 'Facebook',
   'SharedOn': '29/08/2019 11:00.000'
}

Would it be possible to use a callback method for example, where I can return the name of the application the link was shared to?

Thanks in Advance :)

Answers

  • JarvanJarvan Member, Xamarin Team Xamurai

    From the source code of Essentials.Share, we can see that ShareTextRequest class doesn't have a method to get the feedback when sharing. To achieve the feature, you may need to create a custom_Share.

    https://github.com/xamarin/Essentials/blob/master/Xamarin.Essentials/Share/Share.shared.cs

  • SteveGrixtiSteveGrixti Member
    edited August 30

    Yes I actually got to this, just downloaded the code and went through it to see what is actually happening.

    How would one go ahead at extending this code?

    Cant understand how xamarin is able to recognize the difference between share.android.cs and share.ios.cs.

    If I know how this works, I'll try working on an extension of the class to provide more functionality.

Sign In or Register to comment.