npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

cordova-play-install-referrer

v1.0.1

Published

Play Install Referrer wrapper for Cordova

Downloads

7

Readme

Play Install Referrer Library wrapper for Cordova

cordova-play-install-referrer is a simple wrapper around Google's Play Install Referrer Library which offers basic functionality of obtaining Android referrer information from Cordova app.

More information about Play Install Referrer API can be found in official Google documentation.

Version of native Play Install Referrer Library which is being used inside of latest cordova-play-install-referrer plugin version is 2.1.

Add plugin to your app

cordova-play-install-referrer plugin is hosted on npm repo and can be added from there.

cordova plugin add cordova-play-install-referrer

Usage

In order to obtain install referrer details, call getInstallReferrerInfo static method of PlayInstallReferrer class:

PlayInstallReferrer.getInstallReferrerInfo(function(installReferrerInfo) {
    if (!installReferrerInfo.errorMessage) {
        console.log("install referrer = " + installReferrerInfo.installReferrer);
        console.log("referrer click timestamp seconds = " + installReferrerInfo.referrerClickTimestampSeconds);
        console.log("install begin timestamp seconds = " + installReferrerInfo.installBeginTimestampSeconds);
        console.log("referrer click timestamp server seconds = " + installReferrerInfo.referrerClickTimestampServerSeconds);
        console.log("install begin timestamp seconds = " + installReferrerInfo.installBeginTimestampServerSeconds);
        console.log("install version = " + installReferrerInfo.installVersion);
        console.log("google play instant = " + installReferrerInfo.googlePlayInstant);
        } else {
        console.log("error message: " + installReferrerInfo.errorMessage);
        console.log("error response code: " + installReferrerInfo.errorResponseCode);
    }
});

If successfully obtained, map with content of install referrer information will be delivered into callback method. From that map, you can get following install referrer details:

  • Install referrer string value (installReferrer key).
  • Timestamp of when user clicked on URL which redirected him/her to Play Store to download your app (referrerClickTimestampSeconds key).
  • Timestamp of when app installation on device begun (installBeginTimestampSeconds key).
  • Server timestamp of when user clicked on URL which redirected him/her to Play Store to download your app (referrerClickTimestampServerSeconds key).
  • Server timestamp of when app installation on device begun (installBeginTimestampServerSeconds key).
  • Original app version which was installed (installVersion key).
  • Information if your app's instant version (if you have one) was launched in past 7 days (googlePlayInstant key).

Remaining two fields are indicators of error which might have occurred. If error happened, error message is guaranteed that it will be available, so you should first check if error message is null or not before trying to read above mentioned fields. Remaining error related fields are:

  • Error message (errorMessage key).
  • Error response code reported by install referrer API (errorResponseCode key).

In case error is reported, you can get following information about the error:

  • errorMessage: Additional string message which describes error more in detail. Note: Message field should always be present in error map.
  • errorResponseCode: Error response code which native Install Referrer Library might return. Full list of potential response codes can be found in here (OK will never be reported in this property, since it's a success status code). Note: Error code field is not always present in error map - only if error created when one of the error codes from native Install Referrer Library is received; otherwise this field will be undefined.

Under the hood

Important thing to notice is that in order to work properly, Play Install Referrer Library requires following permission to be added to your app's AndroidManifest.xml:

<uses-permission android:name="com.google.android.finsky.permission.BIND_GET_INSTALL_REFERRER_SERVICE"/>

Play Install Referrer Library is added to cordova-play-install-referrer plugin as an Gradle dependency and it will automatically make sure that manifest file ends up with above mentioned permission added to it upon building your app.