diff --git a/.gitignore b/.gitignore
index b30abbc3..a8136797 100755
--- a/.gitignore
+++ b/.gitignore
@@ -92,3 +92,4 @@ atlassian-ide-plugin.xml
# exceptions
!*adjust-android.jar
+!android/libs/adjust*.jar
diff --git a/.npmignore b/.npmignore
index b41b2dbc..c7edc4bf 100644
--- a/.npmignore
+++ b/.npmignore
@@ -10,3 +10,7 @@ node_modules
/ios/**/*xcuserdata*
/ios/**/*xcshareddata*
+# Adjust SDK
+ext/
+scripts/
+example/
diff --git a/CHANGELOG.md b/CHANGELOG.md
new file mode 100644
index 00000000..42f9c70f
--- /dev/null
+++ b/CHANGELOG.md
@@ -0,0 +1,11 @@
+### Version 4.10.0 (1st December 2016)
+#### Added
+- Initial release of the adjust SDK for React Native.
+
+#### Native SDKs
+- [iOS@v4.10.3][ios_sdk_v4.10.3]
+- [Android@v4.10.4][android_sdk_v4.10.4]
+
+[ios_sdk_v4.10.3]: https://github.com/adjust/ios_sdk/tree/v4.10.3
+
+[android_sdk_v4.10.4]: https://github.com/adjust/android_sdk/tree/v4.10.4
diff --git a/README.md b/README.md
index 8be4a56a..04cd8b77 100644
--- a/README.md
+++ b/README.md
@@ -4,18 +4,19 @@ This is the React Native SDK of adjust™. You can read more about adjust™ at
## Table of contents
+* [Supported versions](#supported-versions)
* [Example app](#example-app)
* [Basic integration](#basic-integration)
* [Get the SDK](#sdk-get)
- * [Add the SDK to your project](#sdk-add)
* [Integrate the SDK into your app](#sdk-integrate)
* [Adjust logging](#adjust-logging)
- * [Google Play Services](#google-play-services)
+ * [Add Google Play Services](#sdk-gps)
+ * [Add permissions](#sdk-permissions)
+ * [Proguard settings](#sdk-proguard)
* [Additional features](#additional-features)
* [Event tracking](#event-tracking)
* [Revenue tracking](#revenue-tracking)
* [Revenue deduplication](#revenue-deduplication)
- * [In-App Purchase verification](#iap-verification)
* [Callback parameters](#callback-parameters)
* [Partner parameters](#partner-parameters)
* [Session parameters](#session-parameters)
@@ -28,46 +29,48 @@ This is the React Native SDK of adjust™. You can read more about adjust™ at
* [Offline mode](#offline-mode)
* [Event buffering](#event-buffering)
* [Background tracking](#background-tracking)
- * [Device IDs](#device-ids)
* [Push token](#push-token)
* [Pre-installed trackers](#pre-installed-trackers)
* [Deep linking](#deeplinking)
- * [Deep linking](#deeplinking-standard)
+ * [Standard deep linking scenario](#deeplinking-standard)
* [Deferred deep linking scenario](#deeplinking-deferred)
* [Reattribution via deep links](#deeplinking-reattribution)
* [License](#license)
-## Supported versions
+## Supported versions
- react-native-cli: 1.2.0
- react-native: 0.37.0
-## Example apps
+## Example app
-There is an example app inside the [`examples` directory][example]
+There is an example app inside the [`example` directory][example]
## Basic integration
-We will describe the steps to integrate the adjust SDK into your React Native project. You can use any text editor or IDE for React Native development. There are no assumptions made regarding text editors.
+We will describe the steps to integrate the adjust SDK into your React Native project. You can use any text editor or IDE
+for React Native development. There are no assumptions made regarding development environment.
### Get the SDK
-First, download the library from npm:
+First, download the library from `npm`:
```
$ npm install react-native-adjust --save
```
-Then you must install the native dependencies: You can use rnpm (now part of react-native core) to add native dependencies automatically then continue the directions below depending on your target OS.
+Then you must install the native dependencies. You can use `react-native` cli tool to add native dependencies automatically
+and then continue the directions below depending on your target OS.
```
$ react-native link
```
-for **iOS**, you don't need to do much of anything else.
+For **iOS**, you don't need to do anything else.
-for **Android**, you need to include the native module's package manually.
+For **Android**, you need to include the native module's package manually.
-- Go to your app's `MainApplication.java` class. It should be located in `./android/app/src/main/java/[your app]/MainApplication.java`
+- Go to your app's `MainApplication.java` class. It should be located in
+`./android/app/src/main/java/[your app]/MainApplication.java`
- There is a method called `getPackages()` that looks like this by default:
```java
@Override
@@ -77,7 +80,7 @@ protected List getPackages() {
);
}
```
-- You'l have to add `new AdjustPackage()` to the list of packages like this:
+- You'll have to add the `new AdjustPackage()` to the list of packages like this:
```java
@Override
protected List getPackages() {
@@ -87,7 +90,7 @@ protected List getPackages() {
);
}
```
-- Also, don't forget to add the import statement on top of the `MainApplication.java` file:
+- Also, don't forget to add the import statement on top of the `MainApplication.java` file:
```
import com.adjust.nativemodule.AdjustPackage;
```
@@ -109,23 +112,26 @@ componentWillMount() {
}
```
-Replace `{YourAppToken}` with your app token. You can find this in your dashboard.
+Replace `{YourAppToken}` with your app token. You can find this in your adjust dashboard.
-Depending on whether you build your app for testing or for production, you must set environment with one of these values:
+Depending on whether you build your app for testing or for production, you must set the environment with one of these values:
```
AdjustConfig.EnvironmentSandbox
AdjustConfig.EnvironmentProduction
```
-**Important**: This value should be set to `AdjustConfig.EnvironmentSandbox` if and only if you or someone else is testing your app. Make sure to set the environment to `AdjustConfig.EnvironmentProduction` just before you publish the app. Set it back to `AdjustConfig.EnvironmentSandbox` when you start developing and testing it again.
-
-We use this environment to distinguish between real traffic and test traffic from test devices. It is very important that you keep this value meaningful at all times! This is especially important if you are tracking revenue.
+**Important**: This value should be set to `AdjustConfig.EnvironmentSandbox` if and only if you or someone else is testing
+your app. Make sure to set the environment to `AdjustConfig.EnvironmentProduction` just before you publish the app. Set it
+back to `AdjustConfig.EnvironmentSandbox` when you start developing and testing it again.
+We use this environment to distinguish between real traffic and test traffic from test devices. It is very important that
+you keep this value meaningful at all times!
### Adjust logging
-You can increase or decrease the amount of logs you see in tests by calling `setLogLevel` on your `AdjustConfig` instance with one of the following parameters:
+You can increase or decrease the amount of logs you see in tests by calling `setLogLevel` on your `AdjustConfig` instance
+with one of the following parameters:
```js
adjustConfig.setLogLevel(AdjustConfig.LogLevelVerbose); // enable all logging
@@ -137,8 +143,89 @@ adjustConfig.setLogLevel(AdjustConfig.LogLevelAssert); // disable errors as w
adjustConfig.setLogLevel(AdjustConfig.LogLevelSuppress); // disable all logging
```
-### Google Play Services
+### Add Google Play Services
+
+Please refer to our Android SDK README page
+
+Since the 1st of August of 2014, apps in the Google Play Store must use the [Google Advertising ID][google-ad-id] to
+uniquely identify devices. To allow the adjust SDK to use the Google Advertising ID, you must integrate the
+[Google Play Services][google-play-services]. If you haven't done this yet, follow these steps:
+
+1. Open your app's `build.gradle` file of your app and find the `dependencies` block. Add the following line:
+
+ ```
+ compile 'com.google.android.gms:play-services-analytics:9.8.0'
+ ```
+
+### Add permissions
+
+The adjust SDK by default adds two permissions to your app's `AndroidManifest.xml` file:
+
+```xml
+
+
+```
+
+General rule of thumb is that if you are targeting the Google Play Store and using Google Play Services in your app, then we just
+need `INTERNET` permission:
+
+```xml
+
+```
+
+If you are **not targeting the Google Play Store**, both of these permissions are needed to be present in your app's
+`AndroidManifest.xml` file:
+
+```xml
+
+
+```
+### Proguard settings
+
+If you are using Proguard, add these lines to your Proguard file:
+
+```
+-keepclassmembers enum * {
+ public static **[] values();
+ public static ** valueOf(java.lang.String);
+}
+-keep class com.adjust.sdk.plugin.MacAddressUtil {
+ java.lang.String getMacAddress(android.content.Context);
+}
+-keep class com.adjust.sdk.plugin.AndroidIdUtil {
+ java.lang.String getAndroidId(android.content.Context);
+}
+-keep class com.google.android.gms.common.ConnectionResult {
+ int SUCCESS;
+}
+-keep class com.google.android.gms.ads.identifier.AdvertisingIdClient {
+ com.google.android.gms.ads.identifier.AdvertisingIdClient$Info getAdvertisingIdInfo(android.content.Context);
+}
+-keep class com.google.android.gms.ads.identifier.AdvertisingIdClient$Info {
+ java.lang.String getId();
+ boolean isLimitAdTrackingEnabled();
+}
+-keep class android.os.Build {
+ java.lang.String[] SUPPORTED_ABIS;
+ java.lang.String CPU_ABI;
+}
+-keep class android.content.res.Configuration {
+ android.os.LocaledList getLocales();
+ java.util.Locale locale;
+}
+-keep class android.os.LocaledList {
+ java.util.Locale get(int);
+}
+```
+
+If you are **not targeting the Google Play Store**, you can remove the `com.google.android.gms` rules.
+
+**Important**: If you are using an `-overloadaggressively` flag in your Proguard file, then in order for the adjust SDK to
+work properly you should consider one of two possible scenarios:
+
+* Remove `-overloadaggressively` if it is not necessary
+* Add a `-useuniqueclassmembernames` flag to your Proguard file
## Additional features
@@ -146,7 +233,9 @@ You can take advantage of the following features once the adjust SDK is integrat
### Event tracking
-You can use adjust to track all kinds of events. Let's say you want to track every tap on a button. Simply create a new event token in your [dashboard]. Let's say that event token is `abc123`. You can add the following line in your button’s click handler method to track the click:
+You can use adjust to track all kinds of events. Let's say you want to track every tap on a button. Simply create a new
+event token in your [dashboard]. Let's say that event token is `abc123`. You can add the following line in your button’s
+click handler method to track the click:
```js
var adjustEvent = new AdjustEvent("abc123");
@@ -155,8 +244,8 @@ Adjust.trackEvent(adjustEvent);
### Revenue tracking
-If your users can generate revenue by tapping on advertisements or making In-App Purchases, then you can track those revenues
-with events. Let's say a tap is worth €0.01. You could track the revenue event like this:
+If your users can generate revenue by tapping on advertisements or making In-App Purchases, then you can track those
+revenues with events. Let's say a tap is worth €0.01. You could track the revenue event like this:
```js
var adjustEvent = new AdjustEvent("abc123");
@@ -166,18 +255,17 @@ adjustEvent.setRevenue(0.01, "EUR");
Adjust.trackEvent(adjustEvent);
```
-When you set a currency token, adjust will automatically convert the incoming revenues into a reporting revenue of your
+When you set a currency token, adjust will automatically convert the incoming revenues into a reporting revenue of your
choice. Read more about [currency conversion here][currency-conversion].
-
### Revenue deduplication
-You can also add an optional transaction ID to avoid tracking duplicate revenues. The last ten transaction IDs are remembered,
-and revenue events with duplicate transaction IDs are skipped. This is especially useful for In-App Purchase tracking. You can
-see an example below.
+You can also add an optional transaction ID to avoid tracking duplicate revenues. The last ten transaction IDs are
+remembered, and revenue events with duplicate transaction IDs are skipped. This is especially useful for In-App Purchase
+tracking. You can see an example below.
-If you want to track in-app purchases, please make sure to call the `trackEvent` only if the transaction is finished and an item
-is purchased. That way you can avoid tracking revenue that is not actually being generated.
+If you want to track in-app purchases, please make sure to call the `trackEvent` only if the transaction is finished and an
+item is purchased. That way you can avoid tracking revenue that is not actually being generated.
```js
var adjustEvent = new AdjustEvent("abc123");
@@ -188,16 +276,16 @@ adjustEvent.setTransactionId("{YourTransactionId}");
Adjust.trackEvent(adjustEvent);
```
-**Note**: Transaction ID is the iOS term, unique identifier for successfully finished Android In-App-Purchases is named **Order ID**.
-
-### In-App Purchase verification
+**Note**: Transaction ID is the iOS term, unique identifier for successfully finished Android In-App-Purchases is named
+**Order ID**.
### Callback parameters
-You can also register a callback URL for that event in your [dashboard][dashboard] and we will send a GET request to that URL
-whenever the event gets tracked. In that case you can also put some key-value pairs in an object and pass it to the `trackEvent` method. We will then append these named parameters to your callback URL.
+You can also register a callback URL for that event in your [dashboard][dashboard] and we will send a GET request to that URL whenever the event gets tracked. In that case you can also put some key-value pairs in an object and pass it to the
+`trackEvent` method. We will then append these named parameters to your callback URL.
-For example, suppose you have registered the URL `http://www.adjust.com/callback` for your event with event token `abc123` and execute the following lines:
+For example, suppose you have registered the URL `http://www.adjust.com/callback` for your event with event token `abc123`
+and execute the following lines:
```js
var adjustEvent = new AdjustEvent("abc123");
@@ -214,22 +302,22 @@ In that case we would track the event and send a request to:
http://www.adjust.com/callback?key=value&foo=bar
```
-It should be mentioned that we support a variety of placeholders like `{idfa}` for iOS or `{gps_adid}` for Android that can be
-used as parameter values. In the resulting callback the `{idfa}` placeholder would be replaced with the ID for Advertisers of
-the current device for iOS and the `{gps_adid}` would be replaced with the Google Advertising ID of the current device for
-Android. Also note that we don't store any of your custom parameters, but only append them to your callbacks. If you haven't
-registered a callback for an event, these parameters won't even be read.
+It should be mentioned that we support a variety of placeholders like `{idfa}` for iOS or `{gps_adid}` for Android that can
+be used as parameter values. In the resulting callback the `{idfa}` placeholder would be replaced with the ID for
+Advertisers of the current device for iOS and the `{gps_adid}` would be replaced with the Google Advertising ID of the
+current device for Android. Also note that we don't store any of your custom parameters, but only append them to your
+callbacks. If you haven't registered a callback for an event, these parameters won't even be read.
-You can read more about using URL callbacks, including a full list of available values, in our
+You can read more about using URL callbacks, including a full list of available values, in our
[callbacks guide][callbacks-guide].
### Partner parameters
-Similarly to the callback parameters mentioned above, you can also add parameters that adjust will transmit to the network
+Similarly to the callback parameters mentioned above, you can also add parameters that adjust will transmit to the network
partners of your choice. You can activate these networks in your adjust dashboard.
-This works similarly to the callback parameters mentioned above, but can be added by calling the `addPartnerParameter` method
-on your `AdjustEvent` instance.
+This works similarly to the callback parameters mentioned above, but can be added by calling the `addPartnerParameter`
+method on your `AdjustEvent` instance.
```js
var adjustEvent = new AdjustEvent("abc123");
@@ -249,8 +337,8 @@ parameters, you don't need to add them every time, since they will be saved loca
there will be no effect.
These session parameters can be called before the adjust SDK is launched to make sure they are sent even on install. If you
-need to send them with an install, but can only obtain the needed values after launch, it's possible to [delay](#delay-start)
-the first launch of the adjust SDK to allow this behaviour.
+need to send them with an install, but can only obtain the needed values after launch, it's possible to
+[delay](#delay-start) the first launch of the adjust SDK to allow this behaviour.
### Session callback parameters
@@ -264,11 +352,11 @@ its value to an event, it's added through a call to method `addSessionCallbackPa
Adjust.addSessionCallbackParameter("foo", "bar");
```
-The session callback parameters will be merged with the callback parameters added to an event. The callback parameters added
-to an event have precedence over the session callback parameters. Meaning that, when adding a callback parameter to an event
+The session callback parameters will be merged with the callback parameters and added to an event. The callback parameters added
+to an event have precedence over the session callback parameters. Meaning that, when adding a callback parameter to an event
with the same key to one added from the session, the value that prevails is the callback parameter added to the event.
-It's possible to remove a specific session callback parameter by passing the desiring key to the method
+It's possible to remove a specific session callback parameter by passing the desiring key to the method
`removeSessionCallbackParameter` of the `Adjust` instance:
```js
@@ -296,8 +384,8 @@ value to an event, it's added through a call to method `addSessionPartnerParamet
Adjust.addSessionPartnerParameter("foo", "bar");
```
-The session partner parameters will be merged with the partner parameters added to an event. The partner parameters added to
-an event have precedence over the session partner parameters. Meaning that, when adding a partner parameter to an event with
+The session partner parameters will be merged with the partner parameters and added to an event. The partner parameters added to
+an event have precedence over the session partner parameters. Meaning that, when adding a partner parameter to an event with
the same key to one added from the session, the value that prevails is the partner parameter added to the event.
It's possible to remove a specific session partner parameter by passing the desiring key to the method
@@ -325,16 +413,16 @@ Set the initial delay time in seconds with the `setDelayStart` field of the `Adj
adjustConfig.setDelayStart(5.5);
```
-In this case this will make the adjust SDK not send the initial install session and any event created for 5.5 seconds. After
-this time is expired or if you call `sendFirstPackages()` of the `Adjust` instance in the meanwhile, every session parameter
+In this case this will make the adjust SDK not send the initial install session and any event created for 5.5 seconds. After
+this time is expired or if you call `sendFirstPackages()` of the `Adjust` instance in the meanwhile, every session parameter
will be added to the delayed install session and events and the adjust SDK will resume as usual.
**The maximum delay start time of the adjust SDK is 10 seconds**.
### Attribution callback
-You can register a listener to be notified of tracker attribution changes. Due to the different sources considered for
-attribution, this information cannot by provided synchronously. The simplest way is to create a single anonymous listener
+You can register a listener to be notified of tracker attribution changes. Due to the different sources considered for
+attribution, this information cannot be provided synchronously. The simplest way is to create a single anonymous listener
which is going to be called **each time your user's attribution value changes**:
With the `AdjustConfig` instance, before starting the SDK, add the anonymous listener:
@@ -373,7 +461,7 @@ Please make sure to consider our [applicable attribution data policies][attribut
You can register a callback to be notified of successful and failed tracked events and/or sessions.
-Follow the same steps as for attribution callback to implement the following callback function for successfully tracked
+Follow the same steps as for attribution callback to implement the following callback function for successfully tracked
events:
```js
@@ -446,8 +534,9 @@ adjustConfig.setSessionTrackingFailedCallbackListener(function(sessionFailure) {
Adjust.create(adjustConfig);
```
-The callback functions will be called after the SDK tries to send a package to the server. Within the callback you have access
-to a response data object specifically for the callback. Here is a quick summary of the session response data properties:
+The callback functions will be called after the SDK tries to send a package to the server. Within the callback you have
+access to a response data object specifically for the callback. Here is a quick summary of the session response data
+properties:
- `var message` the message from the server or the error logged by the SDK.
- `var timestamp` timestamp from the server.
@@ -464,21 +553,21 @@ And both event and session failed objects also contain:
### Disable tracking
-You can disable the adjust SDK from tracking by invoking the method `setEnabled` of the `Adjust` instance with the enabled
+You can disable the adjust SDK from tracking by invoking the method `setEnabled` of the `Adjust` instance with the enabled
parameter as `false`. This setting is **remembered between sessions**, but it can only be activated after the first session.
```js
Adjust.setEnabled(false);
```
-You can verify if the adjust SDK is currently active with the method `isEnabled` of the `Adjust` instance. It is always
+You can verify if the adjust SDK is currently active with the method `isEnabled` of the `Adjust` instance. It is always
possible to activate the adjust SDK by invoking `setEnabled` with the parameter set to `true`.
### Offline mode
-You can put the adjust SDK in offline mode to suspend transmission to our servers while retaining tracked data to be sent
-later. When in offline mode, all information is saved in a file, so be careful not to trigger too many events while in offline
-mode.
+You can put the adjust SDK in offline mode to suspend transmission to our servers while retaining tracked data to be sent
+later. When in offline mode, all information is saved in a file, so be careful not to trigger too many events while in
+offline mode.
You can activate offline mode by calling the method `setOfflineMode` of the `Adjust` instance with the parameter `true`.
@@ -486,7 +575,7 @@ You can activate offline mode by calling the method `setOfflineMode` of the `Adj
Adjust.setOfflineMode(true);
```
-Conversely, you can deactivate offline mode by calling `setOfflineMode` with `false`. When the adjust SDK is put back in
+Conversely, you can deactivate offline mode by calling `setOfflineMode` with `false`. When the adjust SDK is put back in
online mode, all saved information is send to our servers with the correct time information.
Unlike disabling tracking, **this setting is not remembered** between sessions. This means that the SDK is in online mode
@@ -494,7 +583,7 @@ whenever it is started, even if the app was terminated in offline mode.
### Event buffering
-If your app makes heavy use of event tracking, you might want to delay some HTTP requests in order to send them in one batch
+If your app makes heavy use of event tracking, you might want to delay some HTTP requests in order to send them in one batch
every minute. You can enable event buffering with your `AdjustConfig` instance by calling `setEventBufferingEnabled` method:
```js
@@ -507,7 +596,7 @@ Adjust.create(adjustConfig);
### Background tracking
-The default behaviour of the adjust SDK is to **pause sending HTTP requests while the app is in the background**. You can
+The default behaviour of the adjust SDK is to **pause sending HTTP requests while the app is in the background**. You can
change this in your `AdjustConfig` instance by calling `setSendInBackground` method:
```js
@@ -520,37 +609,9 @@ Adjust.create(adjustConfig);
If nothing is set, sending in background is **disabled by default**.
-### Device IDs
-
-Certain services (such as Google Analytics) require you to coordinate Device and Client IDs in order to prevent duplicate
-reporting.
-
-### Android
-
-If you need to obtain the Google Advertising ID, you can call the function `getGoogleAdId`. To get it in the callback method
-you pass to the call:
-
-```js
-Adjust.getGoogleAdId(function(googleAdId) {
- // Use googleAdId value.
-});
-```
-
-Inside the callback method you will have access to the Google Advertising ID as the variable `googleAdId`.
-
-### iOS
-
-To obtain the IDFA, call the function `getIdfa` in the same way as the method `getGoogleAdId`:
-
-```js
-Adjust.getIdfa(function(idfa) {
- // Use idfa value.
-});
-```
-
### Push token
-To send us the push notification token, add the following call to Adjust **whenever you get your token in the app or
+To send us the push notification token, add the following call to Adjust **whenever you get your token in the app or
when it gets updated**:
```js
@@ -568,11 +629,11 @@ If you want to use the adjust SDK to recognize users that found your app pre-ins
var adjustConfig = new AdjustConfig(appToken, environment);
adjustConfig.setDefaultTracker("{TrackerToken}");
-
+
Adjust.create(adjustConfig);
```
- Replace `{TrackerToken}` with the tracker token you created in step 2. Please note that the dashboard displays a tracker
+ Replace `{TrackerToken}` with the tracker token you created in step 2. Please note that the dashboard displays a tracker
URL (including `http://app.adjust.com/`). In your source code, you should specify only the six-character token and not the
entire URL.
@@ -582,45 +643,32 @@ If you want to use the adjust SDK to recognize users that found your app pre-ins
Default tracker: 'abc123'
```
-### Deep linking
+### Deep linking
-To support deep linking in Android, the app's `AndroidManifest.xml` file will need to be modified. Please refer to this [page of our Android SDK][android-sdk-deeplink] for the needed modifications to `AndroidManifest.xml`.
+If you are using the adjust tracker URL with an option to deep link into your app from the URL, there is the possibility to
+get info about the deep link URL and its content. Hitting the URL can happen when the user has your app already installed
+(standard deep linking scenario) or if they don't have the app on their device (deferred deep linking scenario).
-To support deep linking in iOS, the app's `info.plist` file will need to be modified. Please refer to this [page of our iOS SDK][ios-sdk-deeplink] for the needed modifications to `info.plist`.
+### Standard deep linking scenario
-After that, please refer to this page of the [React Native offical docs][rn-linking] for instructions on how to support both platforms. In basic terms, your React component will have to add `Linking` component, as follows:
-```js
-import {
- StyleSheet,
- Platform,
- Text,
- View,
- ToolbarAndroid,
- Linking //This is important
-} from 'react-native';
-```
+To support deep linking in Android, the app's `AndroidManifest.xml` file will need to be modified. Please refer to this
+[page of our Android SDK][android-sdk-deeplink] for the needed modifications to `AndroidManifest.xml`.
-And then on your React component you'll be able to listen to the events on `Linking` as follows:
-```js
-componentDidMount() {
- Linking.addEventListener('url', this._handleOpenURL);
-},
-componentWillUnmount() {
- Linking.removeEventListener('url', this._handleOpenURL);
-},
-_handleOpenURL(event) {
- console.log(event.url);
-}
-```
+To support deep linking in iOS 8 or earlier, the app's `Info.plist` file will need to be modified. Please refer to this
+[page of our iOS SDK][ios-sdk-deeplink-early] for the needed modifications to `Info.plist`.
+
+To support deep linking in iOS 9 or later, your app would have to handle Universal Links. Please refer to this
+[page of our iOS SDK][ios-sdk-deeplink-late] for the needed modifications.
-Please refer to the [React Native offical docs][rn-linking] for the detailed steps.
+After that, refer to this page of the [React Native offical docs][rn-linking] for instructions on how to support both
+platforms and obtain deep link URL in your JavaScript code.
-### Deferred deep linking
+### Deferred deep linking scenario
While deferred deep linking is not supported out of the box on Android and iOS, our adjust SDK makes it possible.
-
-In order to get info about the URL content in a deferred deep linking scenario, you should set a callback method on the
-`AdjustConfig` object which will receive one parameter where the content of the URL will be delivered. You should set this
+
+In order to get info about the URL content in a deferred deep linking scenario, you should set a callback method on the
+`AdjustConfig` object which will receive one parameter where the content of the URL will be delivered. You should set this
method on the config object by calling the method `setDeeplinkCallbackListener`:
```js
@@ -633,8 +681,8 @@ adjustConfig.setDeferredDeeplinkCallbackListener(function(deeplink) {
Adjust.create(adjustConfig);
```
-In deferred deep linking scenario, there is one additional setting which can be set on the `AdjustConfig` object. Once the
-adjust SDK gets the deferred deep link info, we are offering you the possibility to choose whether our SDK should open this
+In the deferred deep linking scenario, there is one additional setting which can be set on the `AdjustConfig` object. Once the
+adjust SDK gets the deferred deep link info, we are offering you the possibility to choose whether our SDK should open this
URL or not. You can choose to set this option by calling the `setShouldLaunchDeeplink` method on the config object:
@@ -655,41 +703,82 @@ If nothing is set, **the adjust SDK will always try to launch the URL by default
### Reattribution via deep links
-Adjust enables you to run re-engagement campaigns by using deep links. For more information on this, please check our
+Adjust enables you to run re-engagement campaigns by using deep links. For more information on this, please check our
[official docs][reattribution-with-deeplinks].
-If you are using this feature, in order for your user to be properly reattributed, you need to make one additional call to the
-adjust SDK in your app.
+If you are using this feature, in order for your user to be properly reattributed, you need to make one additional call to
+the adjust SDK in your app. Once you have received deep link content information in your app, add a call to `appWillOpenUrl`
+method of the `Adjust` instance. By making this call, the adjust SDK will try to find if there is any new attribution info
+inside of the deep link and if any, it will be sent to the adjust backend. If your user should be reattributed due to a
+click on the adjust tracker URL with deep link content in it, you will see the [attribution callback](#attribution-callback)
+in your app being triggered with new attribution info for this user.
+
+Call to the `appWillOpenUrl` method in a React component for **Android** would look like this:
-Once you have received deep link content information in your app, add a call to `appWillOpenUrl` method of the `Adjust`
-instance. By making this call, the adjust SDK will try to find if there is any new attribution info inside of the deep link
-and if any, it will be sent to the adjust backend. If your user should be reattributed due to a click on the adjust tracker
-URL with deep link content in it, you will see the [attribution callback](#attribution-callback) in your app being triggered
-with new attribution info for this user.
+```js
+componentDidMount() {
+ const url = Linking.getInitialURL().then(url => {
+ if (url) {
+ Adjust.appWillOpenUrl(url);
+ }
+ });
+}
+```
-Call to the `appWillOpenUrl` method in a React component would look like this:
+And like the following for **iOS**:
```js
componentDidMount() {
Linking.addEventListener('url', this._handleOpenURL);
-},
+}
+
componentWillUnmount() {
Linking.removeEventListener('url', this._handleOpenURL);
-},
-_handleOpenURL(event) {
- console.log(event.url);
+}
+_handleOpenURL(event) {
Adjust.appWillOpenUrl(event.url);
}
```
+**Warning:** There is a bug in version 1.2.0 of React Native where deep link URL delivery to JavaScript only works if the
+app is opened in the background already. If the app is closed and not running in the background, opening it by click on an
+universal link **will not deliver universal link URL info to your callback method in JavaScript**. This will also cause the
+call to `Adjust.appWillOpenUrl` to not be made, and if reattribution for this user should have happened, it won't.
+
+If you are following the [React Native official linking docs][rn-linking] for iOS, you will encounter this issue.
+
+As a quick fix, you can bypass the JavaScript layer and add a call to our SDK directly in your `AppDelegate.m`. It would
+look like this:
+
+```objc
+#include "Adjust.h"
+
+// ...
+
+- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation {
+ [Adjust appWillOpenUrl:url];
+
+ return YES;
+}
+
+- (BOOL)application:(UIApplication *)application continueUserActivity:(NSUserActivity *)userActivity restorationHandler:(void (^)(NSArray *restorableObjects))restorationHandler {
+ if ([[userActivity activityType] isEqualToString:NSUserActivityTypeBrowsingWeb]) {
+ [Adjust appWillOpenUrl:[userActivity webpageURL]];
+ }
+
+ return YES;
+}
+```
+
[dashboard]: http://adjust.com
[adjust.com]: http://adjust.com
-[example]: http://github.com/adjust/ios_sdk/tree/master/examples
+[example]: ./example
[npm-repo]: https://www.npmjs.com/package/react-native-adjust
-[google-ad-id]: https://developer.android.com/google/play-services/id.html
+[rn-linking]: https://facebook.github.io/react-native/docs/linking.html
+[google-ad-id]: https://support.google.com/googleplay/android-developer/answer/6048248?hl=en
[enable-ulinks]: https://github.com/adjust/ios_sdk#deeplinking-setup-new
[event-tracking]: https://docs.adjust.com/en/event-tracking
[callbacks-guide]: https://docs.adjust.com/en/callbacks
@@ -699,16 +788,18 @@ _handleOpenURL(event) {
[google-launch-modes]: http://developer.android.com/guide/topics/manifest/activity-element.html#lmode
[currency-conversion]: https://docs.adjust.com/en/event-tracking/#tracking-purchases-in-different-currencies
[google-play-services]: http://developer.android.com/google/play-services/index.html
+[android-sdk-deeplink]: https://github.com/adjust/android_sdk#deeplinking-standard
+[google-play-services]: http://developer.android.com/google/play-services/setup.html
+[ios-sdk-deeplink-late]: https://github.com/adjust/ios_sdk#-deep-linking-on-ios-9-and-later
+[ios-sdk-deeplink-early]: https://github.com/adjust/ios_sdk#-deep-linking-on-ios-8-and-earlier
-[android-sdk-deeplink]: https://github.com/adjust/android_sdk#deeplinking-standard
[reattribution-with-deeplinks]: https://docs.adjust.com/en/deeplinking/#manually-appending-attribution-data-to-a-deep-link
-[rn-linking]: https://facebook.github.io/react-native/docs/linking.html
## License
The adjust SDK is licensed under the MIT License.
-Copyright (c) 2012-2016 adjust GmbH,
+Copyright (c) 2012-2016 adjust GmbH,
http://www.adjust.com
Permission is hereby granted, free of charge, to any person obtaining a copy of
diff --git a/android/libs/adjust-4.10.4.jar b/android/libs/adjust-4.10.4.jar
new file mode 100644
index 00000000..b9b15b2c
Binary files /dev/null and b/android/libs/adjust-4.10.4.jar differ
diff --git a/android/src/main/AndroidManifest.xml b/android/src/main/AndroidManifest.xml
old mode 100755
new mode 100644
index 6024e180..92354ea6
--- a/android/src/main/AndroidManifest.xml
+++ b/android/src/main/AndroidManifest.xml
@@ -1,18 +1,15 @@
+
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
diff --git a/android/src/main/java/com/adjust/sdk/Adjust.java b/android/src/main/java/com/adjust/sdk/Adjust.java
index 2645893c..a4856d17 100755
--- a/android/src/main/java/com/adjust/sdk/Adjust.java
+++ b/android/src/main/java/com/adjust/sdk/Adjust.java
@@ -9,18 +9,17 @@
package com.adjust.nativemodule;
-import android.view.Gravity;
-
-import com.facebook.common.logging.FLog;
import com.facebook.react.bridge.*;
import com.facebook.react.modules.core.*;
-import javax.annotation.Nullable;
-import android.util.Log;
-import android.net.Uri;
+
import java.util.Map;
import java.util.HashMap;
import java.util.Map.Entry;
+import android.net.Uri;
+
+import javax.annotation.Nullable;
+
import com.adjust.sdk.*;
public class Adjust extends ReactContextBaseJavaModule
@@ -55,10 +54,7 @@ public void initialize() {
@Override
public void onHostPause() {
- }
-
- @Override
- public void onHostDestroy() {
+ com.adjust.sdk.Adjust.onPause();
}
@Override
@@ -66,6 +62,9 @@ public void onHostResume() {
com.adjust.sdk.Adjust.onResume();
}
+ @Override
+ public void onHostDestroy() {}
+
@Override
public void onAttributionChanged(AdjustAttribution attribution) {
sendEvent(getReactApplicationContext(), "adjust_attribution", AdjustUtil.attributionToMap(attribution));
@@ -112,162 +111,158 @@ public void create(ReadableMap mapConfig) {
double delayStart = 0.0;
boolean isLogLevelSuppress = false;
- //check for isLogLevelSuppress
+ // Check for isLogLevelSuppress.
if (!mapConfig.isNull("logLevel")) {
logLevel = mapConfig.getString("logLevel");
- if(logLevel.equals("SUPPRESS")) {
+ if (logLevel.equals("SUPPRESS")) {
isLogLevelSuppress = true;
}
}
- //check for appToken and environment
+ // Check for appToken and environment.
appToken = mapConfig.getString("appToken");
environment = mapConfig.getString("environment");
- final AdjustConfig adjustConfig
- = new AdjustConfig(
- getReactApplicationContext(),
- appToken,
- environment,
- isLogLevelSuppress);
-
-
- if (adjustConfig.isValid()) {
- // Log level
- if (!mapConfig.isNull("logLevel")) {
- logLevel = mapConfig.getString("logLevel");
-
- if (logLevel.equals("VERBOSE")) {
- adjustConfig.setLogLevel(LogLevel.VERBOSE);
- } else if (logLevel.equals("DEBUG")) {
- adjustConfig.setLogLevel(LogLevel.DEBUG);
- } else if (logLevel.equals("INFO")) {
- adjustConfig.setLogLevel(LogLevel.INFO);
- } else if (logLevel.equals("WARN")) {
- adjustConfig.setLogLevel(LogLevel.WARN);
- } else if (logLevel.equals("ERROR")) {
- adjustConfig.setLogLevel(LogLevel.ERROR);
- } else if (logLevel.equals("ASSERT")) {
- adjustConfig.setLogLevel(LogLevel.ASSERT);
- } else if (logLevel.equals("SUPPRESS")) {
- adjustConfig.setLogLevel(LogLevel.SUPRESS);
- } else {
- adjustConfig.setLogLevel(LogLevel.INFO);
- }
- }
+ final AdjustConfig adjustConfig = new AdjustConfig(getReactApplicationContext(), appToken, environment, isLogLevelSuppress);
- // Event buffering
- if(!mapConfig.isNull("eventBufferingEnabled")) {
- eventBufferingEnabled = mapConfig.getBoolean("eventBufferingEnabled");
- adjustConfig.setEventBufferingEnabled(eventBufferingEnabled);
- }
+ if (!adjustConfig.isValid()) {
+ return;
+ }
- // SDK prefix
- if (!mapConfig.isNull("sdkPrefix")) {
- sdkPrefix = mapConfig.getString("sdkPrefix");
- adjustConfig.setSdkPrefix(sdkPrefix);
- }
+ // Log level
+ if (!mapConfig.isNull("logLevel")) {
+ logLevel = mapConfig.getString("logLevel");
- // Main process name
- if (!mapConfig.isNull("processName")) {
- processName = mapConfig.getString("processName");
- adjustConfig.setProcessName(processName);
+ if (logLevel.equals("VERBOSE")) {
+ adjustConfig.setLogLevel(LogLevel.VERBOSE);
+ } else if (logLevel.equals("DEBUG")) {
+ adjustConfig.setLogLevel(LogLevel.DEBUG);
+ } else if (logLevel.equals("INFO")) {
+ adjustConfig.setLogLevel(LogLevel.INFO);
+ } else if (logLevel.equals("WARN")) {
+ adjustConfig.setLogLevel(LogLevel.WARN);
+ } else if (logLevel.equals("ERROR")) {
+ adjustConfig.setLogLevel(LogLevel.ERROR);
+ } else if (logLevel.equals("ASSERT")) {
+ adjustConfig.setLogLevel(LogLevel.ASSERT);
+ } else if (logLevel.equals("SUPPRESS")) {
+ adjustConfig.setLogLevel(LogLevel.SUPRESS);
+ } else {
+ adjustConfig.setLogLevel(LogLevel.INFO);
}
+ }
- // Default tracker
- if (!mapConfig.isNull("defaultTracker")) {
- defaultTracker = mapConfig.getString("defaultTracker");
- adjustConfig.setDefaultTracker(defaultTracker);
- }
+ // Event buffering
+ if(!mapConfig.isNull("eventBufferingEnabled")) {
+ eventBufferingEnabled = mapConfig.getBoolean("eventBufferingEnabled");
+ adjustConfig.setEventBufferingEnabled(eventBufferingEnabled);
+ }
- // User agent
- if (!mapConfig.isNull("userAgent") ) {
- userAgent = mapConfig.getString("userAgent");
- adjustConfig.setUserAgent(userAgent);
- }
+ // SDK prefix
+ if (!mapConfig.isNull("sdkPrefix")) {
+ sdkPrefix = mapConfig.getString("sdkPrefix");
+ adjustConfig.setSdkPrefix(sdkPrefix);
+ }
- // Background tracking
- if(!mapConfig.isNull("sendInBackground")) {
- sendInBackground = mapConfig.getBoolean("sendInBackground");
- adjustConfig.setSendInBackground(sendInBackground);
- }
+ // Main process name
+ if (!mapConfig.isNull("processName")) {
+ processName = mapConfig.getString("processName");
+ adjustConfig.setProcessName(processName);
+ }
- // Launching deferred deep link
- if(!mapConfig.isNull("shouldLaunchDeeplink")) {
- shouldLaunchDeeplink = mapConfig.getBoolean("shouldLaunchDeeplink");
- this.shouldLaunchDeeplink = shouldLaunchDeeplink;
- }
+ // Default tracker
+ if (!mapConfig.isNull("defaultTracker")) {
+ defaultTracker = mapConfig.getString("defaultTracker");
+ adjustConfig.setDefaultTracker(defaultTracker);
+ }
- // Delayed start
- if(!mapConfig.isNull("delayStart")) {
- delayStart = mapConfig.getDouble("delayStart");
- adjustConfig.setDelayStart(delayStart);
- }
+ // User agent
+ if (!mapConfig.isNull("userAgent") ) {
+ userAgent = mapConfig.getString("userAgent");
+ adjustConfig.setUserAgent(userAgent);
+ }
- // Attribution callback
- if (attributionCallback) {
- adjustConfig.setOnAttributionChangedListener(this);
- }
+ // Background tracking
+ if (!mapConfig.isNull("sendInBackground")) {
+ sendInBackground = mapConfig.getBoolean("sendInBackground");
+ adjustConfig.setSendInBackground(sendInBackground);
+ }
- // Event tracking succeeded callback
- if (eventTrackingSucceededCallback) {
- adjustConfig.setOnEventTrackingSucceededListener(this);
- }
+ // Launching deferred deep link
+ if (!mapConfig.isNull("shouldLaunchDeeplink")) {
+ shouldLaunchDeeplink = mapConfig.getBoolean("shouldLaunchDeeplink");
+ this.shouldLaunchDeeplink = shouldLaunchDeeplink;
+ }
- // Event tracking failed callback
- if (eventTrackingFailedCallback) {
- adjustConfig.setOnEventTrackingFailedListener(this);
- }
+ // Delayed start
+ if (!mapConfig.isNull("delayStart")) {
+ delayStart = mapConfig.getDouble("delayStart");
+ adjustConfig.setDelayStart(delayStart);
+ }
- // Session tracking succeeded callback
- if (sessionTrackingSucceededCallback) {
- adjustConfig.setOnSessionTrackingSucceededListener(this);
- }
+ // Attribution callback
+ if (attributionCallback) {
+ adjustConfig.setOnAttributionChangedListener(this);
+ }
- // Session tracking failed callback
- if (sessionTrackingFailedCallback) {
- adjustConfig.setOnSessionTrackingFailedListener(this);
- }
+ // Event tracking succeeded callback
+ if (eventTrackingSucceededCallback) {
+ adjustConfig.setOnEventTrackingSucceededListener(this);
+ }
- // Deferred deeplink callback listener
- if (deferredDeeplinkCallback) {
- adjustConfig.setOnDeeplinkResponseListener(this);
- }
+ // Event tracking failed callback
+ if (eventTrackingFailedCallback) {
+ adjustConfig.setOnEventTrackingFailedListener(this);
+ }
+
+ // Session tracking succeeded callback
+ if (sessionTrackingSucceededCallback) {
+ adjustConfig.setOnSessionTrackingSucceededListener(this);
+ }
+
+ // Session tracking failed callback
+ if (sessionTrackingFailedCallback) {
+ adjustConfig.setOnSessionTrackingFailedListener(this);
+ }
- com.adjust.sdk.Adjust.onCreate(adjustConfig);
- com.adjust.sdk.Adjust.onResume();
+ // Deferred deeplink callback listener
+ if (deferredDeeplinkCallback) {
+ adjustConfig.setOnDeeplinkResponseListener(this);
}
+
+ com.adjust.sdk.Adjust.onCreate(adjustConfig);
+ com.adjust.sdk.Adjust.onResume();
}
@ReactMethod
public void trackEvent(ReadableMap mapEvent) {
final String eventToken = mapEvent.getString("eventToken");
- final Double revenue = mapEvent.getDouble("revenue");
final String currency = mapEvent.getString("currency");
+ final String transactionId = mapEvent.getString("transactionId");
final Map callbackParameters = AdjustUtil.toMap(mapEvent.getMap("callbackParameters"));
final Map partnerParameters = AdjustUtil.toMap(mapEvent.getMap("partnerParameters"));
AdjustEvent event = new AdjustEvent(eventToken);
- if(event.isValid()) {
- event.setRevenue(revenue, currency);
+
+ if (event.isValid()) {
+ if (!mapEvent.isNull("revenue")) {
+ event.setRevenue(mapEvent.getDouble("revenue"), currency);
+ }
- if(callbackParameters != null) {
+ if (null != callbackParameters) {
for (Map.Entry entry : callbackParameters.entrySet()) {
event.addCallbackParameter(entry.getKey(), entry.getValue().toString());
}
}
- if(partnerParameters != null) {
+ if (null != partnerParameters) {
for (Map.Entry entry : partnerParameters.entrySet()) {
event.addPartnerParameter(entry.getKey(), entry.getValue().toString());
}
}
- if(!mapEvent.isNull("transactionId")) {
- final String transactionId
- = mapEvent.getString("transactionId");
-
+ if (null != transactionId) {
event.setOrderId(transactionId);
}
@@ -371,42 +366,9 @@ public void setDeferredDeeplinkCallbackListener() {
this.deferredDeeplinkCallback = true;
}
- @ReactMethod
- public void clearAttributionCallbackListener() {
- this.attributionCallback = false;
- }
-
- @ReactMethod
- public void clearEventTrackingSucceededCallbackListener() {
- this.eventTrackingSucceededCallback = false;
- }
-
- @ReactMethod
- public void clearEventTrackingFailedCallbackListener() {
- this.eventTrackingFailedCallback = false;
- }
-
- @ReactMethod
- public void clearSessionTrackingSucceededCallbackListener() {
- this.sessionTrackingSucceededCallback = false;
- }
-
- @ReactMethod
- public void clearSessionTrackingFailedCallbackListener() {
- this.sessionTrackingFailedCallback = false;
- }
-
- @ReactMethod
- public void clearDeferredDeeplinkCallbackListener() {
- this.deferredDeeplinkCallback = false;
- }
-
- private void sendEvent(ReactContext reactContext,
- String eventName,
- @Nullable WritableMap params) {
+ private void sendEvent(ReactContext reactContext, String eventName, @Nullable WritableMap params) {
reactContext
.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class)
.emit(eventName, params);
}
-
}
diff --git a/android/src/main/java/com/adjust/sdk/AdjustUtil.java b/android/src/main/java/com/adjust/sdk/AdjustUtil.java
index b8ee20d6..c71f8b19 100644
--- a/android/src/main/java/com/adjust/sdk/AdjustUtil.java
+++ b/android/src/main/java/com/adjust/sdk/AdjustUtil.java
@@ -9,73 +9,121 @@
package com.adjust.nativemodule;
-import com.facebook.react.modules.core.*;
-import com.facebook.react.bridge.*;
-
-import java.util.ArrayList;
+import java.util.Map;
+import java.util.List;
import android.net.Uri;
import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
+import java.util.ArrayList;
+
+import javax.annotation.Nullable;
+
+import com.facebook.react.bridge.*;
+import com.facebook.react.modules.core.*;
+
import com.adjust.sdk.*;
-import javax.annotation.Nullable;
+final class AdjustUtil {
+ private static final String ATTRIBUTION_TRACKER_TOKEN = "trackerToken";
+ private static final String ATTRIBUTION_TRACKER_NAME = "trackerName";
+ private static final String ATTRIBUTION_NETWORK = "network";
+ private static final String ATTRIBUTION_CAMPAIGN = "campaign";
+ private static final String ATTRIBUTION_ADGROUP = "adgroup";
+ private static final String ATTRIBUTION_CREATIVE = "creative";
+ private static final String ATTRIBUTION_CLICK_LABEL = "clickLabel";
+
+ private static final String EVENT_SUCCESS_MESSAGE = "message";
+ private static final String EVENT_SUCCESS_TIMESTAMP = "timestamp";
+ private static final String EVENT_SUCCESS_ADID = "adid";
+ private static final String EVENT_SUCCESS_EVENT_TOKEN = "eventToken";
+ private static final String EVENT_SUCCESS_JSON_RESPONSE = "jsonResponse";
+
+ private static final String EVENT_FAILED_MESSAGE = "message";
+ private static final String EVENT_FAILED_TIMESTAMP = "timestamp";
+ private static final String EVENT_FAILED_ADID = "adid";
+ private static final String EVENT_FAILED_EVENT_TOKEN = "eventToken";
+ private static final String EVENT_FAILED_WILL_RETRY = "willRetry";
+ private static final String EVENT_FAILED_JSON_RESPONSE = "jsonResponse";
+
+ private static final String SESSION_SUCCESS_MESSAGE = "message";
+ private static final String SESSION_SUCCESS_TIMESTAMP = "timestamp";
+ private static final String SESSION_SUCCESS_ADID = "adid";
+ private static final String SESSION_SUCCESS_JSON_RESPONSE = "jsonResponse";
+
+ private static final String SESSION_FAILED_MESSAGE = "message";
+ private static final String SESSION_FAILED_TIMESTAMP = "timestamp";
+ private static final String SESSION_FAILED_ADID = "adid";
+ private static final String SESSION_FAILED_WILL_RETRY = "willRetry";
+ private static final String SESSION_FAILED_JSON_RESPONSE = "jsonResponse";
-/**
- * toMap converts a {@link ReadableMap} into a HashMap.
- *
- * @param readableMap The ReadableMap to be conveted.
- * @return A HashMap containing the data that was in the ReadableMap.
- */
+ public static WritableMap attributionToMap(AdjustAttribution attribution) {
+ WritableMap map = Arguments.createMap();
-final class AdjustUtil {
- /**
- * toObject extracts a value from a {@link ReadableMap} by its key,
- * and returns a POJO representing that object.
- *
- * @param readableMap The Map to containing the value to be converted
- * @param key The key for the value to be converted
- * @return The converted POJO
- */
- public static Object toObject(@Nullable ReadableMap readableMap, String key) {
- if (readableMap == null) {
- return null;
- }
+ map.putString(ATTRIBUTION_TRACKER_TOKEN, null != attribution.trackerToken ? attribution.trackerToken : "");
+ map.putString(ATTRIBUTION_TRACKER_NAME, null != attribution.trackerName ? attribution.trackerName : "");
+ map.putString(ATTRIBUTION_NETWORK, null != attribution.network ? attribution.network : "");
+ map.putString(ATTRIBUTION_CAMPAIGN, null != attribution.campaign ? attribution.campaign : "");
+ map.putString(ATTRIBUTION_ADGROUP, null != attribution.adgroup ? attribution.adgroup : "");
+ map.putString(ATTRIBUTION_CREATIVE, null != attribution.creative ? attribution.creative : "");
+ map.putString(ATTRIBUTION_CLICK_LABEL, null != attribution.clickLabel ? attribution.clickLabel : "");
- Object result;
+ return map;
+ }
- ReadableType readableType = readableMap.getType(key);
- switch (readableType) {
- case Null:
- result = key;
- break;
- case Boolean:
- result = readableMap.getBoolean(key);
- break;
- case Number:
- // Can be int or double.
- double tmp = readableMap.getDouble(key);
- if (tmp == (int) tmp) {
- result = (int) tmp;
- } else {
- result = tmp;
- }
- break;
- case String:
- result = readableMap.getString(key);
- break;
- case Map:
- result = toMap(readableMap.getMap(key));
- break;
- case Array:
- result = toList(readableMap.getArray(key));
- break;
- default:
- throw new IllegalArgumentException("Could not convert object with key: " + key + ".");
- }
+ public static WritableMap eventSuccessToMap(AdjustEventSuccess eventSuccess) {
+ WritableMap map = Arguments.createMap();
- return result;
- }
+ map.putString(EVENT_SUCCESS_MESSAGE, null != eventSuccess.message ? eventSuccess.message : "");
+ map.putString(EVENT_SUCCESS_TIMESTAMP, null != eventSuccess.timestamp ? eventSuccess.timestamp : "");
+ map.putString(EVENT_SUCCESS_ADID, null != eventSuccess.adid ? eventSuccess.adid : "");
+ map.putString(EVENT_SUCCESS_EVENT_TOKEN, null != eventSuccess.eventToken ? eventSuccess.eventToken : "");
+ map.putString(EVENT_SUCCESS_JSON_RESPONSE, null != eventSuccess.jsonResponse ? eventSuccess.jsonResponse.toString() : "");
+
+ return map;
+ }
+
+ public static WritableMap eventFailureToMap(AdjustEventFailure eventFailure) {
+ WritableMap map = Arguments.createMap();
+
+ map.putString(EVENT_FAILED_MESSAGE, null != eventFailure.message ? eventFailure.message : "");
+ map.putString(EVENT_FAILED_TIMESTAMP, null != eventFailure.timestamp ? eventFailure.timestamp : "");
+ map.putString(EVENT_FAILED_ADID, null != eventFailure.adid ? eventFailure.adid : "");
+ map.putString(EVENT_FAILED_EVENT_TOKEN, null != eventFailure.eventToken ? eventFailure.eventToken : "");
+ map.putString(EVENT_FAILED_WILL_RETRY, eventFailure.willRetry ? "true" : "false");
+ map.putString(EVENT_FAILED_JSON_RESPONSE, null != eventFailure.jsonResponse ? eventFailure.jsonResponse.toString() : "");
+
+ return map;
+ }
+
+ public static WritableMap sessionSuccessToMap(AdjustSessionSuccess sessionSuccess) {
+ WritableMap map = Arguments.createMap();
+
+ map.putString(SESSION_SUCCESS_MESSAGE, null != sessionSuccess.message ? sessionSuccess.message : "");
+ map.putString(SESSION_SUCCESS_TIMESTAMP, null != sessionSuccess.timestamp ? sessionSuccess.timestamp : "");
+ map.putString(SESSION_SUCCESS_ADID, null != sessionSuccess.adid ? sessionSuccess.adid : "");
+ map.putString(SESSION_SUCCESS_JSON_RESPONSE, null != sessionSuccess.jsonResponse ? sessionSuccess.jsonResponse.toString() : "");
+
+ return map;
+ }
+
+ public static WritableMap sessionFailureToMap(AdjustSessionFailure sessionFailure) {
+ WritableMap map = Arguments.createMap();
+
+ map.putString(SESSION_FAILED_MESSAGE, null != sessionFailure.message ? sessionFailure.message : "");
+ map.putString(SESSION_FAILED_TIMESTAMP, null != sessionFailure.timestamp ? sessionFailure.timestamp : "");
+ map.putString(SESSION_FAILED_ADID, null != sessionFailure.adid ? sessionFailure.adid : "");
+ map.putString(SESSION_FAILED_WILL_RETRY, sessionFailure.willRetry ? "true" : "false");
+ map.putString(SESSION_FAILED_JSON_RESPONSE, null != sessionFailure.jsonResponse ? sessionFailure.jsonResponse.toString() : "");
+
+ return map;
+ }
+
+ public static WritableMap deferredDeeplinkToMap(Uri uri) {
+ WritableMap map = Arguments.createMap();
+
+ map.putString("uri", uri.toString());
+
+ return map;
+ }
/**
* toMap converts a {@link ReadableMap} into a HashMap.
@@ -86,21 +134,30 @@ public static Object toObject(@Nullable ReadableMap readableMap, String key) {
public static Map toMap(@Nullable ReadableMap readableMap) {
if (readableMap == null) {
return null;
- }
+ }
com.facebook.react.bridge.ReadableMapKeySetIterator iterator = readableMap.keySetIterator();
+
if (!iterator.hasNextKey()) {
return null;
- }
+ }
Map result = new HashMap<>();
+
while (iterator.hasNextKey()) {
String key = iterator.nextKey();
- result.put(key, toObject(readableMap, key));
- }
+ String value = toObject(readableMap, key).toString();
+
+ if (value == null) {
+ AdjustFactory.getLogger().warn("Null parameter inside key-value pair with key: " + key);
+ continue;
+ }
+
+ result.put(key, value);
+ }
return result;
- }
+ }
/**
* toList converts a {@link ReadableArray} into an ArrayList.
@@ -111,14 +168,15 @@ public static Map toMap(@Nullable ReadableMap readableMap) {
public static List