Skip to content

Module for getting install referrer on android, using Google Play Install Referrer API

Notifications You must be signed in to change notification settings

alexkuttig/react-native-install-referrer

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

react-native-install-referrer

Module for getting install referrer on android, using Google Play Install Referrer API.

Getting started

$ npm install react-native-install-referrer --save

or

$ yarn add react-native-install-referrer

Mostly automatic installation

$ react-native link react-native-install-referrer

Manual installation

Android

  1. Open up android/app/src/main/java/[...]/MainAplication.java
  • Add import com.reactlibrary.RNInstallReferrerPackage; to the imports at the top of the file
  • Add new RNInstallReferrerPackage() to the list returned by the getPackages() method
  1. Append the following lines to android/settings.gradle:
    include ':react-native-install-referrer'
    project(':react-native-install-referrer').projectDir = new File(rootProject.projectDir, 	'../node_modules/react-native-install-referrer/android')
    
  2. Insert the following lines inside the dependencies block in android/app/build.gradle:
      implementation project(':react-native-install-referrer')
    

Usage

import RNInstallReferrer from 'react-native-install-referrer';
...
const referrer = await RNInstallReferrer.getReferrer();
console.log(referrer);
//  or
RNInstallReferrer.getReferrer().then(referrer=>console.log(referrer));

//  response example:
//  {
//  	"installTimestamp": "1557907970",
//  	"installReferrer": "utm_source=google-play&utm_medium=organic",
//  	"clickTimestamp": "1557907970",
//  }
//
//  or
//
//  {
//  	"message": "some error message",
//  }

Caution

The install referrer information will be available for 90 days and won't change unless the application is reinstalled. To avoid unecessary API calls in your app, you should invoke the API only once during the first execution after install.

About

Module for getting install referrer on android, using Google Play Install Referrer API

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Java 96.7%
  • JavaScript 3.3%