https://github.com/appsflyersdk/nativescript-plugin-appsflyer
https://github.com/appsflyersdk/nativescript-plugin-appsflyer
Last synced: about 2 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/appsflyersdk/nativescript-plugin-appsflyer
- Owner: AppsFlyerSDK
- License: mit
- Created: 2016-11-20T08:41:05.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2024-05-07T09:19:31.000Z (about 1 year ago)
- Last Synced: 2025-03-08T14:03:40.247Z (2 months ago)
- Language: TypeScript
- Size: 82.9 MB
- Stars: 5
- Watchers: 2
- Forks: 10
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# appsflyer-nativescript-plugin
Nativescript Library for AppsFlyer SDK[](https://badge.fury.io/js/nativescript-plugin-appsflyer)
## Table of content
- [Supported Platforms](#this-plugin-is-built-for)
- [Installation](#installation)
- [Integration](#api-methods)
- [initSdk](#initSdk)
- [logEvent](#logEvent)
- [Set plugin for IOS 14](docs/ios14.md)
- [deepLink](docs/deeplink.md)
- [APIs](/docs/api.md)
- [Demo](#demo)- iOS AppsFlyerSDK **v6.14.3**
- Android AppsFlyerSDK **v6.14.0****v6.14.3**
iOS Minimum deployment target: 12 , Android minSdk: 19
**v6.5.4**
Android: deepLinkResult will return an object instead of a string
## Installation
`$ tns plugin add nativescript-plugin-appsflyer`
### Huawei Referrer (Android)
Huawei Referrer is supported in SDK v6.14.0 and above. Due to changes in the Huawei AppGallery store, previous versions of the AppsFlyer SDK are not able to fetch the referrer from the store. Learn more.## Integration
---
Call module by adding (native javascript):
`var appsFlyer = require("nativescript-plugin-appsflyer");`
---
##### **`appsFlyer.initSdk(options, callback): void`**
initializes the SDK.
| parameter | type | description |
| ----------- |-----------------------------|--------------|
| `options` | `Object` | SDK configuration |**`options`**
| name | type | default | description |
| -----------|---------|---------|------------------------|
| `devKey` |`string` | | [Appsflyer Dev key](https://support.appsflyer.com/hc/en-us/articles/207032126-AppsFlyer-SDK-Integration-Android) |
| `appId` |`string` | | [Apple Application ID](https://support.appsflyer.com/hc/en-us/articles/207032066-AppsFlyer-SDK-Integration-iOS) (for iOS only) |
| `isDebug` |`boolean`| `false` | debug mode (optional)|
| `onConversionDataSuccess` |`function`| | AppsFlyer allows you to access the user attribution data in real-time for every new install, directly from the SDK level. By doing this you can serve users with personalized content or send them to specific activities within the app, which can greatly enhance their engagement with your app. For [Android](https://support.appsflyer.com/hc/en-us/articles/207032126-AppsFlyer-SDK-Integration-Android#7-get-conversion-data); for [iOS](https://support.appsflyer.com/hc/en-us/articles/207032066-AppsFlyer-SDK-Integration-iOS#7-get-conversion-data) |
| `onConversionDataFailure` |`function`| | |*Example:*
```javascript
var options = {
devKey: 'WdpTVAcYwmxsaQ4WeTspmh',
appId: "975313579",
isDebug: true,
timeToWaitForATTUserAuthorization: 60,
onConversionDataSuccess: function(_res){
console.log(JSON.stringify(_res));
},
onConversionDataFailure: function(_res){
console.warn("failure: " + JSON.stringify(_res));
},
};appsFlyer.initSdk(options).then(function(result) {
viewModel.set("initSdkResponse", result.status);
}, function(err) {
viewModel.set("initSdkResponse", JSON.stringify(err));
});
```---
##### **`appsFlyer.logEvent(options): Promise`**
- These in-app events help you measure how loyal users discover your app, and attribute them to specific
campaigns/media-sources. Please take the time define the event/s you want to measure to allow you
to measure the ROI (Return on Investment) and LTV (Lifetime Value).
- The `logEvent` method allows you to send in-app events to AppsFlyer analytics. This method allows you to add events dynamically by adding them directly to the application code.| parameter | type | description |
| ----------- |-----------------------------|--------------|
| `options` | `Object` | log event configuration |**`options`**
| parameter | type | description |
| ----------- |-----------------------------|--------------|
| `eventName` | `string` | custom event name, is presented in your dashboard. See the Event list [HERE](https://github.com/AppsFlyerSDK/AppsFlyerFramework/blob/master/AppsFlyerLib.framework/Versions/A/Headers/AppsFlyerTracker.h) |
| `eventValues` | `Object` | event details (see example bellow) |*Example: (native javascript)*
```javascript
var options = {
eventName: "af_add_to_cart",
eventValues: {
"af_content_id": "id123",
"af_currency": "USD",
"af_revenue": "2"
}
};
appsFlyer.logEvent(options).then(function(result) {
viewModel.set("logEventResponse", result);
}, function(err) {
viewModel.set("logEventResponse", JSON.stringify(err));
});
```## Demo
This plugin has a `demo` project bundled with it. To give it a try , clone this repo and from root a.e. `nativescript-plugin-appsflyer` execute the following:
```sh
npm run setup
```- Run `npm run demo.ios` or `npm run demo.android` will run for the appropriate platform.