diff --git a/Adjust/build.gradle b/Adjust/build.gradle index 54ab560ce..a9495314e 100644 --- a/Adjust/build.gradle +++ b/Adjust/build.gradle @@ -9,7 +9,7 @@ ext { coreMinSdkVersion = 21 coreCompileSdkVersion = 34 coreTargetSdkVersion = 34 - coreVersionName = '5.0.0' + coreVersionName = '5.0.0-SNAPSHOT' defaultVersionCode = 1 webbridgeMinSdkVersion = 21 samsungReferrerMinSdkVersion = 21 diff --git a/Adjust/example-app-java/src/main/java/com/adjust/examples/GlobalApplication.java b/Adjust/example-app-java/src/main/java/com/adjust/examples/GlobalApplication.java index 3ff7c24c3..25babb14c 100644 --- a/Adjust/example-app-java/src/main/java/com/adjust/examples/GlobalApplication.java +++ b/Adjust/example-app-java/src/main/java/com/adjust/examples/GlobalApplication.java @@ -19,21 +19,17 @@ import com.adjust.sdk.OnAmazonAdIdReadListener; import com.adjust.sdk.OnAttributionChangedListener; import com.adjust.sdk.OnAttributionReadListener; -import com.adjust.sdk.OnDeeplinkResponseListener; +import com.adjust.sdk.OnDeferredDeeplinkResponseListener; import com.adjust.sdk.OnEventTrackingFailedListener; import com.adjust.sdk.OnEventTrackingSucceededListener; import com.adjust.sdk.OnGooglePlayInstallReferrerReadListener; import com.adjust.sdk.OnSessionTrackingFailedListener; import com.adjust.sdk.OnSessionTrackingSucceededListener; -import java.util.ArrayList; -import java.util.List; - /** * Created by pfms on 17/12/14. */ public class GlobalApplication extends Application { - @Override public void onCreate() { super.onCreate(); @@ -65,14 +61,6 @@ public void onFinishedEventTrackingSucceeded(AdjustEventSuccess eventSuccessResp } }); - - // Set url strategy -// List urlStrategy = new ArrayList<>(); -// urlStrategy.add("adjust.com"); -// urlStrategy.add("adjust.cn"); -// urlStrategy.add("eu.adjust.com"); -// config.setUrlStrategy(urlStrategy , true, false); - // Set event failure tracking delegate. config.setOnEventTrackingFailedListener(new OnEventTrackingFailedListener() { @Override @@ -101,7 +89,7 @@ public void onFinishedSessionTrackingFailed(AdjustSessionFailure sessionFailureR }); // Evaluate deferred deep link to be launched. - config.setOnDeeplinkResponseListener(new OnDeeplinkResponseListener() { + config.setOnDeferredDeeplinkResponseListener(new OnDeferredDeeplinkResponseListener() { @Override public boolean launchReceivedDeeplink(Uri deeplink) { Log.d("example", "Deferred deep link callback called!"); @@ -111,17 +99,8 @@ public boolean launchReceivedDeeplink(Uri deeplink) { } }); - // Set default tracker. - // config.setDefaultTracker("{YourDefaultTracker}"); - - // Set process name. - // config.setProcessName("com.adjust.examples"); - // Allow to send in the background. - config.setSendInBackground(true); - - // Allow tracking preinstall - // config.setPreinstallTrackingEnabled(true); + config.enableSendingInBackground(); // Add session callback parameters. Adjust.addGlobalCallbackParameter("sc_foo", "sc_bar"); @@ -155,96 +134,5 @@ public boolean launchReceivedDeeplink(Uri deeplink) { // Initialise the adjust SDK. Adjust.initSdk(config); - - - - - Adjust.getAttribution(new OnAttributionReadListener() { - @Override - public void onAttributionRead(AdjustAttribution attribution) { - Log.d("example", "Attribution callback called!"); - Log.d("example", "Attribution: " + attribution.toString()); - } - }); - - // Get the adid. - Adjust.getAdid(new OnAdidReadListener() { - @Override - public void onAdidRead(String adid) { - Log.d("example", "Adid callback called!"); - Log.d("example", "Adid: " + adid); - } - }); - - Adjust.getGooglePlayInstallReferrer(this, new OnGooglePlayInstallReferrerReadListener() { - @Override - public void onInstallReferrerRead(GooglePlayInstallReferrerDetails referrerDetails) { - Log.d("example", "referrerApi : " + referrerDetails.toString()); - } - - @Override - public void onFailure(String message) { - Log.d("example", "failed : " + message); - - } - }); - - // Register onResume and onPause events of all activities - // for applications with minSdkVersion >= 14. - registerActivityLifecycleCallbacks(new AdjustLifecycleCallbacks()); - - Adjust.getAmazonAdId(this, new OnAmazonAdIdReadListener() { - @Override - public void onAmazonAdIdRead(String amazonAdId) { - Log.d("example", "amazonAdId : " + amazonAdId); - } - - @Override - public void onFail(String message) { - Log.d("example", "failed : " + message); - } - }); - - // Put the SDK in offline mode. - // Adjust.switchToOfflineMode(); - - // Disable the SDK - // Adjust.disable(); - - // Send push notification token. - // Adjust.setPushToken("token"); - } - - // You can use this class if your app is for Android 4.0 or higher - private static final class AdjustLifecycleCallbacks implements ActivityLifecycleCallbacks { - @Override - public void onActivityResumed(Activity activity) { - Adjust.onResume(); - } - - @Override - public void onActivityPaused(Activity activity) { - Adjust.onPause(); - } - - @Override - public void onActivityStopped(Activity activity) { - } - - @Override - public void onActivitySaveInstanceState(Activity activity, Bundle outState) { - } - - @Override - public void onActivityDestroyed(Activity activity) { - } - - @Override - public void onActivityCreated(Activity activity, Bundle savedInstanceState) { - } - - @Override - public void onActivityStarted(Activity activity) { - } } } diff --git a/Adjust/example-app-keyboard/src/main/java/com/adjust/examples/keyboard/GlobalApplication.java b/Adjust/example-app-keyboard/src/main/java/com/adjust/examples/keyboard/GlobalApplication.java index 215e64d07..55f30b016 100644 --- a/Adjust/example-app-keyboard/src/main/java/com/adjust/examples/keyboard/GlobalApplication.java +++ b/Adjust/example-app-keyboard/src/main/java/com/adjust/examples/keyboard/GlobalApplication.java @@ -1,9 +1,7 @@ package com.adjust.examples.keyboard; -import android.app.Activity; import android.app.Application; import android.net.Uri; -import android.os.Bundle; import android.util.Log; import com.adjust.sdk.Adjust; @@ -11,15 +9,15 @@ import com.adjust.sdk.AdjustConfig; import com.adjust.sdk.AdjustEventFailure; import com.adjust.sdk.AdjustEventSuccess; +import com.adjust.sdk.AdjustSessionFailure; +import com.adjust.sdk.AdjustSessionSuccess; import com.adjust.sdk.LogLevel; import com.adjust.sdk.OnAttributionChangedListener; -import com.adjust.sdk.OnDeeplinkResponseListener; +import com.adjust.sdk.OnDeferredDeeplinkResponseListener; import com.adjust.sdk.OnEventTrackingFailedListener; import com.adjust.sdk.OnEventTrackingSucceededListener; import com.adjust.sdk.OnSessionTrackingFailedListener; import com.adjust.sdk.OnSessionTrackingSucceededListener; -import com.adjust.sdk.AdjustSessionFailure; -import com.adjust.sdk.AdjustSessionSuccess; /** * Created by pfms on 17/12/14. @@ -84,7 +82,7 @@ public void onFinishedSessionTrackingFailed(AdjustSessionFailure sessionFailureR }); // Evaluate deferred deep link to be launched. - config.setOnDeeplinkResponseListener(new OnDeeplinkResponseListener() { + config.setOnDeferredDeeplinkResponseListener(new OnDeferredDeeplinkResponseListener() { @Override public boolean launchReceivedDeeplink(Uri deeplink) { Log.d("example", "Deferred deep link callback called!"); @@ -101,7 +99,7 @@ public boolean launchReceivedDeeplink(Uri deeplink) { // config.setProcessName("com.adjust.examples"); // Allow to send in the background. - config.setSendInBackground(true); + config.enableSendingInBackground(); // Add session callback parameters. Adjust.addGlobalCallbackParameter("sc_foo", "sc_bar"); @@ -136,10 +134,6 @@ public boolean launchReceivedDeeplink(Uri deeplink) { // Initialise the adjust SDK. Adjust.initSdk(config); - // Register onResume and onPause events of all activities - // for applications with minSdkVersion >= 14. - registerActivityLifecycleCallbacks(new AdjustLifecycleCallbacks()); - // Put the SDK in offline mode. // Adjust.switchToOfflineMode(); @@ -149,37 +143,4 @@ public boolean launchReceivedDeeplink(Uri deeplink) { // Send push notification token. // Adjust.setPushToken("token"); } - - // You can use this class if your app is for Android 4.0 or higher - private static final class AdjustLifecycleCallbacks implements ActivityLifecycleCallbacks { - @Override - public void onActivityResumed(Activity activity) { - Adjust.onResume(); - } - - @Override - public void onActivityPaused(Activity activity) { - Adjust.onPause(); - } - - @Override - public void onActivityStopped(Activity activity) { - } - - @Override - public void onActivitySaveInstanceState(Activity activity, Bundle outState) { - } - - @Override - public void onActivityDestroyed(Activity activity) { - } - - @Override - public void onActivityCreated(Activity activity, Bundle savedInstanceState) { - } - - @Override - public void onActivityStarted(Activity activity) { - } - } } diff --git a/Adjust/example-app-kotlin/src/main/java/com/adjust/examples/GlobalApplication.kt b/Adjust/example-app-kotlin/src/main/java/com/adjust/examples/GlobalApplication.kt index 624fec504..5204dcad4 100644 --- a/Adjust/example-app-kotlin/src/main/java/com/adjust/examples/GlobalApplication.kt +++ b/Adjust/example-app-kotlin/src/main/java/com/adjust/examples/GlobalApplication.kt @@ -1,8 +1,6 @@ package com.adjust.examples -import android.app.Activity import android.app.Application -import android.os.Bundle import android.util.Log import com.adjust.sdk.Adjust import com.adjust.sdk.AdjustConfig @@ -52,25 +50,15 @@ class GlobalApplication : Application() { } // Evaluate deferred deep link to be launched. - config.setOnDeeplinkResponseListener { deeplink -> + config.setOnDeferredDeeplinkResponseListener { deeplink -> Log.d("example", "Deferred deep link callback called!") Log.d("example", "Deep link URL: $deeplink") true } - // Set default tracker. - // config.setDefaultTracker("{YourDefaultTracker}"); - - // Set process name. - // config.setProcessName("com.adjust.examples"); - // Allow to send in the background. - config.setSendInBackground(true) - - - // Allow tracking preinstall - // config.setPreinstallTrackingEnabled(true); + config.enableSendingInBackground() // Add session callback parameters. Adjust.addGlobalCallbackParameter("sc_foo", "sc_bar") @@ -104,40 +92,5 @@ class GlobalApplication : Application() { // Initialise the adjust SDK. Adjust.initSdk(config) - - // Register onResume and onPause events of all activities - // for applications with minSdkVersion >= 14. - registerActivityLifecycleCallbacks(AdjustLifecycleCallbacks()) - - // Put the SDK in offline mode. - // Adjust.switchToOfflineMode(); - - // Disable the SDK - // Adjust.disable(); - - // Send push notification token. - // Adjust.setPushToken("token"); - - } - - // You can use this class if your app is for Android 4.0 or higher - private class AdjustLifecycleCallbacks : Application.ActivityLifecycleCallbacks { - override fun onActivityResumed(activity: Activity) { - Adjust.onResume() - } - - override fun onActivityPaused(activity: Activity) { - Adjust.onPause() - } - - override fun onActivityStopped(activity: Activity) {} - - override fun onActivitySaveInstanceState(activity: Activity, outState: Bundle) {} - - override fun onActivityDestroyed(activity: Activity) {} - - override fun onActivityCreated(activity: Activity, savedInstanceState: Bundle?) {} - - override fun onActivityStarted(activity: Activity) {} } } diff --git a/Adjust/example-app-tv/src/main/java/com/adjust/examples/GlobalApplication.java b/Adjust/example-app-tv/src/main/java/com/adjust/examples/GlobalApplication.java index 03d739ad9..ff6dce7d4 100755 --- a/Adjust/example-app-tv/src/main/java/com/adjust/examples/GlobalApplication.java +++ b/Adjust/example-app-tv/src/main/java/com/adjust/examples/GlobalApplication.java @@ -1,9 +1,7 @@ package com.adjust.examples; -import android.app.Activity; import android.app.Application; import android.net.Uri; -import android.os.Bundle; import android.util.Log; import com.adjust.sdk.Adjust; @@ -11,15 +9,15 @@ import com.adjust.sdk.AdjustConfig; import com.adjust.sdk.AdjustEventFailure; import com.adjust.sdk.AdjustEventSuccess; +import com.adjust.sdk.AdjustSessionFailure; +import com.adjust.sdk.AdjustSessionSuccess; import com.adjust.sdk.LogLevel; import com.adjust.sdk.OnAttributionChangedListener; -import com.adjust.sdk.OnDeeplinkResponseListener; +import com.adjust.sdk.OnDeferredDeeplinkResponseListener; import com.adjust.sdk.OnEventTrackingFailedListener; import com.adjust.sdk.OnEventTrackingSucceededListener; import com.adjust.sdk.OnSessionTrackingFailedListener; import com.adjust.sdk.OnSessionTrackingSucceededListener; -import com.adjust.sdk.AdjustSessionFailure; -import com.adjust.sdk.AdjustSessionSuccess; public class GlobalApplication extends Application { @Override @@ -81,7 +79,7 @@ public void onFinishedSessionTrackingFailed(AdjustSessionFailure sessionFailureR }); // Evaluate deferred deep link to be launched. - config.setOnDeeplinkResponseListener(new OnDeeplinkResponseListener() { + config.setOnDeferredDeeplinkResponseListener(new OnDeferredDeeplinkResponseListener() { @Override public boolean launchReceivedDeeplink(Uri deeplink) { Log.d("example", "Deferred deep link callback called!"); @@ -98,7 +96,7 @@ public boolean launchReceivedDeeplink(Uri deeplink) { // config.setProcessName("com.adjust.examples"); // Allow to send in the background. - config.setSendInBackground(true); + config.enableSendingInBackground(); // Add session callback parameters. Adjust.addGlobalCallbackParameter("sc_foo", "sc_bar"); @@ -123,10 +121,6 @@ public boolean launchReceivedDeeplink(Uri deeplink) { // Initialise the adjust SDK. Adjust.initSdk(config); - // Register onResume and onPause events of all activities - // for applications with minSdkVersion >= 14. - registerActivityLifecycleCallbacks(new AdjustLifecycleCallbacks()); - // Put the SDK in offline mode. // Adjust.switchToOfflineMode(); @@ -137,36 +131,4 @@ public boolean launchReceivedDeeplink(Uri deeplink) { // Adjust.setPushToken("token"); } - // You can use this class if your app is for Android 4.0 or higher - private static final class AdjustLifecycleCallbacks implements ActivityLifecycleCallbacks { - @Override - public void onActivityResumed(Activity activity) { - Adjust.onResume(); - } - - @Override - public void onActivityPaused(Activity activity) { - Adjust.onPause(); - } - - @Override - public void onActivityStopped(Activity activity) { - } - - @Override - public void onActivitySaveInstanceState(Activity activity, Bundle outState) { - } - - @Override - public void onActivityDestroyed(Activity activity) { - } - - @Override - public void onActivityCreated(Activity activity, Bundle savedInstanceState) { - } - - @Override - public void onActivityStarted(Activity activity) { - } - } } diff --git a/Adjust/example-app-webbridge/src/main/assets/AdjustExample-WebView.html b/Adjust/example-app-webbridge/src/main/assets/AdjustExample-WebView.html index bca5cfab1..845ab2c2a 100755 --- a/Adjust/example-app-webbridge/src/main/assets/AdjustExample-WebView.html +++ b/Adjust/example-app-webbridge/src/main/assets/AdjustExample-WebView.html @@ -62,8 +62,6 @@

Adjust Web View SDK Demo var adjustConfig = new AdjustConfig('2fm9gkqubvpc', AdjustConfig.EnvironmentSandbox); adjustConfig.setLogLevel(AdjustConfig.LogLevelVerbose); - // adjustConfig.setOpenDeferredDeeplink(true); - // adjustConfig.setSendInBackground(true); adjustConfig.setAttributionCallback(attributionCallback); adjustConfig.setEventSuccessCallback(eventSuccessCallback); @@ -72,8 +70,6 @@

Adjust Web View SDK Demo adjustConfig.setSessionFailureCallback(sessionFailureCallback); adjustConfig.setDeferredDeeplinkCallback(deferredDeeplinkCallback); - - Adjust.initSdk(adjustConfig); window.onload = function() { diff --git a/Adjust/sdk-core/src/main/java/com/adjust/sdk/ActivityHandler.java b/Adjust/sdk-core/src/main/java/com/adjust/sdk/ActivityHandler.java index 8556e8a9a..1ce649dd0 100644 --- a/Adjust/sdk-core/src/main/java/com/adjust/sdk/ActivityHandler.java +++ b/Adjust/sdk-core/src/main/java/com/adjust/sdk/ActivityHandler.java @@ -948,7 +948,7 @@ public void run() { }, FOREGROUND_TIMER_START, FOREGROUND_TIMER_INTERVAL, FOREGROUND_TIMER_NAME); // create background timer - if (adjustConfig.sendInBackground) { + if (adjustConfig.isSendingInBackgroundEnabled) { logger.info("Send in background configured"); backgroundTimer = new TimerOnce(new Runnable() { @@ -1122,7 +1122,7 @@ private void checkForPreinstallI() { // sending preinstall referrer doesn't require preinstall tracking flag to be enabled sendPreinstallReferrerI(); - if (!adjustConfig.preinstallTrackingEnabled) return; + if (!adjustConfig.isPreinstallTrackingEnabled) return; if (internalState.hasPreinstallBeenRead()) return; if (deviceInfo.packageName == null || deviceInfo.packageName.isEmpty()) { @@ -1595,7 +1595,7 @@ private void trackEventI(AdjustEvent event) { packageHandler.sendFirstPackage(); // if it is in the background and it can send, start the background timer - if (adjustConfig.sendInBackground && internalState.isInBackground()) { + if (adjustConfig.isSendingInBackgroundEnabled && internalState.isInBackground()) { startBackgroundTimerI(); } @@ -1840,8 +1840,8 @@ public void run() { return; } boolean toLaunchDeeplink = true; - if (adjustConfig.onDeeplinkResponseListener != null) { - toLaunchDeeplink = adjustConfig.onDeeplinkResponseListener.launchReceivedDeeplink(deeplink); + if (adjustConfig.onDeferredDeeplinkResponseListener != null) { + toLaunchDeeplink = adjustConfig.onDeferredDeeplinkResponseListener.launchReceivedDeeplink(deeplink); } if (toLaunchDeeplink) { launchDeeplinkMain(deeplinkIntent, deeplink); @@ -1853,15 +1853,9 @@ public void run() { private Intent createDeeplinkIntentI(Uri deeplink) { Intent mapIntent; - if (adjustConfig.deepLinkComponent == null) { - mapIntent = new Intent(Intent.ACTION_VIEW, deeplink); - } else { - mapIntent = new Intent(Intent.ACTION_VIEW, deeplink, adjustConfig.context, adjustConfig.deepLinkComponent); - } + mapIntent = new Intent(Intent.ACTION_VIEW, deeplink); mapIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); - mapIntent.setPackage(adjustConfig.context.getPackageName()); - return mapIntent; } @@ -2150,12 +2144,9 @@ private void updateHandlersStatusAndSendI() { } resumeSendingI(); - // if it's the first launch and it hasn't received the session response - if ((internalState.isFirstLaunch() && internalState.hasSessionResponseNotBeenProcessed())) - { - // try to send - packageHandler.sendFirstPackage(); - } + + // try to send + packageHandler.sendFirstPackage(); } private void pauseSendingI() { @@ -2865,7 +2856,7 @@ private boolean toSendI(boolean sdkClickHandlerOnly) { } // has the option to send in the background -> is to send - if (adjustConfig.sendInBackground) { + if (adjustConfig.isSendingInBackgroundEnabled) { return true; } diff --git a/Adjust/sdk-core/src/main/java/com/adjust/sdk/AdjustConfig.java b/Adjust/sdk-core/src/main/java/com/adjust/sdk/AdjustConfig.java index d9e103b6c..63d7efbc6 100644 --- a/Adjust/sdk-core/src/main/java/com/adjust/sdk/AdjustConfig.java +++ b/Adjust/sdk-core/src/main/java/com/adjust/sdk/AdjustConfig.java @@ -20,27 +20,26 @@ public class AdjustConfig { String sdkPrefix; String defaultTracker; OnAttributionChangedListener onAttributionChangedListener; - Class deepLinkComponent; OnEventTrackingSucceededListener onEventTrackingSucceededListener; OnEventTrackingFailedListener onEventTrackingFailedListener; OnSessionTrackingSucceededListener onSessionTrackingSucceededListener; OnSessionTrackingFailedListener onSessionTrackingFailedListener; - OnDeeplinkResponseListener onDeeplinkResponseListener; - boolean sendInBackground; + OnDeferredDeeplinkResponseListener onDeferredDeeplinkResponseListener; + boolean isSendingInBackgroundEnabled; AdjustInstance.PreLaunchActions preLaunchActions; ILogger logger; String pushToken; Boolean startEnabled; boolean startOffline; String externalDeviceId; - boolean preinstallTrackingEnabled; - Boolean needsCost; + boolean isPreinstallTrackingEnabled; + boolean isCostDataInAttributionEnabled; List urlStrategyDomains; boolean useSubdomains; boolean isDataResidency; String preinstallFilePath; String fbAppId; - boolean shouldReadDeviceIdsOnce; + boolean isDeviceIdsReadingOnceEnabled; OnDeeplinkResolvedListener cachedDeeplinkResolutionCallback; ArrayList cachedAdidReadCallbacks = new ArrayList<>(); Integer eventDeduplicationIdsMaxSize; @@ -77,20 +76,20 @@ private void init(Context context, String appToken, String environment, boolean this.environment = environment; // default values - this.sendInBackground = false; - this.preinstallTrackingEnabled = false; - this.shouldReadDeviceIdsOnce = false; - } - - - public void setSendInBackground(boolean sendInBackground) { - this.sendInBackground = sendInBackground; + this.isSendingInBackgroundEnabled = false; + this.isPreinstallTrackingEnabled = false; + this.isDeviceIdsReadingOnceEnabled = false; + this.isCostDataInAttributionEnabled = false; } public void setLogLevel(LogLevel logLevel) { setLogLevel(logLevel, environment); } + private void setLogLevel(LogLevel logLevel, String environment) { + logger.setLogLevel(logLevel, AdjustConfig.ENVIRONMENT_PRODUCTION.equals(environment)); + } + public void setSdkPrefix(String sdkPrefix) { this.sdkPrefix = sdkPrefix; } @@ -103,78 +102,70 @@ public void setDefaultTracker(String defaultTracker) { this.defaultTracker = defaultTracker; } - public void setOnAttributionChangedListener(OnAttributionChangedListener onAttributionChangedListener) { - this.onAttributionChangedListener = onAttributionChangedListener; - } - - public void setDeepLinkComponent(Class deepLinkComponent) { - this.deepLinkComponent = deepLinkComponent; + public void setExternalDeviceId(String externalDeviceId) { + this.externalDeviceId = externalDeviceId; } - public void setOnEventTrackingSucceededListener(OnEventTrackingSucceededListener onEventTrackingSucceededListener) { - this.onEventTrackingSucceededListener = onEventTrackingSucceededListener; + public void setPreinstallFilePath(String preinstallFilePath) { + this.preinstallFilePath = preinstallFilePath; } - public void setOnEventTrackingFailedListener(OnEventTrackingFailedListener onEventTrackingFailedListener) { - this.onEventTrackingFailedListener = onEventTrackingFailedListener; + public void setFbAppId(String fbAppId) { + this.fbAppId = fbAppId; } - public void setOnSessionTrackingSucceededListener(OnSessionTrackingSucceededListener onSessionTrackingSucceededListener) { - this.onSessionTrackingSucceededListener = onSessionTrackingSucceededListener; + public void setEventDeduplicationIdsMaxSize(Integer eventDeduplicationIdsMaxSize) { + this.eventDeduplicationIdsMaxSize = eventDeduplicationIdsMaxSize; } - public void setOnSessionTrackingFailedListener(OnSessionTrackingFailedListener onSessionTrackingFailedListener) { - this.onSessionTrackingFailedListener = onSessionTrackingFailedListener; + public void setUrlStrategy(List domains, boolean useSubdomains, boolean isDataResidency) { + if (domains == null || domains.isEmpty()) { + logger.error("Invalid URL strategy domains array"); + return; + } + this.urlStrategyDomains = domains; + this.useSubdomains = useSubdomains; + this.isDataResidency = isDataResidency; } - public void setOnDeeplinkResponseListener(OnDeeplinkResponseListener onDeeplinkResponseListener) { - this.onDeeplinkResponseListener = onDeeplinkResponseListener; + public void enablePreinstallTracking() { + this.isPreinstallTrackingEnabled = true; } - public void setExternalDeviceId(String externalDeviceId) { - this.externalDeviceId = externalDeviceId; + public void enableCostDataInAttribution() { + this.isCostDataInAttributionEnabled = true; } - public void setPreinstallTrackingEnabled(boolean preinstallTrackingEnabled) { - this.preinstallTrackingEnabled = preinstallTrackingEnabled; + public void enableSendingInBackground() { + this.isSendingInBackgroundEnabled = true; } - public void setPreinstallFilePath(String preinstallFilePath) { - this.preinstallFilePath = preinstallFilePath; + public void enableDeviceIdsReadingOnce() { + this.isDeviceIdsReadingOnceEnabled = true; } - public void setNeedsCost(boolean needsCost) { - this.needsCost = needsCost; + public void setOnAttributionChangedListener(OnAttributionChangedListener onAttributionChangedListener) { + this.onAttributionChangedListener = onAttributionChangedListener; } - public void setFbAppId(String fbAppId) { - this.fbAppId = fbAppId; + public void setOnEventTrackingSucceededListener(OnEventTrackingSucceededListener onEventTrackingSucceededListener) { + this.onEventTrackingSucceededListener = onEventTrackingSucceededListener; } - public boolean isValid() { - if (!checkAppToken(appToken)) return false; - if (!checkEnvironment(environment)) return false; - if (!checkContext(context)) return false; - - return true; + public void setOnEventTrackingFailedListener(OnEventTrackingFailedListener onEventTrackingFailedListener) { + this.onEventTrackingFailedListener = onEventTrackingFailedListener; } - public void setUrlStrategy(List domains, boolean useSubdomains, boolean isDataResidency) { - if (domains == null || domains.isEmpty()) { - logger.error("Invalid url strategy"); - return; - } - this.urlStrategyDomains = domains; - this.useSubdomains = useSubdomains; - this.isDataResidency = isDataResidency; + public void setOnSessionTrackingSucceededListener(OnSessionTrackingSucceededListener onSessionTrackingSucceededListener) { + this.onSessionTrackingSucceededListener = onSessionTrackingSucceededListener; } - public void readDeviceIdsOnce() { - this.shouldReadDeviceIdsOnce = true; + public void setOnSessionTrackingFailedListener(OnSessionTrackingFailedListener onSessionTrackingFailedListener) { + this.onSessionTrackingFailedListener = onSessionTrackingFailedListener; } - public void setEventDeduplicationIdsMaxSize(Integer eventDeduplicationIdsMaxSize) { - this.eventDeduplicationIdsMaxSize = eventDeduplicationIdsMaxSize; + public void setOnDeferredDeeplinkResponseListener(OnDeferredDeeplinkResponseListener onDeferredDeeplinkResponseListener) { + this.onDeferredDeeplinkResponseListener = onDeferredDeeplinkResponseListener; } public String getBasePath() { @@ -217,92 +208,84 @@ public String getDefaultTracker() { return defaultTracker; } - public OnAttributionChangedListener getOnAttributionChangedListener() { - return onAttributionChangedListener; - } - - public Class getDeepLinkComponent() { - return deepLinkComponent; - } - - public Integer getEventDeduplicationIdsMaxSize() { - return eventDeduplicationIdsMaxSize; + public String getPushToken() { + return pushToken; } - public OnEventTrackingSucceededListener getOnEventTrackingSucceededListener() { - return onEventTrackingSucceededListener; + public Boolean getStartEnabled() { + return startEnabled; } - public OnEventTrackingFailedListener getOnEventTrackingFailedListener() { - return onEventTrackingFailedListener; + public boolean isStartOffline() { + return startOffline; } - public OnSessionTrackingSucceededListener getOnSessionTrackingSucceededListener() { - return onSessionTrackingSucceededListener; + public String getExternalDeviceId() { + return externalDeviceId; } - public OnSessionTrackingFailedListener getOnSessionTrackingFailedListener() { - return onSessionTrackingFailedListener; + public boolean isPreinstallTrackingEnabled() { + return isPreinstallTrackingEnabled; } - public OnDeeplinkResponseListener getOnDeeplinkResponseListener() { - return onDeeplinkResponseListener; + public Boolean getCostDataInAttributionEnabled() { + return isCostDataInAttributionEnabled; } - public boolean isSendInBackground() { - return sendInBackground; + public boolean isSendingInBackgroundEnabled() { + return isSendingInBackgroundEnabled; } - public AdjustInstance.PreLaunchActions getPreLaunchActions() { - return preLaunchActions; + public Integer getEventDeduplicationIdsMaxSize() { + return eventDeduplicationIdsMaxSize; } - public ILogger getLogger() { - return logger; + public List getUrlStrategyDomains() { + return urlStrategyDomains; } - public String getPushToken() { - return pushToken; + public String getPreinstallFilePath() { + return preinstallFilePath; } - public Boolean getStartEnabled() { - return startEnabled; + public String getFbAppId() { + return fbAppId; } - public boolean isStartOffline() { - return startOffline; + public boolean isDeviceIdsReadingOnceEnabled() { + return isDeviceIdsReadingOnceEnabled; } - public String getExternalDeviceId() { - return externalDeviceId; + public OnAttributionChangedListener getOnAttributionChangedListener() { + return onAttributionChangedListener; } - public boolean isPreinstallTrackingEnabled() { - return preinstallTrackingEnabled; + public OnEventTrackingSucceededListener getOnEventTrackingSucceededListener() { + return onEventTrackingSucceededListener; } - public Boolean getNeedsCost() { - return needsCost; + public OnEventTrackingFailedListener getOnEventTrackingFailedListener() { + return onEventTrackingFailedListener; } - public List getUrlStrategyDomains() { - return urlStrategyDomains; + public OnSessionTrackingSucceededListener getOnSessionTrackingSucceededListener() { + return onSessionTrackingSucceededListener; } - public String getPreinstallFilePath() { - return preinstallFilePath; + public OnSessionTrackingFailedListener getOnSessionTrackingFailedListener() { + return onSessionTrackingFailedListener; } - public String getFbAppId() { - return fbAppId; + public OnDeferredDeeplinkResponseListener getOnDeeplinkResponseListener() { + return onDeferredDeeplinkResponseListener; } - public boolean shouldReadDeviceIdsOnce() { - return shouldReadDeviceIdsOnce; + public AdjustInstance.PreLaunchActions getPreLaunchActions() { + return preLaunchActions; } - private void setLogLevel(LogLevel logLevel, String environment) { - logger.setLogLevel(logLevel, AdjustConfig.ENVIRONMENT_PRODUCTION.equals(environment)); + public ILogger getLogger() { + return logger; } private boolean checkContext(Context context) { @@ -356,4 +339,17 @@ private boolean checkEnvironment(String environment) { logger.error("Unknown environment '%s'", environment); return false; } + + public boolean isValid() { + if (!checkAppToken(appToken)) { + return false; + } + if (!checkEnvironment(environment)) { + return false; + } + if (!checkContext(context)) { + return false; + } + return true; + } } \ No newline at end of file diff --git a/Adjust/sdk-core/src/main/java/com/adjust/sdk/AdjustInstance.java b/Adjust/sdk-core/src/main/java/com/adjust/sdk/AdjustInstance.java index fb09c786e..0370312ca 100644 --- a/Adjust/sdk-core/src/main/java/com/adjust/sdk/AdjustInstance.java +++ b/Adjust/sdk-core/src/main/java/com/adjust/sdk/AdjustInstance.java @@ -79,6 +79,10 @@ public PreLaunchActions() { * @param adjustConfig AdjustConfig object used for SDK initialisation */ public void initSdk(final AdjustConfig adjustConfig) { + if (!AdjustSigner.isPresent()) { + AdjustFactory.getLogger().error("Missing signature library, SDK can't be initialised"); + return; + } if (adjustConfig == null) { AdjustFactory.getLogger().error("AdjustConfig missing"); return; diff --git a/Adjust/sdk-core/src/main/java/com/adjust/sdk/AdjustSigner.java b/Adjust/sdk-core/src/main/java/com/adjust/sdk/AdjustSigner.java index 2d084b975..18c62fb0a 100644 --- a/Adjust/sdk-core/src/main/java/com/adjust/sdk/AdjustSigner.java +++ b/Adjust/sdk-core/src/main/java/com/adjust/sdk/AdjustSigner.java @@ -13,6 +13,16 @@ public class AdjustSigner { private AdjustSigner() { } + public static boolean isPresent() { + getSignerInstance(); + + if (signerInstance != null) { + return true; + } + + return false; + } + public static void onResume(ILogger logger){ getSignerInstance(); diff --git a/Adjust/sdk-core/src/main/java/com/adjust/sdk/DeviceInfo.java b/Adjust/sdk-core/src/main/java/com/adjust/sdk/DeviceInfo.java index 8d7a23183..25e8c8756 100644 --- a/Adjust/sdk-core/src/main/java/com/adjust/sdk/DeviceInfo.java +++ b/Adjust/sdk-core/src/main/java/com/adjust/sdk/DeviceInfo.java @@ -140,7 +140,7 @@ class DeviceInfo { } void reloadPlayIds(final AdjustConfig adjustConfig, boolean coppaEnabled, boolean playStoreKidsAppEnabled) { - if (playIdsReadOnce && adjustConfig.shouldReadDeviceIdsOnce) { + if (playIdsReadOnce && adjustConfig.isDeviceIdsReadingOnceEnabled) { if (!Util.canReadPlayIds(adjustConfig, coppaEnabled, playStoreKidsAppEnabled)) { playAdId = null; isTrackingEnabled = null; @@ -250,7 +250,7 @@ void reloadNonPlayIds(final AdjustConfig adjustConfig, boolean coppaEnabled, boo void reloadOtherDeviceInfoParams(final AdjustConfig adjustConfig, final boolean coppaEnabled, final ILogger logger) { - if (adjustConfig.shouldReadDeviceIdsOnce && otherDeviceIdsParamsReadOnce) { + if (adjustConfig.isDeviceIdsReadingOnceEnabled && otherDeviceIdsParamsReadOnce) { return; } diff --git a/Adjust/sdk-core/src/main/java/com/adjust/sdk/OnDeeplinkResponseListener.java b/Adjust/sdk-core/src/main/java/com/adjust/sdk/OnDeferredDeeplinkResponseListener.java similarity index 72% rename from Adjust/sdk-core/src/main/java/com/adjust/sdk/OnDeeplinkResponseListener.java rename to Adjust/sdk-core/src/main/java/com/adjust/sdk/OnDeferredDeeplinkResponseListener.java index 6075055ad..70762d87a 100644 --- a/Adjust/sdk-core/src/main/java/com/adjust/sdk/OnDeeplinkResponseListener.java +++ b/Adjust/sdk-core/src/main/java/com/adjust/sdk/OnDeferredDeeplinkResponseListener.java @@ -5,6 +5,6 @@ /** * Created by pfms on 22/03/16. */ -public interface OnDeeplinkResponseListener { +public interface OnDeferredDeeplinkResponseListener { boolean launchReceivedDeeplink(Uri deeplink); } diff --git a/Adjust/sdk-core/src/main/java/com/adjust/sdk/PackageBuilder.java b/Adjust/sdk-core/src/main/java/com/adjust/sdk/PackageBuilder.java index 71266884e..5c73b4023 100644 --- a/Adjust/sdk-core/src/main/java/com/adjust/sdk/PackageBuilder.java +++ b/Adjust/sdk-core/src/main/java/com/adjust/sdk/PackageBuilder.java @@ -278,7 +278,7 @@ private Map getSessionParameters() { PackageBuilder.addString(parameters, "cpu_type", deviceInfo.abi); PackageBuilder.addDateInMilliseconds(parameters, "created_at", createdAt); PackageBuilder.addString(parameters, "default_tracker", adjustConfig.defaultTracker); - PackageBuilder.addBoolean(parameters, "needs_cost", adjustConfig.needsCost); + PackageBuilder.addBoolean(parameters, "needs_cost", adjustConfig.isCostDataInAttributionEnabled); PackageBuilder.addString(parameters, "device_manufacturer", deviceInfo.deviceManufacturer); PackageBuilder.addString(parameters, "device_name", deviceInfo.deviceName); PackageBuilder.addString(parameters, "device_type", deviceInfo.deviceType); @@ -369,7 +369,7 @@ public Map getEventParameters(AdjustEvent event) { PackageBuilder.addString(parameters, "cpu_type", deviceInfo.abi); PackageBuilder.addDateInMilliseconds(parameters, "created_at", createdAt); PackageBuilder.addString(parameters, "currency", event.currency); - PackageBuilder.addBoolean(parameters, "needs_cost", adjustConfig.needsCost); + PackageBuilder.addBoolean(parameters, "needs_cost", adjustConfig.isCostDataInAttributionEnabled); PackageBuilder.addString(parameters, "device_manufacturer", deviceInfo.deviceManufacturer); PackageBuilder.addString(parameters, "device_name", deviceInfo.deviceName); PackageBuilder.addString(parameters, "device_type", deviceInfo.deviceType); @@ -455,7 +455,7 @@ private Map getInfoParameters(String source) { PackageBuilder.addString(parameters, "app_token", adjustConfig.appToken); PackageBuilder.addBoolean(parameters, "attribution_deeplink", true); PackageBuilder.addDateInMilliseconds(parameters, "created_at", createdAt); - PackageBuilder.addBoolean(parameters, "needs_cost", adjustConfig.needsCost); + PackageBuilder.addBoolean(parameters, "needs_cost", adjustConfig.isCostDataInAttributionEnabled); PackageBuilder.addString(parameters, "environment", adjustConfig.environment); PackageBuilder.addString(parameters, "external_device_id", adjustConfig.externalDeviceId); PackageBuilder.addBoolean(parameters, "needs_response_details", true); @@ -530,7 +530,7 @@ private Map getClickParameters(String source) { PackageBuilder.addString(parameters, "cpu_type", deviceInfo.abi); PackageBuilder.addDateInMilliseconds(parameters, "created_at", createdAt); PackageBuilder.addString(parameters, "deeplink", deeplink); - PackageBuilder.addBoolean(parameters, "needs_cost", adjustConfig.needsCost); + PackageBuilder.addBoolean(parameters, "needs_cost", adjustConfig.isCostDataInAttributionEnabled); PackageBuilder.addString(parameters, "device_manufacturer", deviceInfo.deviceManufacturer); PackageBuilder.addString(parameters, "device_name", deviceInfo.deviceName); PackageBuilder.addString(parameters, "device_type", deviceInfo.deviceType); @@ -627,7 +627,7 @@ private Map getAttributionParameters(String initiatedBy) { PackageBuilder.addString(parameters, "app_version", deviceInfo.appVersion); PackageBuilder.addBoolean(parameters, "attribution_deeplink", true); PackageBuilder.addDateInMilliseconds(parameters, "created_at", createdAt); - PackageBuilder.addBoolean(parameters, "needs_cost", adjustConfig.needsCost); + PackageBuilder.addBoolean(parameters, "needs_cost", adjustConfig.isCostDataInAttributionEnabled); PackageBuilder.addString(parameters, "device_name", deviceInfo.deviceName); PackageBuilder.addString(parameters, "device_type", deviceInfo.deviceType); PackageBuilder.addLong(parameters, "ui_mode", deviceInfo.uiMode); @@ -692,7 +692,7 @@ private Map getGdprParameters() { PackageBuilder.addString(parameters, "app_version", deviceInfo.appVersion); PackageBuilder.addBoolean(parameters, "attribution_deeplink", true); PackageBuilder.addDateInMilliseconds(parameters, "created_at", createdAt); - PackageBuilder.addBoolean(parameters, "needs_cost", adjustConfig.needsCost); + PackageBuilder.addBoolean(parameters, "needs_cost", adjustConfig.isCostDataInAttributionEnabled); PackageBuilder.addString(parameters, "device_name", deviceInfo.deviceName); PackageBuilder.addString(parameters, "device_type", deviceInfo.deviceType); PackageBuilder.addLong(parameters, "ui_mode", deviceInfo.uiMode); @@ -910,7 +910,7 @@ private Map getAdRevenueParameters(AdjustAdRevenue adjustAdReven PackageBuilder.addString(parameters, "cpu_type", deviceInfo.abi); PackageBuilder.addDateInMilliseconds(parameters, "created_at", createdAt); PackageBuilder.addString(parameters, "default_tracker", adjustConfig.defaultTracker); - PackageBuilder.addBoolean(parameters, "needs_cost", adjustConfig.needsCost); + PackageBuilder.addBoolean(parameters, "needs_cost", adjustConfig.isCostDataInAttributionEnabled); PackageBuilder.addString(parameters, "device_manufacturer", deviceInfo.deviceManufacturer); PackageBuilder.addString(parameters, "device_name", deviceInfo.deviceName); PackageBuilder.addString(parameters, "device_type", deviceInfo.deviceType); @@ -1008,7 +1008,7 @@ private Map getSubscriptionParameters(AdjustPlayStoreSubscriptio PackageBuilder.addString(parameters, "cpu_type", deviceInfo.abi); PackageBuilder.addDateInMilliseconds(parameters, "created_at", createdAt); PackageBuilder.addString(parameters, "default_tracker", adjustConfig.defaultTracker); - PackageBuilder.addBoolean(parameters, "needs_cost", adjustConfig.needsCost); + PackageBuilder.addBoolean(parameters, "needs_cost", adjustConfig.isCostDataInAttributionEnabled); PackageBuilder.addString(parameters, "device_manufacturer", deviceInfo.deviceManufacturer); PackageBuilder.addString(parameters, "device_name", deviceInfo.deviceName); PackageBuilder.addString(parameters, "device_type", deviceInfo.deviceType); @@ -1103,7 +1103,7 @@ private Map getVerificationParameters(AdjustPlayStorePurchase pu PackageBuilder.addString(parameters, "cpu_type", deviceInfo.abi); PackageBuilder.addDateInMilliseconds(parameters, "created_at", createdAt); PackageBuilder.addString(parameters, "default_tracker", adjustConfig.defaultTracker); - PackageBuilder.addBoolean(parameters, "needs_cost", adjustConfig.needsCost); + PackageBuilder.addBoolean(parameters, "needs_cost", adjustConfig.isCostDataInAttributionEnabled); PackageBuilder.addString(parameters, "device_manufacturer", deviceInfo.deviceManufacturer); PackageBuilder.addString(parameters, "device_name", deviceInfo.deviceName); PackageBuilder.addString(parameters, "device_type", deviceInfo.deviceType); @@ -1193,7 +1193,7 @@ private Map getVerificationParameters(AdjustEvent event) { PackageBuilder.addString(parameters, "cpu_type", deviceInfo.abi); PackageBuilder.addDateInMilliseconds(parameters, "created_at", createdAt); PackageBuilder.addString(parameters, "default_tracker", adjustConfig.defaultTracker); - PackageBuilder.addBoolean(parameters, "needs_cost", adjustConfig.needsCost); + PackageBuilder.addBoolean(parameters, "needs_cost", adjustConfig.isCostDataInAttributionEnabled); PackageBuilder.addString(parameters, "device_manufacturer", deviceInfo.deviceManufacturer); PackageBuilder.addString(parameters, "device_name", deviceInfo.deviceName); PackageBuilder.addString(parameters, "device_type", deviceInfo.deviceType); diff --git a/Adjust/sdk-core/src/main/java/com/adjust/sdk/PackageHandler.java b/Adjust/sdk-core/src/main/java/com/adjust/sdk/PackageHandler.java index 43e796eac..bcab223fe 100644 --- a/Adjust/sdk-core/src/main/java/com/adjust/sdk/PackageHandler.java +++ b/Adjust/sdk-core/src/main/java/com/adjust/sdk/PackageHandler.java @@ -134,7 +134,7 @@ public void onResponseDataCallback(final ResponseData responseData) { scheduler.submit(new Runnable() { @Override public void run() { - sendNextI(); + sendNextI(responseData.continueIn); } }); @@ -258,16 +258,32 @@ private Map generateSendingParametersI() { return sendingParameters; } - private void sendNextI() { + private void sendNextI(Long previousResponseContinueIn) { if (packageQueue.isEmpty()) { return; } packageQueue.remove(0); writePackageQueueI(); - isSending.set(false); - logger.verbose("Package handler can send"); - sendFirstI(); + + if (previousResponseContinueIn != null && previousResponseContinueIn > 0) { + Runnable runnable = new Runnable() { + @Override + public void run() { + logger.verbose("Package handler finished waiting to continue"); + isSending.set(false); + sendFirstPackage(); + } + }; + + logger.verbose("Waiting for %d seconds before continuing for next package in continue_in", previousResponseContinueIn / 1000.0); + scheduler.schedule(runnable, previousResponseContinueIn); + + } else { + logger.verbose("Package handler can send"); + isSending.set(false); + sendFirstI(); + } } private void flushI() { diff --git a/Adjust/sdk-plugin-webbridge/src/main/assets/adjust.js b/Adjust/sdk-plugin-webbridge/src/main/assets/adjust.js index b38737c74..553434cb3 100644 --- a/Adjust/sdk-plugin-webbridge/src/main/assets/adjust.js +++ b/Adjust/sdk-plugin-webbridge/src/main/assets/adjust.js @@ -209,34 +209,35 @@ var Adjust = { } }, - getAmazonAdId: function (callbackSuccess,callbackFail) { - if (AdjustBridge) { - if (typeof callbackSuccess === 'string' || callbackSuccess instanceof String) { - this.getAmazonIdCallbackSuccessName = callbackSuccess; - } else { - this.getAmazonIdCallbackSuccessName = 'Adjust.adjust_getAmazonIdCallbackSuccess'; - this.getAmazonIdCallbackSuccessFunction = callbackSuccess; - } - if (typeof callbackFail === 'string' || callbackFail instanceof String) { - this.getAmazonIdCallbackFailName = callbackFail; - } else { - this.getAmazonIdCallbackFailName = 'Adjust.adjust_getAmazonIdCallbackFail'; - this.getAmazonIdCallbackFailFunction = callbackFail; - } - AdjustBridge.getAmazonAdId(this.getAmazonIdCallbackSuccessName,this.getAmazonIdCallbackFailName); + getAmazonAdId: function (callbackSuccess,callbackFail) { + if (AdjustBridge) { + if (typeof callbackSuccess === 'string' || callbackSuccess instanceof String) { + this.getAmazonIdCallbackSuccessName = callbackSuccess; + } else { + this.getAmazonIdCallbackSuccessName = 'Adjust.adjust_getAmazonIdCallbackSuccess'; + this.getAmazonIdCallbackSuccessFunction = callbackSuccess; } - }, - - adjust_getAmazonIdCallbackSuccess: function (amazonId) { - if (AdjustBridge && this.getAmazonIdCallbackSuccessFunction) { - this.getAmazonIdCallbackSuccessFunction(amazonId); - } - }, - adjust_getAmazonIdCallbackFail: function (message) { - if (AdjustBridge && this.getAmazonIdCallbackFailFunction) { - this.getAmazonIdCallbackFailName(message); + if (typeof callbackFail === 'string' || callbackFail instanceof String) { + this.getAmazonIdCallbackFailName = callbackFail; + } else { + this.getAmazonIdCallbackFailName = 'Adjust.adjust_getAmazonIdCallbackFail'; + this.getAmazonIdCallbackFailFunction = callbackFail; + } + AdjustBridge.getAmazonAdId(this.getAmazonIdCallbackSuccessName,this.getAmazonIdCallbackFailName); } - }, + }, + + adjust_getAmazonIdCallbackSuccess: function (amazonId) { + if (AdjustBridge && this.getAmazonIdCallbackSuccessFunction) { + this.getAmazonIdCallbackSuccessFunction(amazonId); + } + }, + + adjust_getAmazonIdCallbackFail: function (message) { + if (AdjustBridge && this.getAmazonIdCallbackFailFunction) { + this.getAmazonIdCallbackFailName(message); + } + }, getAttribution: function (callback) { if (AdjustBridge) { @@ -258,19 +259,19 @@ var Adjust = { getSdkVersion: function (callback) { if (AdjustBridge) { - if (typeof callback === 'string' || callback instanceof String) { - this.getSdkVersionCallbackName = callback; - } else { - this.getSdkVersionCallbackName = 'Adjust.adjust_getSdkVersionCallback'; - this.getSdkVersionCallbackFunction = callback; - } - AdjustBridge.getSdkVersion(this.getSdkVersionCallbackName); + if (typeof callback === 'string' || callback instanceof String) { + this.getSdkVersionCallbackName = callback; + } else { + this.getSdkVersionCallbackName = 'Adjust.adjust_getSdkVersionCallback'; + this.getSdkVersionCallbackFunction = callback; } + AdjustBridge.getSdkVersion(this.getSdkVersionCallbackName); + } }, adjust_getSdkVersionCallback: function (sdkVersion) { if (AdjustBridge && this.getSdkVersionCallbackFunction) { - this.getSdkVersionCallbackFunction(sdkVersion); + this.getSdkVersionCallbackFunction(this.getSdkPrefix() + '@' + sdkVersion); } }, diff --git a/Adjust/sdk-plugin-webbridge/src/main/assets/adjust_config.js b/Adjust/sdk-plugin-webbridge/src/main/assets/adjust_config.js index a536c97e2..f8aa13dbe 100644 --- a/Adjust/sdk-plugin-webbridge/src/main/assets/adjust_config.js +++ b/Adjust/sdk-plugin-webbridge/src/main/assets/adjust_config.js @@ -19,7 +19,7 @@ function AdjustConfig(appToken, environment, legacy) { } } - this.sendInBackground = null; + this.isSendingInBackgroundEnabled = null; this.logLevel = null; this.sdkPrefix = null; this.processName = null; @@ -27,7 +27,7 @@ function AdjustConfig(appToken, environment, legacy) { this.externalDeviceId = null; this.attributionCallbackName = null; this.attributionCallbackFunction = null; - this.needsCost = null; + this.isCostDataInAttributionEnabled = null; this.eventSuccessCallbackName = null; this.eventSuccessCallbackFunction = null; this.eventFailureCallbackName = null; @@ -36,7 +36,7 @@ function AdjustConfig(appToken, environment, legacy) { this.sessionSuccessCallbackFunction = null; this.sessionFailureCallbackName = null; this.sessionFailureCallbackFunction = null; - this.openDeferredDeeplink = null; + this.isOpeningDeferredDeeplinkEnabled = null; this.deferredDeeplinkCallbackName = null; this.deferredDeeplinkCallbackFunction = null; this.fbPixelDefaultEventToken = null; @@ -44,7 +44,7 @@ function AdjustConfig(appToken, environment, legacy) { this.urlStrategy = []; this.useSubDomain = null; this.isDataResidency = null; - this.preinstallTrackingEnabled = null; + this.isPreinstallTrackingEnabled = null; this.preinstallFilePath = null; this.fbAppId = null; this.shouldReadDeviceIdsOnce = null; @@ -66,8 +66,8 @@ AdjustConfig.prototype.getBridge = function() { return this.bridge; }; -AdjustConfig.prototype.setSendInBackground = function(isEnabled) { - this.sendInBackground = isEnabled; +AdjustConfig.prototype.enableSendingInBackground = function() { + this.isSendingInBackgroundEnabled = true; }; AdjustConfig.prototype.setLogLevel = function(logLevel) { @@ -109,8 +109,8 @@ AdjustConfig.prototype.adjust_attributionCallback = function(attribution) { } }; -AdjustConfig.prototype.setNeedsCost = function(needsCost) { - this.needsCost = needsCost; +AdjustConfig.prototype.enableCostDataInAttribution = function() { + this.isCostDataInAttributionEnabled = true; }; AdjustConfig.prototype.setEventSuccessCallback = function(callback) { @@ -173,8 +173,8 @@ AdjustConfig.prototype.adjust_sessionFailureCallback = function(sessionFailure) } }; -AdjustConfig.prototype.setOpenDeferredDeeplink = function(shouldOpen) { - this.openDeferredDeeplink = shouldOpen; +AdjustConfig.prototype.disableDeferredDeeplinkOpening = function() { + this.isOpeningDeferredDeeplinkEnabled = false; }; AdjustConfig.prototype.setDeferredDeeplinkCallback = function(callback) { @@ -209,8 +209,8 @@ AdjustConfig.prototype.setUrlStrategy = function(urlStrategy, useSubDomain , isD this.isDataResidency = isDataResidency; }; -AdjustConfig.prototype.setPreinstallTrackingEnabled = function(preinstallTrackingEnabled) { - this.preinstallTrackingEnabled = preinstallTrackingEnabled; +AdjustConfig.prototype.enablePreinstallTracking = function() { + this.isPreinstallTrackingEnabled = true; }; AdjustConfig.prototype.setPreinstallFilePath = function(preinstallFilePath) { diff --git a/Adjust/sdk-plugin-webbridge/src/main/java/com/adjust/sdk/webbridge/AdjustBridgeInstance.java b/Adjust/sdk-plugin-webbridge/src/main/java/com/adjust/sdk/webbridge/AdjustBridgeInstance.java index b3b89855e..9a8ef1281 100644 --- a/Adjust/sdk-plugin-webbridge/src/main/java/com/adjust/sdk/webbridge/AdjustBridgeInstance.java +++ b/Adjust/sdk-plugin-webbridge/src/main/java/com/adjust/sdk/webbridge/AdjustBridgeInstance.java @@ -24,7 +24,7 @@ import com.adjust.sdk.OnAmazonAdIdReadListener; import com.adjust.sdk.OnAttributionChangedListener; import com.adjust.sdk.OnAttributionReadListener; -import com.adjust.sdk.OnDeeplinkResponseListener; +import com.adjust.sdk.OnDeferredDeeplinkResponseListener; import com.adjust.sdk.OnDeviceIdsRead; import com.adjust.sdk.OnEventTrackingFailedListener; import com.adjust.sdk.OnEventTrackingSucceededListener; @@ -38,7 +38,6 @@ import java.util.Arrays; import java.util.List; -import java.util.stream.Collectors; /** * Created by uerceg on 22/07/16. @@ -58,7 +57,7 @@ public class AdjustBridgeInstance { private WebView webView; private Application application; private boolean isInitialized = false; - private boolean shouldDeferredDeeplinkBeLaunched = true; + private boolean isOpeningDeferredDeeplinkEnabled = true; private FacebookSDKJSInterface facebookSDKJSInterface = null; private String adjustSdkPrefix = null; @@ -150,26 +149,26 @@ public void initSdk(String adjustConfigString) { Object appTokenField = jsonAdjustConfig.get("appToken"); Object environmentField = jsonAdjustConfig.get("environment"); Object allowSuppressLogLevelField = jsonAdjustConfig.get("allowSuppressLogLevel"); - Object sendInBackgroundField = jsonAdjustConfig.get("sendInBackground"); + Object isSendingInBackgroundEnabledField = jsonAdjustConfig.get("isSendingInBackgroundEnabled"); Object logLevelField = jsonAdjustConfig.get("logLevel"); Object sdkPrefixField = jsonAdjustConfig.get("sdkPrefix"); Object processNameField = jsonAdjustConfig.get("processName"); Object defaultTrackerField = jsonAdjustConfig.get("defaultTracker"); Object externalDeviceIdField = jsonAdjustConfig.get("externalDeviceId"); Object attributionCallbackNameField = jsonAdjustConfig.get("attributionCallbackName"); - Object needsCostField = jsonAdjustConfig.get("needsCost"); + Object isCostDataInAttributionEnabledField = jsonAdjustConfig.get("isCostDataInAttributionEnabled"); Object eventSuccessCallbackNameField = jsonAdjustConfig.get("eventSuccessCallbackName"); Object eventFailureCallbackNameField = jsonAdjustConfig.get("eventFailureCallbackName"); Object sessionSuccessCallbackNameField = jsonAdjustConfig.get("sessionSuccessCallbackName"); Object sessionFailureCallbackNameField = jsonAdjustConfig.get("sessionFailureCallbackName"); - Object openDeferredDeeplinkField = jsonAdjustConfig.get("openDeferredDeeplink"); + Object isOpeningDeferredDeeplinkEnabledField = jsonAdjustConfig.get("isOpeningDeferredDeeplinkEnabled"); Object deferredDeeplinkCallbackNameField = jsonAdjustConfig.get("deferredDeeplinkCallbackName"); Object fbPixelDefaultEventTokenField = jsonAdjustConfig.get("fbPixelDefaultEventToken"); Object fbPixelMappingField = jsonAdjustConfig.get("fbPixelMapping"); Object urlStrategyField = jsonAdjustConfig.get("urlStrategy"); Object useSubDomainField = jsonAdjustConfig.get("useSubDomain"); Object isDataResidencyField = jsonAdjustConfig.get("isDataResidency"); - Object preinstallTrackingEnabledField = jsonAdjustConfig.get("preinstallTrackingEnabled"); + Object isPreinstallTrackingEnabledField = jsonAdjustConfig.get("isPreinstallTrackingEnabled"); Object preinstallFilePathField = jsonAdjustConfig.get("preinstallFilePath"); Object fbAppIdField = jsonAdjustConfig.get("fbAppId"); Object shouldReadDeviceIdsOnceField = jsonAdjustConfig.get("shouldReadDeviceIdsOnce"); @@ -191,9 +190,11 @@ public void initSdk(String adjustConfigString) { } // Send in the background - Boolean sendInBackground = AdjustBridgeUtil.fieldToBoolean(sendInBackgroundField); - if (sendInBackground != null) { - adjustConfig.setSendInBackground(sendInBackground); + Boolean isSendingInBackgroundEnabled = AdjustBridgeUtil.fieldToBoolean(isSendingInBackgroundEnabledField); + if (isSendingInBackgroundEnabled != null) { + if (isSendingInBackgroundEnabled) { + adjustConfig.enableSendingInBackground(); + } } // Log level @@ -253,9 +254,11 @@ public void onAttributionChanged(AdjustAttribution attribution) { } // Needs cost - Boolean needsCost = AdjustBridgeUtil.fieldToBoolean(needsCostField); - if (needsCost != null) { - adjustConfig.setNeedsCost(needsCost); + Boolean isCostDataInAttributionEnabled = AdjustBridgeUtil.fieldToBoolean(isCostDataInAttributionEnabledField); + if (isCostDataInAttributionEnabled != null) { + if (isCostDataInAttributionEnabled) { + adjustConfig.enableCostDataInAttribution(); + } } // Event success callback @@ -301,19 +304,19 @@ public void onFinishedSessionTrackingFailed(AdjustSessionFailure failureResponse } // Should deferred deep link be opened? - Boolean openDeferredDeeplink = AdjustBridgeUtil.fieldToBoolean(openDeferredDeeplinkField); - if (openDeferredDeeplink != null) { - shouldDeferredDeeplinkBeLaunched = openDeferredDeeplink; + Boolean isOpeningDeferredDeeplinkEnabledObject = AdjustBridgeUtil.fieldToBoolean(isOpeningDeferredDeeplinkEnabledField); + if (isOpeningDeferredDeeplinkEnabledObject != null) { + isOpeningDeferredDeeplinkEnabled = isOpeningDeferredDeeplinkEnabledObject; } // Deferred deeplink callback final String deferredDeeplinkCallbackName = AdjustBridgeUtil.fieldToString(deferredDeeplinkCallbackNameField); if (deferredDeeplinkCallbackName != null) { - adjustConfig.setOnDeeplinkResponseListener(new OnDeeplinkResponseListener() { + adjustConfig.setOnDeferredDeeplinkResponseListener(new OnDeferredDeeplinkResponseListener() { @Override public boolean launchReceivedDeeplink(Uri deeplink) { AdjustBridgeUtil.execSingleValueCallback(webView, deferredDeeplinkCallbackName, deeplink.toString()); - return shouldDeferredDeeplinkBeLaunched; + return isOpeningDeferredDeeplinkEnabled; } }); } @@ -349,9 +352,11 @@ public boolean launchReceivedDeeplink(Uri deeplink) { } // Preinstall tracking - Boolean preinstallTrackingEnabled = AdjustBridgeUtil.fieldToBoolean(preinstallTrackingEnabledField); - if (preinstallTrackingEnabled != null) { - adjustConfig.setPreinstallTrackingEnabled(preinstallTrackingEnabled); + Boolean isPreinstallTrackingEnabled = AdjustBridgeUtil.fieldToBoolean(isPreinstallTrackingEnabledField); + if (isPreinstallTrackingEnabled != null) { + if (isPreinstallTrackingEnabled) { + adjustConfig.enablePreinstallTracking(); + } } // Preinstall secondary file path @@ -369,7 +374,7 @@ public boolean launchReceivedDeeplink(Uri deeplink) { // read device info once Boolean shouldReadDeviceIdsOnce = AdjustBridgeUtil.fieldToBoolean(shouldReadDeviceIdsOnceField); if (shouldReadDeviceIdsOnce != null && shouldReadDeviceIdsOnce.booleanValue()) { - adjustConfig.readDeviceIdsOnce(); + adjustConfig.enableDeviceIdsReadingOnce(); } Integer eventDeduplicationIdsMaxSize = AdjustBridgeUtil.fieldToInteger(eventDeduplicationIdsMaxSizeField); @@ -755,9 +760,6 @@ public void getSdkVersion(final String callback) { Adjust.getSdkVersion(new OnSdkVersionReadListener() { @Override public void onSdkVersionRead(String sdkVersion) { - if (adjustSdkPrefix != null && adjustSdkPrefix.length() > 0) { - sdkVersion = adjustSdkPrefix + "@" + sdkVersion; - } AdjustBridgeUtil.execSingleValueCallback(webView, callback, sdkVersion); } }); @@ -771,7 +773,7 @@ public void fbPixelEvent(String pixelId, String event_name, String jsonString) { @JavascriptInterface public void teardown() { isInitialized = false; - shouldDeferredDeeplinkBeLaunched = true; + isOpeningDeferredDeeplinkEnabled = true; } public void setWebView(WebView webView) { diff --git a/Adjust/test-app-core/src/main/java/com/adjust/testapp/AdjustCommandExecutor.java b/Adjust/test-app-core/src/main/java/com/adjust/testapp/AdjustCommandExecutor.java index 3a1613ac8..371b9092c 100644 --- a/Adjust/test-app-core/src/main/java/com/adjust/testapp/AdjustCommandExecutor.java +++ b/Adjust/test-app-core/src/main/java/com/adjust/testapp/AdjustCommandExecutor.java @@ -27,7 +27,7 @@ import com.adjust.sdk.LogLevel; import com.adjust.sdk.OnAttributionChangedListener; import com.adjust.sdk.OnDeeplinkResolvedListener; -import com.adjust.sdk.OnDeeplinkResponseListener; +import com.adjust.sdk.OnDeferredDeeplinkResponseListener; import com.adjust.sdk.OnEventTrackingFailedListener; import com.adjust.sdk.OnEventTrackingSucceededListener; import com.adjust.sdk.OnPurchaseVerificationFinishedListener; @@ -284,23 +284,20 @@ private void config() { adjustConfig.setDefaultTracker(defaultTracker); } -// if (command.containsParameter("externalDeviceId")) { -// String externalDeviceId = command.getFirstParameterValue("externalDeviceId"); -// adjustConfig.setExternalDeviceId(externalDeviceId); -// } - - if (command.containsParameter("needsCost")) { - String needsCostS = command.getFirstParameterValue("needsCost"); - boolean needsCost = "true".equals(needsCostS); - adjustConfig.setNeedsCost(needsCost); + String isCostDataInAttributionEnabledS = command.getFirstParameterValue("needsCost"); + boolean isCostDataInAttributionEnabled = "true".equals(isCostDataInAttributionEnabledS); + if (isCostDataInAttributionEnabled) { + adjustConfig.enableCostDataInAttribution(); + } } - if (command.containsParameter("sendInBackground")) { - String sendInBackgroundS = command.getFirstParameterValue("sendInBackground"); - boolean sendInBackground = "true".equals(sendInBackgroundS); - adjustConfig.setSendInBackground(sendInBackground); + String isSendingInBackgroundEnabledS = command.getFirstParameterValue("sendInBackground"); + boolean isSendingInBackgroundEnabled = "true".equals(isSendingInBackgroundEnabledS); + if (isSendingInBackgroundEnabled) { + adjustConfig.enableSendingInBackground(); + } } if (command.containsParameter("eventDeduplicationIdsMaxSize")) { @@ -315,7 +312,7 @@ private void config() { } if(command.containsParameter("deferredDeeplinkCallback")) { - adjustConfig.setOnDeeplinkResponseListener(new OnDeeplinkResponseListener() { + adjustConfig.setOnDeferredDeeplinkResponseListener(new OnDeferredDeeplinkResponseListener() { @Override public boolean launchReceivedDeeplink(Uri deeplink) { if (deeplink == null) { @@ -439,7 +436,7 @@ public void onFinishedEventTrackingFailed(AdjustEventFailure eventFailureRespons String launchDeferredDeeplinkS = command.getFirstParameterValue("deferredDeeplinkCallback"); final boolean launchDeferredDeeplink = "true".equals(launchDeferredDeeplinkS); final String localBasePath = basePath; - adjustConfig.setOnDeeplinkResponseListener(new OnDeeplinkResponseListener() { + adjustConfig.setOnDeferredDeeplinkResponseListener(new OnDeferredDeeplinkResponseListener() { @Override public boolean launchReceivedDeeplink(Uri deeplink) { Log.d("TestApp", "deferred_deep_link = " + deeplink.toString()); diff --git a/Adjust/test-app-webbridge/src/main/assets/AdjustTestApp-WebView.html b/Adjust/test-app-webbridge/src/main/assets/AdjustTestApp-WebView.html index e4a0ed006..846e4880d 100755 --- a/Adjust/test-app-webbridge/src/main/assets/AdjustTestApp-WebView.html +++ b/Adjust/test-app-webbridge/src/main/assets/AdjustTestApp-WebView.html @@ -22,7 +22,9 @@

Adjust Web View SDK Test

window.onload = function() { // TestLibrary.addTestDirectory('current/user-agent'); // TestLibrary.addTest('current/deeplink-deferred/Test_DeferredDeeplink_callback_false'); - TestLibrary.startTestSession(Adjust.getSdkVersion()); + Adjust.getSdkVersion(function(sdkVersion) { + TestLibrary.startTestSession(sdkVersion); + }); }
diff --git a/Adjust/test-app-webbridge/src/main/assets/command_executor.js b/Adjust/test-app-webbridge/src/main/assets/command_executor.js index 66a823d00..9d4c934a3 100644 --- a/Adjust/test-app-webbridge/src/main/assets/command_executor.js +++ b/Adjust/test-app-webbridge/src/main/assets/command_executor.js @@ -293,20 +293,24 @@ AdjustCommandExecutor.prototype.config = function(params) { } if ('externalDeviceId' in params) { - var externalDeviceId = getFirstParameterValue(params, 'externalDeviceId'); - adjustConfig.setExternalDeviceId(externalDeviceId); - } + var externalDeviceId = getFirstParameterValue(params, 'externalDeviceId'); + adjustConfig.setExternalDeviceId(externalDeviceId); + } if ('needsCost' in params) { - var needsCostS = getFirstParameterValue(params, 'needsCost'); - var needsCost = needsCostS == 'true'; - adjustConfig.setNeedsCost(needsCost); + var isCostDataInAttributionEnabledS = getFirstParameterValue(params, 'needsCost'); + var isCostDataInAttributionEnabled = isCostDataInAttributionEnabledS == 'true'; + if (isCostDataInAttributionEnabled == true) { + adjustConfig.enableCostDataInAttribution(); + } } if ('sendInBackground' in params) { - var sendInBackgroundS = getFirstParameterValue(params, 'sendInBackground'); - var sendInBackground = sendInBackgroundS == 'true'; - adjustConfig.setSendInBackground(sendInBackground); + var isSendingInBackgroundEnabledS = getFirstParameterValue(params, 'sendInBackground'); + var isSendingInBackgroundEnabled = isSendingInBackgroundEnabledS == 'true'; + if (isSendingInBackgroundEnabled == true) { + adjustConfig.enableSendingInBackground(); + } } if ('eventDeduplicationIdsMaxSize' in params) { @@ -390,9 +394,12 @@ AdjustCommandExecutor.prototype.config = function(params) { if ('deferredDeeplinkCallback' in params) { var basePath = this.basePath; - var openDeeplinkS = getFirstParameterValue(params, 'deferredDeeplinkCallback'); - var openDeeplink = openDeeplinkS == 'true'; - adjustConfig.setOpenDeferredDeeplink(openDeeplink); + var isOpeningDeferredDeeplinkEnabledS = getFirstParameterValue(params, 'deferredDeeplinkCallback'); + var isOpeningDeferredDeeplinkEnabled = isOpeningDeferredDeeplinkEnabledS == 'true'; + if (isOpeningDeferredDeeplinkEnabled == false) { + adjustConfig.disableDeferredDeeplinkOpening(); + } + adjustConfig.setDeferredDeeplinkCallback(function(deeplink) { TestLibrary.addInfoToSend("deeplink", deeplink); TestLibrary.sendInfoToServer(basePath); diff --git a/Adjust/test-app-webbridge/src/test/java/com/example/testappwebbridge/ExampleUnitTest.java b/Adjust/test-app-webbridge/src/test/java/com/example/testappwebbridge/ExampleUnitTest.java deleted file mode 100644 index 020b2e22e..000000000 --- a/Adjust/test-app-webbridge/src/test/java/com/example/testappwebbridge/ExampleUnitTest.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.example.testappwebbridge; - -import org.junit.Test; - -import static org.junit.Assert.*; - -/** - * Example local unit test, which will execute on the development machine (host). - * - * @see Testing documentation - */ -public class ExampleUnitTest { - @Test - public void addition_isCorrect() { - assertEquals(4, 2 + 2); - } -} \ No newline at end of file