Giter Site home page Giter Site logo

xamarin.android.binding.installreferrer's Introduction

Deprecation warning: Microsoft has now a official binding for this that also supports .Net Maui. https://www.nuget.org/packages/Xamarin.Google.Android.InstallReferrer. This binding will not be updated anymore.

Xamarin.Android.Binding.InstallReferrer

A Google's InstallReferrer library binding for Xamarin Android

Official docs: https://developer.android.com/google/play/installreferrer/library

Example of use:

InstallReferrerClient referrerClient = InstallReferrerClient.NewBuilder(context).Build();

referrerClient.StartConnection(new InstallReferrerStateListenerImpl {
    InstallReferrerSetupFinished = code => OnSetupFinished(referrerClient, code),
    InstallReferrerServiceDisconnected = OnInstallReferrerServiceDisconnected
});

private static void OnSetupFinished(InstallReferrerClient referrerClient, int code) {
    switch (code) {
        case InstallReferrerClient.InstallReferrerResponse.DeveloperError:
            TrackError("DeveloperError");
            break;
        case InstallReferrerClient.InstallReferrerResponse.PermissionError:
            TrackError("PermissionError");
            break;
        case InstallReferrerClient.InstallReferrerResponse.ServiceDisconnected:
            TrackError("ServiceDisconnected");
            break;
        case InstallReferrerClient.InstallReferrerResponse.ServiceUnavailable:
            TrackError("ServiceUnavailable");
            break;
        case InstallReferrerClient.InstallReferrerResponse.FeatureNotSupported:
            TrackError("FeatureNotSupported");
            break;
        case InstallReferrerClient.InstallReferrerResponse.Ok:
            OnConnectionEstablished(referrerClient);
            break;
    }
}

private static void OnConnectionEstablished(InstallReferrerClient referrerClient) {
    ReferrerDetails response = referrerClient.InstallReferrer;
    string referrerUrl = response.InstallReferrer;
    
    // do something
    
    referrerClient?.EndConnection();
    referrerClient?.Dispose();
}
 internal sealed class InstallReferrerStateListenerImpl : Java.Lang.Object, IInstallReferrerStateListener {

    public Action<int> InstallReferrerSetupFinished;
    public Action InstallReferrerServiceDisconnected;

    public void OnInstallReferrerServiceDisconnected() {
        InstallReferrerServiceDisconnected.Invoke();
    }

    public void OnInstallReferrerSetupFinished(int p0) {
        InstallReferrerSetupFinished.Invoke(p0);
    }

}

xamarin.android.binding.installreferrer's People

Contributors

douglasgiovanella avatar

Stargazers

 avatar David Taylor avatar Joachim avatar

Watchers

 avatar

xamarin.android.binding.installreferrer's Issues

Please provide more information.

How do I use this? I really have no clue how to get the referrer after Google depraced the referrer Intent Broadcast in March 2020. I need to get the referrer! Can you provide a little more information how setup this with your binding project in the ReadMe or give at least a little hint? I can't find anything about this topic in Xamarin Forums or Stackoverflow.

MAUI

Does this package work on MAUI?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.