react-native-as-attribution-sdk-bridge

AS Attribution SDK Bridge

Usage no npm install needed!

<script type="module">
  import reactNativeAsAttributionSdkBridge from 'https://cdn.skypack.dev/react-native-as-attribution-sdk-bridge';
</script>

README

React Native Bridge For AppSamurai Attribution SDK

React Native Bridge For AppSamurai Attribution SDK is a project for React Native applications to use AppSamurai Attribution SDK.

alt text

Getting Started

Add react-native-as-attribution-sdk-bridge to your dependencies with one of the options below(yarn or npm);

yarn add react-native-as-attribution-sdk-bridge
npm install --save react-native-as-attribution-sdk-bridge

Linking library react-native 0.60+ handles autolinking as it mentioned in autolinking in react-native. For react-native 0.60- version auto linking needs to be done to use libraries with native dependencies correctly. Please refer detailed explanation from Linking Libraries in iOS

react-native link react-native-as-attribution-sdk-bridge

iOS Platform Notes

AppSamurai Attribution SDK targets iOS 10 or higher. Projects those use CocoaPods do not forget to run pod install. You need to initialize ASAttributionSDK to use AppSamurai Attribution SDK. First, you need to import ASAttributionSDK module in your AppDelegate file;

@import ASAttributionSDK;

Then you need to add the following initialization line to your application’s didFinishLaunchingWithOptions method in AppDelegate:

[ASAttribution initialize:@"your-user-id"];

"your-user-id" parameter should be your user id retrieved from AppSamurai User Dashboard, you can use your user id for integration purposes.

Android Platform Notes

Minimum supported SDK version is 14. Please make sure that you are using the latest version of gradle and gradle android plugin. You need to add multidex support to Android project. You can do this by adding the following line to app’s gradle.

defaultConfig {
    ....
    multiDexEnabled true
    ...
}

Add the following dependency to the dependencies block in app/build.gradle. Be sure to add the latest release for attribution sdk which is: Download

implementation 'com.ppsmr.attribution.attributionsdk:attribution:<latest-version>'

You need to initialize ASAttributionSDK to use AppSamurai Attribution SDK. First, you need to import AttributionSDK module in your MainApplication file;

import com.ppsmr.attribution.attributionsdk.AttributionSDK;

Then you need to add the following initialization line to your application’s onCreate method in MainApplication file:

@Override
public void onCreate() {
    super.onCreate();
    SoLoader.init(this, /* native exopackage */ false);
    AttributionSDK.Instance.initialize("your-user-id");
}

"your-user-id" parameter should be your user id retrieved from AppSamurai User Dashboard, you can use your user id for integration purposes.

For Publishers Supporting Android API Level < 21

If your minSdkVersion is set to 20 or lower and when multidex is enabled you need to do additional changes. Please import MultiDexApplication package instead of Application package in your MainApplication file.

import androidx.multidex.MultiDexApplication;

Then extend your MainApplication class with MultiDexApplication instead of Application class:

public class MainApplication extends MultiDexApplication implements ReactApplication {
    ...
}

If the previous solution does not fit for you, you can apply another solution from https://developer.android.com/studio/build/multidex.html#mdex-gradle.

Add the following multidex dependency to the dependencies block in app/build.gradle. Be sure to add the latest release for multidex library. If you are not using AndroidX, please use the following dependency:

implementation 'com.android.support:multidex:1.0.3'

If you are using AndroidX, use the following dependency instead of the previous one:

implementation 'androidx.multidex:multidex:2.0.1'

Usage in React-Native

Import the module

import AsAttributionSdkBridge from 'react-native-as-attribution-sdk-bridge';

Custom Event Tracking

Using AppSamurai Attribution SDK, you are able to track the frequency of custom events by placing the following code piece into your own application code. You can also attach data to your events. If you are planning to attach data to your event, make sure your map is JSON serializable.

AsAttributionSdkBridge.track("string-event-name")
AsAttributionSdkBridge.trackWithData("string-event-name", map<String:"<JSON Serializable Object>">)

Examples:

// Track event with no event data
AsAttributionSdkBridge.track("user-login")

// Track event with data
var dataMap = {
    "type": "water-bottle",
    "amount": 40.0,
    "currency": "dollar",
    "properties": {
        "color": "blue",
        "size": "L"
    },
    "last-product-views": ["Bags", "Shorts", "Bottles"]
}
AsAttributionSdkBridge.trackWithData("purchase", dataMap)

Log Level

AppSamurai SDK logging level can be changed with setLogLevel after SDK initialization. Available log levels are "OFF", "DEBUG", "WARNING" and "ERROR". Default log level is "DEBUG".

AsAttributionSdkBridge.setLogLevel("string-log-level")

Author

App Samurai Mobile Team, mobile@appsamurai.com

License

Copyright 2018 App Samurai Inc. alt text