Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

react-native-appsflyer

Package Overview
Dependencies
Maintainers
1
Versions
120
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-native-appsflyer

React Native Appsflyer plugin

  • 1.0.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
74K
increased by7.99%
Maintainers
1
Weekly downloads
 
Created
Source

react-native-appsflyer

This React Natie Library uses the AppsFlyer 4.6.0 library for both iOS and Android

npm version

This plugin is built for

  • iOS AppsFlyerSDK v4.5.9
  • Android AppsFlyerSDK v4.6.0

Installation

$ npm install react-native-appsflyer --save

iOS

  1. Add the appsFlyerFramework to podfile and run pod install.

Example:

use_frameworks!
target 'demo' do
  pod 'AppsFlyerFramework'
end

Don't use CocoaPods? please see their DOCS .

  1. Create bridge between your application and appsFlyerFramework: In XCode ➜ project navigator, right click LibrariesAdd Files to [your project's name] Go to node_modulesreact-native-appsflyer and add RNAppsFlyer.xcodeproj Build your project, It will generate libRNAppsFlyer.a file:

    enter image description here

  2. Run your project (Cmd+R) or through CLI run: react-native run-ios

Android

android/app/build.gradle
  1. Add the project to your dependencies
dependencies {
    ...
    compile project(':react-native-appsflyer')
}
android/settings.gradle
  1. Add the project
include ':react-native-appsflyer'
project(':react-native-appsflyer').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-appsflyer/android')

Build project so you should get following dependency (see an Image):

enter image description here

MainApplication.java

Add:

  1. import com.appsflyer.reactnative.RNAppsFlyerPackage;

  2. In the getPackages() method register the module: new RNAppsFlyerPackage(MainApplication.this)

So getPackages() should look like:

 @Override
    protected List<ReactPackage> getPackages() {
      return Arrays.<ReactPackage>asList(
          new MainReactPackage(),
          new RNAppsFlyerPackage(MainApplication.this),
          //.....
      );
    }

##API Methods


Call module by adding:

import appsFlyer from 'react-native-appsflyer';


appsFlyer.initSdk(options, callback): void

initialize the SDK, returns Object.

parametertypedescription
optionsObjectSDK configuration

options

nametypedefaultdescription
devKeystringAppsflyer Dev key
appIdstringApple Application ID (for iOS only)
isDebugbooleanfalsedebug mode (optional)

Example:

 let options = {
       devKey:  'WdpTVAcYwmxsaQ4WeTspmh',
       appId: "975313579",
       isDebug: true
     };

    appsFlyer.initSdk(options, (error, result) => {
      if (error) {
        console.error(error);
      } else {
       /..
      }
    })

appsFlyer.trackEvent(eventName, eventValues, callback): void

  • These in-app events help you track 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 track ROI (Return on Investment) and LTV (Lifetime Value).
  • The trackEvent 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.
parametertypedescription
eventNameStringcustom event name, is presented in your dashboard. See the Event list HERE
eventValueObjectevent details

Example:


 const eventName = "af_add_to_cart";
 const eventValues = {
      "af_content_id": "id123",
      "af_currency":"USD",
      "af_revenue": "2"
  };

 appsFlyer.trackEvent(eventName, eventValues, (error, result) => {
     if (error) {
         console.error(error);
     } else {
         //...
     }
 })
    

appsFlyer.getAppsFlyerUID(callback): void

Get AppsFlyer’s proprietary Device ID. The AppsFlyer Device ID is the main ID used by AppsFlyer in Reports and APIs.

Example:

 appsFlyer.getAppsFlyerUID((error, appsFlyerUID) => {
      if (error) {
        console.error(error);
      } else {
        console.log("on getAppsFlyerUID: " + appsFlyerUID);
      }
    })

appsFlyer.trackLocation(longitude, latitude, callback(error, coords): void (iOS only)

Get AppsFlyer’s proprietary Device ID. The AppsFlyer Device ID is the main ID used by AppsFlyer in Reports and APIs.

parametertypedescription
errorStringError callback - called on getAppsFlyerUID failure
appsFlyerUIDstringThe AppsFlyer Device ID

Example:


 const  latitude = -18.406655;
 const  longitude = 46.406250;
 
 appsFlyer.trackLocation(longitude, latitude, (error, coords) => {
      if (error) {
        console.error(error);
      } else {
        this.setState( { ...this.state, trackLocation: coords });
      }
    })
})

##Demo

This plugin has a demo project bundled with it. To give it a try , clone this repo and from root a.e. react-native-appsflyer execute the following:

npm run setup
  • Run npm run demo.ios or npm run demo.ios will run for the appropriate platform.
  • Run npm run ios-pod to run Podfile under demo project

demo printscreen

Keywords

FAQs

Package last updated on 14 Nov 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc