Skip to content

Commit

Permalink
add version 1.0.0 of the plugin to the repo
Browse files Browse the repository at this point in the history
  • Loading branch information
uerceg committed Sep 6, 2020
1 parent 34fc80b commit b01f90c
Show file tree
Hide file tree
Showing 847 changed files with 110,056 additions and 2 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
### Version 1.0.0 [24th August 2020]
#### Added
- Initial release of **cordova-play-install-referrer** plugin.
83 changes: 81 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,81 @@
# play-install-referrer-cordova
Play Install Referrer Library ported to Cordova
# Play Install Referrer Library wrapper for Cordova

<table>
<tr>
<td align="left">Supported platforms:</td>
<td align="left"><img src="https://images-fe.ssl-images-amazon.com/images/I/21EctgvtXUL.png" width="16"></td>
</tr>
<tr>
<td align="left">Current version:</td>
<td align="left"><a href=../../../releases/tag/cordova-v1.0.0><b>1.0.0</b></a></td>
</tr>
<tr>
<td align="left">Troubles?</td>
<td align="left"><a href="../../../issues/new"><b>Report an issue</b></a></td>
</tr>
</table>

**cordova-play-install-referrer** is a simple wrapper around Google's [Play Install Referrer Library](https://developer.android.com/google/play/installreferrer/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](https://developer.android.com/google/play/installreferrer/igetinstallreferrerservice).

Version of native Play Install Referrer Library which is being used inside of latest **cordova-play-install-referrer** plugin version is [2.1](https://mvnrepository.com/artifact/com.android.installreferrer/installreferrer/2.1).

## Add plugin to your app

**cordova-play-install-referrer** plugin is hosted on [npm repo](https://www.npmjs.com/package/cordova-play-install-referrer) 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:

```js
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](https://developer.android.com/reference/com/android/installreferrer/api/InstallReferrerClient.InstallReferrerResponse) (`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`:

```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](./plugin/plugin.xml#L30) and it will automatically make sure that manifest file ends up with above mentioned permission added to it upon building your app.
1 change: 1 addition & 0 deletions VERSION
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1.0.0
26 changes: 26 additions & 0 deletions app/config.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?xml version='1.0' encoding='utf-8'?>
<widget id="com.ugi.example" version="1.0.0" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
<name>App</name>
<description>
A sample Apache Cordova application that responds to the deviceready event.
</description>
<author email="[email protected]" href="http://cordova.io">
Apache Cordova Team
</author>
<content src="index.html" />
<plugin name="cordova-plugin-whitelist" spec="1" />
<access origin="*" />
<allow-intent href="http://*/*" />
<allow-intent href="https://*/*" />
<allow-intent href="tel:*" />
<allow-intent href="sms:*" />
<allow-intent href="mailto:*" />
<allow-intent href="geo:*" />
<platform name="android">
<allow-intent href="market:*" />
</platform>
<platform name="ios">
<allow-intent href="itms:*" />
<allow-intent href="itms-apps:*" />
</platform>
</widget>
23 changes: 23 additions & 0 deletions app/hooks/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<!--
#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
#
-->
# Cordova Hooks

Cordova Hooks represent special scripts which could be added by application and plugin developers or even by your own build system to customize cordova commands. See Hooks Guide for more details: http://cordova.apache.org/docs/en/edge/guide_appdev_hooks_index.md.html#Hooks%20Guide.
1 change: 1 addition & 0 deletions app/node_modules/.bin/create

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions app/node_modules/.bin/nopt

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions app/node_modules/.bin/semver

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions app/node_modules/.bin/shjs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions app/node_modules/.bin/which

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

46 changes: 46 additions & 0 deletions app/node_modules/abbrev/LICENSE

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 23 additions & 0 deletions app/node_modules/abbrev/README.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

61 changes: 61 additions & 0 deletions app/node_modules/abbrev/abbrev.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

56 changes: 56 additions & 0 deletions app/node_modules/abbrev/package.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions app/node_modules/android-versions/.jshintignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

29 changes: 29 additions & 0 deletions app/node_modules/android-versions/.jshintrc

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions app/node_modules/android-versions/.travis.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit b01f90c

Please sign in to comment.