Skip to content

com.android.installreferrer

marchbold edited this page Mar 19, 2020 · 1 revision

Install Referrer

The com.android.installreferrer extension provides functionality to retrieve the install referrer url from Android devices via the Google Play install referrer SDK.

Generally this extension is just used as a dependency however this functionality has been exposed for users who wish direct access to the SDK.

Get Install Referrer

The process to retrieve the install referrer is asynchronous and involves a service connection. This is all done in the native code so all you are required to do is to listen for the events and call getInstallReferrer() when you wish to initiate the process:

InstallReferrer.instance.addEventListener( InstallReferrerEvent.FEATURE_NOT_SUPPORTED, errorHandler );
InstallReferrer.instance.addEventListener( InstallReferrerEvent.SERVICE_UNAVAILABLE, errorHandler );
InstallReferrer.instance.addEventListener( InstallReferrerEvent.COMPLETE, completeHandler );
InstallReferrer.instance.getInstallReferrer();

The events dispatched are related to various results from the process:

  • InstallReferrerEvent.FEATURE_NOT_SUPPORTED: The device doesn't support this functionality;
  • InstallReferrerEvent.SERVICE_UNAVAILABLE: The service is currently unavailable, perhaps due to a network issue. You can retry the process later;
  • InstallReferrerEvent.COMPLETE: The referrer was retrieved successfully.

On success the event will have a valid referrerUrl parameter.

function completeHandler( event:InstallReferrerEvent ):void 
{
    trace( event.referrerUrl );
}

function errorHandler( event:InstallReferrerEvent ):void 
{
    // Handle the error according to your application logic
}
Clone this wiki locally