SharedPreferences
. To enable the SDK to access this data and include it with every event, follow these steps:AppsFlyerLib.getInstance().enableTCFDataCollection(true)
to instruct the SDK to collect the TCF data from the device.
269 | AppsflyerIntegration.setManualMode(true)
. AppsflyerIntegration.FACTORY
.
271 | Activity
class, use the CMP to decide if you need the consent dialog in the current session.
272 | SharedPreferences
.
274 | AppsflyerIntegration.startAppsFlyer(this)
275 | AppsFlyerIntegration
using manual mode and also Analytics
. This will allow us to delay the Conversion call in order to provide the SDK with the user consent.
328 | Activity
class, determine whether the GDPR applies or not to the user.AppsFlyerConsent
using the forGDPRUser()
method with the following parameters:hasConsentForDataUsage
- Indicates whether the user has consented to use their data for advertising purposes.hasConsentForAdsPersonalization
- Indicates whether the user has consented to use their data for personalized advertising purposes.
339 | AppsFlyerLib.getInstance().setConsentData()
with the AppsFlyerConsent
object.
340 | AppsflyerIntegration.startAppsFlyer(this)
.
341 | AppsFlyerConsent
object using the forNonGDPRUser()
method. This method doesn’t accept any parameters.
345 | AppsFlyerLib.getInstance().setConsentData()
with the AppsFlyerConsent
object.
346 | AppsflyerIntegration.startAppsFlyer(this)
.
347 | AppsFlyer has created a sample Android application that integrates AppsFlyer via Segment. Check it out at the Github repo.
354 | -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.library' 2 | 3 | android { 4 | compileSdk 33 5 | 6 | defaultConfig { 7 | minSdk 19 8 | targetSdk 33 9 | versionCode 1 10 | versionName "1.0" 11 | testApplicationId "com.example.test" 12 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" 13 | } 14 | buildTypes { 15 | release { 16 | minifyEnabled false 17 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 18 | } 19 | } 20 | compileOptions { 21 | sourceCompatibility JavaVersion.VERSION_1_8 22 | targetCompatibility JavaVersion.VERSION_1_8 23 | } 24 | 25 | testOptions { 26 | unitTests { 27 | all { 28 | testLogging { 29 | exceptionFormat = "full" 30 | events "PASSED", "FAILED", "SKIPPED" 31 | } 32 | forkEvery 1 33 | } 34 | includeAndroidResources = true 35 | returnDefaultValues = true 36 | } 37 | } 38 | } 39 | 40 | dependencies { 41 | api 'com.appsflyer:af-android-sdk:6.15.0' 42 | compileOnly 'com.segment.analytics.android:analytics:4.+' 43 | compileOnly 'com.android.installreferrer:installreferrer:2.2' 44 | 45 | testImplementation 'androidx.test:core:1.6.1' 46 | testImplementation 'androidx.test.ext:junit:1.2.1' 47 | testImplementation 'com.android.installreferrer:installreferrer:2.2' 48 | 49 | testImplementation 'junit:junit:4.13.2' 50 | testImplementation 'org.mockito:mockito-core:4.2.0' 51 | testImplementation 'org.robolectric:robolectric:4.9.2' 52 | 53 | testImplementation 'com.segment.analytics.android:analytics:4.+' 54 | testImplementation 'com.segment.analytics.android:analytics-tests:4.+' 55 | } 56 | 57 | tasks.withType(Test) { 58 | testLogging { 59 | exceptionFormat "full" 60 | events "started", "skipped", "passed", "failed" 61 | showStandardStreams true 62 | } 63 | } 64 | 65 | apply from:file("publish.gradle") 66 | -------------------------------------------------------------------------------- /app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in /Users/shacharaharon/Library/Android/sdk/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | -------------------------------------------------------------------------------- /app/publish.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'maven-publish' 2 | apply plugin: 'signing' 3 | 4 | def isReleaseBuild() { 5 | return !VERSION_NAME.contains("SNAPSHOT") 6 | } 7 | 8 | def getReleaseRepositoryUrl() { 9 | return hasProperty('RELEASE_REPOSITORY_URL') ? RELEASE_REPOSITORY_URL 10 | : "https://oss.sonatype.org/service/local/staging/deploy/maven2/" 11 | } 12 | 13 | def getSnapshotRepositoryUrl() { 14 | return hasProperty('SNAPSHOT_REPOSITORY_URL') ? SNAPSHOT_REPOSITORY_URL 15 | : "https://oss.sonatype.org/content/repositories/snapshots/" 16 | } 17 | 18 | task androidJavadocs(type: Javadoc) { 19 | exclude "**/*.orig" // exclude files created by source control 20 | source = android.sourceSets.main.java.srcDirs 21 | classpath += project.files(android.getBootClasspath().join(File.pathSeparator)) 22 | failOnError false 23 | } 24 | 25 | task androidJavadocsJar(type: Jar, dependsOn: androidJavadocs) { 26 | archiveClassifier.set("javadoc") 27 | 28 | from androidJavadocs.destinationDir 29 | } 30 | 31 | task androidSourcesJar(type: Jar) { 32 | archiveClassifier.set("sources") 33 | 34 | from android.sourceSets.main.java.source 35 | } 36 | 37 | def logger(log) { 38 | println log 39 | } 40 | 41 | def configurePom(pom) { 42 | logger("configurePom") 43 | pom.name = POM_NAME 44 | pom.packaging = POM_PACKAGING 45 | pom.description = POM_DESCRIPTION 46 | pom.url = POM_URL 47 | 48 | pom.scm { 49 | url = POM_SCM_URL 50 | connection = POM_SCM_CONNECTION 51 | developerConnection = POM_SCM_DEV_CONNECTION 52 | } 53 | 54 | pom.licenses { 55 | license { 56 | name = POM_LICENCE_NAME 57 | url = POM_LICENCE_URL 58 | distribution = POM_LICENCE_DIST 59 | } 60 | } 61 | 62 | pom.developers { 63 | developer { 64 | id = POM_DEVELOPER_ID 65 | name = POM_DEVELOPER_NAME 66 | } 67 | } 68 | } 69 | 70 | afterEvaluate { 71 | publishing { 72 | publications { 73 | release(MavenPublication) { 74 | logger("release") 75 | // The coordinates of the library, being set from variables that 76 | // we'll set up in a moment 77 | groupId GROUP 78 | artifactId POM_ARTIFACT_ID 79 | version VERSION_NAME 80 | 81 | // Two artifacts, the `aar` and the sources 82 | // artifact("$buildDir/outputs/aar/${project.getName()}-release.aar") 83 | artifact bundleReleaseAar 84 | artifact androidSourcesJar 85 | artifact androidJavadocsJar 86 | 87 | // Self-explanatory metadata for the most part 88 | pom { 89 | configurePom(pom) 90 | // A slight fix so that the generated POM will include any transitive dependencies 91 | // that the library builds upon 92 | withXml { 93 | def dependenciesNode = asNode().appendNode('dependencies') 94 | 95 | project.configurations.implementation.allDependencies.each { 96 | def dependencyNode = dependenciesNode.appendNode('dependency') 97 | dependencyNode.appendNode('groupId', it.group) 98 | dependencyNode.appendNode('artifactId', it.name) 99 | dependencyNode.appendNode('version', it.version) 100 | } 101 | } 102 | } 103 | } 104 | } 105 | repositories { 106 | maven { 107 | name = "sonatype" 108 | 109 | // You only need this if you want to publish snapshots, otherwise just set the URL 110 | // to the release repo directly 111 | url = isReleaseBuild() ? getReleaseRepositoryUrl() : getSnapshotRepositoryUrl() 112 | 113 | credentials(PasswordCredentials) { 114 | username = getSonatypeRepositoryToken() 115 | password = getSonatypeRepositoryTokenPassword() 116 | } 117 | } 118 | } 119 | } 120 | } 121 | 122 | signing { 123 | logger("signing") 124 | sign publishing.publications 125 | } 126 | 127 | publish.dependsOn build 128 | publishToMavenLocal.dependsOn build -------------------------------------------------------------------------------- /app/src/androidTest/java/com/segment/analytics/android/integrations/appsflyer/ApplicationTest.java: -------------------------------------------------------------------------------- 1 | //package com.segment.analytics.android.integration.appsflyer; 2 | // 3 | //import android.app.Application; 4 | //import android.test.ApplicationTestCase; 5 | // 6 | ///** 7 | // * Testing Fundamentals 8 | // */ 9 | //public class ApplicationTest extends ApplicationTestCase