react-native-appsflyer
Advanced tools
Comparing version 1.0.1 to 1.0.2
76
index.js
import { NativeModules } from 'react-native'; | ||
import { NativeAppEventEmitter } from 'react-native'; | ||
const { RNAppsFlyer } = NativeModules; | ||
export default RNAppsFlyer; | ||
const appsFlyer = {}; | ||
const eventsMap = {}; | ||
appsFlyer.initSdk = (options, successC, errorC) => { | ||
console.log("initSdk: " + eventsMap['onInstallConversionData']); | ||
options.onInstallConversionDataListener = (eventsMap['onInstallConversionData']) ? true: false; | ||
return RNAppsFlyer.initSdk(options, successC, errorC); | ||
}; | ||
appsFlyer.trackLocation = (longitude, latitude, callback) => { | ||
return RNAppsFlyer.trackLocation(longitude, latitude, callback); | ||
}; | ||
appsFlyer.trackEvent = (eventName, eventValues, successC, errorC) => { | ||
return RNAppsFlyer.trackEvent(eventName, eventValues, successC, errorC); | ||
}; | ||
appsFlyer.getAppsFlyerUID = (callback) => { | ||
return RNAppsFlyer.getAppsFlyerUID(callback); | ||
}; | ||
/** | ||
* Accessing AppsFlyer Attribution / Conversion Data from the SDK (Deferred Deeplinking) | ||
* @param callback: contains fields: | ||
* status: success/failure | ||
* type: | ||
* onAppOpenAttribution | ||
* onInstallConversionDataLoaded | ||
* onAttributionFailure | ||
* onInstallConversionFailure | ||
* data: metadata, | ||
* @example {"status":"success","type":"onInstallConversionDataLoaded","data":{"af_status":"Organic","af_message":"organic install"}} | ||
* | ||
* @returns {remove: function - unregister listener} | ||
*/ | ||
appsFlyer.onInstallConversionData = (callback) => { | ||
console.log("onInstallConversionData is called" ); | ||
const listener = NativeAppEventEmitter.addListener('onInstallConversionData', | ||
(_data) => { | ||
if(callback && typeof(callback) === typeof(Function)){ | ||
try{ | ||
let data = JSON.parse(_data); | ||
callback(data); | ||
} | ||
catch(_error){ | ||
//throw new AFParseJSONException("..."); | ||
//TODO: for today we return an error in callback | ||
callback(new AFParseJSONException("Invalid data structure", _data)); | ||
} | ||
} | ||
} | ||
); | ||
eventsMap['onInstallConversionData'] = listener; | ||
// unregister listener (suppose should be called from componentWillUnmount() ) | ||
return function remove() { | ||
listener.remove(); | ||
}; | ||
}; | ||
function AFParseJSONException(_message, _data) { | ||
this.message = _message; | ||
this.data = _data; | ||
this.name = "AFParseJSONException"; | ||
} | ||
export default appsFlyer; |
{ | ||
"name": "react-native-appsflyer", | ||
"version": "1.0.1", | ||
"version": "1.0.2", | ||
"description": "React Native Appsflyer plugin", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -9,13 +9,26 @@ | ||
## Table of content | ||
## This plugin is built for | ||
- [Supported Platforms](#supported-platforms) | ||
- [Installation](#installation) | ||
- [iOS](#i-ios) | ||
- [Android](#i-android) | ||
- [API Methods](#api-methods) | ||
- [initSdk](#init-sdk) | ||
- [trackEvent](#trackEvent) | ||
- [onInstallConversionData](#onInstallConversionData) | ||
- [getAppsFlyerUID](#getAppsFlyerUID) | ||
- [trackLocation](#trackLocation) | ||
## This plugin is built for {#supported-platforms} | ||
- iOS AppsFlyerSDK **v4.5.9** | ||
- Android AppsFlyerSDK **v4.6.0** | ||
## Installation | ||
## Installation {#installation} | ||
`$ npm install react-native-appsflyer --save` | ||
### iOS | ||
### iOS {#i-ios} | ||
@@ -49,3 +62,3 @@ | ||
### Android | ||
### Android {#i-android} | ||
@@ -98,3 +111,3 @@ ##### **android/app/build.gradle** | ||
##API Methods | ||
##API Methods {#api-methods} | ||
@@ -109,5 +122,5 @@ --- | ||
**`appsFlyer.initSdk(options, callback): void`** | ||
#####**`appsFlyer.initSdk(options, callback): void`** {#init-sdk} | ||
initialize the SDK, returns `Object`. | ||
initializes the SDK. | ||
@@ -140,3 +153,3 @@ | parameter | type | description | | ||
} else { | ||
/.. | ||
//.. | ||
} | ||
@@ -148,3 +161,3 @@ }) | ||
**`appsFlyer.trackEvent(eventName, eventValues, callback): void`** | ||
#####**`appsFlyer.trackEvent(eventName, eventValues, callback): void`** {#trackEvent} | ||
@@ -186,6 +199,61 @@ | ||
#####**`appsFlyer.onInstallConversionData(callback): function:unregister `** {#onInstallConversionData} | ||
**`appsFlyer.getAppsFlyerUID(callback): void`** | ||
Accessing AppsFlyer Attribution / Conversion Data from the SDK (Deferred Deeplinking). | ||
Read more: [Android](http://support.appsflyer.com/entries/69796693-Accessing-AppsFlyer-Attribution-Conversion-Data-from-the-SDK-Deferred-Deep-linking-), [iOS](http://support.appsflyer.com/entries/22904293-Testing-AppsFlyer-iOS-SDK-Integration-Before-Submitting-to-the-App-Store-) | ||
| parameter | type | description | | ||
| ----------- |-----------------------------|--------------| | ||
| `callback` | `function` | returns [object](#callback-structure) | | ||
##### callback structure: {#callback-structure} | ||
- `status`: `"success"`or `"failure"` if SDK returned error on `onInstallConversionData` event handler | ||
- `type`: | ||
- `"onAppOpenAttribution"` - returns deep linking data (non-organic) | ||
- `"onInstallConversionDataLoaded"` - called on each launch | ||
- `"onAttributionFailure"` | ||
- `"onInstallConversionFailure"` | ||
- `data`: some metadata, | ||
for example: | ||
``` | ||
{ | ||
"status": "success", | ||
"type": "onInstallConversionDataLoaded", | ||
"data": { | ||
"af_status": "Organic", | ||
"af_message": "organic install" | ||
} | ||
} | ||
``` | ||
*Example:* | ||
```javascript | ||
this.onInstallConversionDataCanceller = appsFlyer.onInstallConversionData( | ||
(data) => { | ||
console.log(data); | ||
} | ||
); | ||
``` | ||
The `appsFlyer.onInstallConversionData` returns function to unregister this event listener. Actually it calls `NativeAppEventEmitter.remove()` | ||
*Example:* | ||
```javascript | ||
componentWillUnmount() { | ||
if(this.onInstallConversionDataCanceller){ | ||
this.onInstallConversionDataCanceller(); | ||
} | ||
} | ||
``` | ||
--- | ||
#####**`appsFlyer.getAppsFlyerUID(callback): void`** {#getAppsFlyerUID} | ||
Get AppsFlyer’s proprietary Device ID. The AppsFlyer Device ID is the main ID used by AppsFlyer in Reports and APIs. | ||
@@ -211,3 +279,3 @@ | ||
**`appsFlyer.trackLocation(longitude, latitude, callback(error, coords): void`** (**iOS only**) | ||
#####**`appsFlyer.trackLocation(longitude, latitude, callback(error, coords): void`** (**iOS only**) {#trackLocation} | ||
@@ -214,0 +282,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Trivial Package
Supply chain riskPackages less than 10 lines of code are easily copied into your own project and may not warrant the additional supply chain risk of an external dependency.
Found 1 instance in 1 package
195465
24
61
317
0