Skip to content

Commit

Permalink
Merge pull request #7758 from braze-inc/sdk-untracked-appflyer-integr…
Browse files Browse the repository at this point in the history
…ation

[SDK Untracked] Update Appsflyer integration code snippet
  • Loading branch information
internetisaiah authored Aug 14, 2024
2 parents 71bafd7 + 2d674f2 commit dc0e292
Showing 1 changed file with 29 additions and 43 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,21 +33,22 @@ You can also pass your AppsFlyer audiences (cohorts) directly to Braze with the

### Step 1: Map device ID

#### Android

{% tabs local %}
{% tab Android %}
If you have an Android app, you will need to pass a unique Braze device ID to AppsFlyer.

Make sure the following lines of code are inserted at the correct place—after the Braze SDK is launched and before the initialization code for the AppsFlyer SDK. See the AppsFlyer [Android SDK integration guide](https://dev.appsflyer.com/hc/docs/integrate-android-sdk#initializing-the-android-sdk) for more information.

```java
HashMap<String, Object> customData = new HashMap<String,Object>();
String deviceId =(Braze.getInstance(MyActivity.this).getDeviceId());
customData.put("brazeCustomerId", deviceId);
AppsFlyerLib.setAdditionalData(customData);
```kotlin
val customData = HashMap<String, Any>()
Braze.getInstance(context).getDeviceIdAsync { deviceId ->
customData["brazeCustomerId"] = deviceId
setAdditionalData(customData)
}
```
{% endtab %}

#### iOS

{% tab ios %}
{% alert important %}
Prior to February 2023, our AppsFlyer attribution integration used the IDFV as the primary identifier to match iOS attribution data. It is not necessary for Braze customers using Objective-C to fetch the Braze `device_id` and sent to AppsFlyer upon install as there will be no disruption of service.
{% endalert%}
Expand All @@ -56,58 +57,43 @@ For those using the Swift SDK v5.7.0+, if you wish to continue using IDFV as the

If set to `true`, you must implement the iOS device ID mapping for Swift in order to pass the Braze `device_id` to AppsFlyer upon app install in order for Braze to appropriately match iOS attributions.

{% tabs local %}
{% tab Objective-C %}

```objc
BRZConfiguration *configurations = [[BRZConfiguration alloc] initWithApiKey:@"BRAZE_API_KEY" endpoint:@"BRAZE_END_POINT"];
[configurations setUseUUIDAsDeviceId:NO];
Braze *braze = [[Braze alloc] initWithConfiguration:configurations];
[braze deviceIdWithCompletion:^(NSString * _Nonnull brazeDeviceId) {
NSLog(@">>[BRZ]: %@", brazeDeviceId);
[[AppsFlyerLib shared] setAdditionalData:@{
@"brazeDeviceId": brazeDeviceId
}];
}];
```
{% endtab %}
{% tab Swift %}
{% subtabs local %}
{% subtab Swift %}

##### Swift completion handler
```swift
let configuration = Braze.Configuration(
apiKey: "<BRAZE_API_KEY>",
endpoint: "<BRAZE_ENDPOINT>")
configuration.useUUIDAsDeviceId = false
let braze = Braze(configuration: configuration)
braze.deviceId {
brazeDeviceId in
AppsFlyerLib.shared().customData = ["brazeDeviceId": brazeDeviceId]
}
```
##### Swift await
```swift
let configuration = Braze.Configuration(
apiKey: "<BRAZE_API_KEY>",
endpoint: "<BRAZE_ENDPOINT>")
configuration.useUUIDAsDeviceId = false
let braze = Braze(configuration: configuration)
let brazeDeviceId = await braze.deviceId()
AppsFlyerLib.shared().customData = ["brazeDeviceId": brazeDeviceId]
AppsFlyerLib.shared().customData = ["brazeDeviceId": braze.deviceId]
```
{% endsubtab %}

{% subtab Objective-C %}
```objc
BRZConfiguration *configurations = [[BRZConfiguration alloc] initWithApiKey:@"BRAZE_API_KEY" endpoint:@"BRAZE_END_POINT"];
[configurations setUseUUIDAsDeviceId:NO];
Braze *braze = [[Braze alloc] initWithConfiguration:configurations];
[[AppsFlyerLib shared] setAdditionalData:@{
@"brazeDeviceId": braze.deviceId
}];
```
{% endsubtab %}
{% endsubtabs %}
{% endtab %}
{% endtabs %}
#### Unity
{% tab unity %}
To map the device ID in Unity, use the following:
```
Appboy.AppboyBinding.getDeviceId()
Dictionary<string, string> customData = new Dictionary<string, string>();
customData.Add("brazeCustomerId", Appboy.AppboyBinding.getDeviceId());
AppsFlyer.setAdditionalData(customData);
```
{% endtab %}
{% endtabs %}
### Step 2: Get the Braze data import key
Expand Down

0 comments on commit dc0e292

Please sign in to comment.