@adadapted/react-native-sdk 3.1.8 → 3.1.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,34 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <projectDescription>
3
+ <name>adadaptedreactnativesdk</name>
4
+ <comment>Project android_ created by Buildship.</comment>
5
+ <projects>
6
+ </projects>
7
+ <buildSpec>
8
+ <buildCommand>
9
+ <name>org.eclipse.jdt.core.javabuilder</name>
10
+ <arguments>
11
+ </arguments>
12
+ </buildCommand>
13
+ <buildCommand>
14
+ <name>org.eclipse.buildship.core.gradleprojectbuilder</name>
15
+ <arguments>
16
+ </arguments>
17
+ </buildCommand>
18
+ </buildSpec>
19
+ <natures>
20
+ <nature>org.eclipse.jdt.core.javanature</nature>
21
+ <nature>org.eclipse.buildship.core.gradleprojectnature</nature>
22
+ </natures>
23
+ <filteredResources>
24
+ <filter>
25
+ <id>0</id>
26
+ <name></name>
27
+ <type>30</type>
28
+ <matcher>
29
+ <id>org.eclipse.core.resources.regexFilterMatcher</id>
30
+ <arguments>node_modules|\.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__</arguments>
31
+ </matcher>
32
+ </filter>
33
+ </filteredResources>
34
+ </projectDescription>
@@ -0,0 +1,13 @@
1
+ arguments=--init-script /var/folders/vw/1yz06gyj201f5y15zm_xv9gr0000gn/T/d146c9752a26f79b52047fb6dc6ed385d064e120494f96f08ca63a317c41f94c.gradle --init-script /var/folders/vw/1yz06gyj201f5y15zm_xv9gr0000gn/T/52cde0cfcf3e28b8b7510e992210d9614505e0911af0c190bd590d7158574963.gradle
2
+ auto.sync=false
3
+ build.scans.enabled=false
4
+ connection.gradle.distribution=GRADLE_DISTRIBUTION(VERSION(7.4.2))
5
+ connection.project.dir=../example/android
6
+ eclipse.preferences.version=1
7
+ gradle.user.home=
8
+ java.home=/Library/Java/JavaVirtualMachines/temurin-11.jdk/Contents/Home
9
+ jvm.arguments=
10
+ offline.mode=false
11
+ override.workspace.settings=true
12
+ show.console.view=true
13
+ show.executions.view=true
@@ -0,0 +1,130 @@
1
+ buildscript {
2
+ // Buildscript is evaluated before everything else so we can't use getExtOrDefault
3
+ def kotlin_version = rootProject.ext.has('kotlinVersion') ? rootProject.ext.get('kotlinVersion') : project.properties['AdadaptedReactNativeSdk_kotlinVersion']
4
+
5
+ repositories {
6
+ google()
7
+ jcenter()
8
+ }
9
+
10
+ dependencies {
11
+ classpath 'com.android.tools.build:gradle:3.2.1'
12
+ // noinspection DifferentKotlinGradleVersion
13
+ classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
14
+ }
15
+ }
16
+
17
+ apply plugin: 'com.android.library'
18
+ apply plugin: 'kotlin-android'
19
+
20
+ def getExtOrDefault(name) {
21
+ return rootProject.ext.has(name) ? rootProject.ext.get(name) : project.properties['AdadaptedReactNativeSdk_' + name]
22
+ }
23
+
24
+ def getExtOrIntegerDefault(name) {
25
+ return rootProject.ext.has(name) ? rootProject.ext.get(name) : (project.properties['AdadaptedReactNativeSdk_' + name]).toInteger()
26
+ }
27
+
28
+ android {
29
+ compileSdkVersion getExtOrIntegerDefault('compileSdkVersion')
30
+ buildToolsVersion getExtOrDefault('buildToolsVersion')
31
+ defaultConfig {
32
+ minSdkVersion 21
33
+ targetSdkVersion getExtOrIntegerDefault('targetSdkVersion')
34
+ versionCode 1
35
+ versionName "1.0"
36
+ }
37
+ buildTypes {
38
+ release {
39
+ minifyEnabled false
40
+ }
41
+ }
42
+ lintOptions {
43
+ disable 'GradleCompatible'
44
+ }
45
+ compileOptions {
46
+ sourceCompatibility JavaVersion.VERSION_1_8
47
+ targetCompatibility JavaVersion.VERSION_1_8
48
+ }
49
+ }
50
+
51
+ repositories {
52
+ mavenCentral()
53
+ jcenter()
54
+ google()
55
+
56
+ def found = false
57
+ def defaultDir = null
58
+ def androidSourcesName = 'React Native sources'
59
+
60
+ if (rootProject.ext.has('reactNativeAndroidRoot')) {
61
+ defaultDir = rootProject.ext.get('reactNativeAndroidRoot')
62
+ } else {
63
+ defaultDir = new File(
64
+ projectDir,
65
+ '/../../../node_modules/react-native/android'
66
+ )
67
+ }
68
+
69
+ if (defaultDir.exists()) {
70
+ maven {
71
+ url defaultDir.toString()
72
+ name androidSourcesName
73
+ }
74
+
75
+ logger.info(":${project.name}:reactNativeAndroidRoot ${defaultDir.canonicalPath}")
76
+ found = true
77
+ } else {
78
+ def parentDir = rootProject.projectDir
79
+
80
+ 1.upto(5, {
81
+ if (found) return true
82
+ parentDir = parentDir.parentFile
83
+
84
+ def androidSourcesDir = new File(
85
+ parentDir,
86
+ 'node_modules/react-native'
87
+ )
88
+
89
+ def androidPrebuiltBinaryDir = new File(
90
+ parentDir,
91
+ 'node_modules/react-native/android'
92
+ )
93
+
94
+ if (androidPrebuiltBinaryDir.exists()) {
95
+ maven {
96
+ url androidPrebuiltBinaryDir.toString()
97
+ name androidSourcesName
98
+ }
99
+
100
+ logger.info(":${project.name}:reactNativeAndroidRoot ${androidPrebuiltBinaryDir.canonicalPath}")
101
+ found = true
102
+ } else if (androidSourcesDir.exists()) {
103
+ maven {
104
+ url androidSourcesDir.toString()
105
+ name androidSourcesName
106
+ }
107
+
108
+ logger.info(":${project.name}:reactNativeAndroidRoot ${androidSourcesDir.canonicalPath}")
109
+ found = true
110
+ }
111
+ })
112
+ }
113
+
114
+ if (!found) {
115
+ throw new GradleException(
116
+ "${project.name}: unable to locate React Native android sources. " +
117
+ "Ensure you have you installed React Native as a dependency in your project and try again."
118
+ )
119
+ }
120
+ }
121
+
122
+ def kotlin_version = getExtOrDefault('kotlinVersion')
123
+
124
+ dependencies {
125
+ // noinspection GradleDynamicVersion
126
+ api 'com.facebook.react:react-native:+'
127
+ implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
128
+
129
+ implementation 'com.google.android.gms:play-services-ads:12.0.1'
130
+ }
@@ -0,0 +1,4 @@
1
+ AdadaptedReactNativeSdk_kotlinVersion=1.3.50
2
+ AdadaptedReactNativeSdk_compileSdkVersion=28
3
+ AdadaptedReactNativeSdk_buildToolsVersion=28.0.3
4
+ AdadaptedReactNativeSdk_targetSdkVersion=28
@@ -0,0 +1,4 @@
1
+ <manifest xmlns:android="http://schemas.android.com/apk/res/android"
2
+ package="com.adadaptedreactnativesdk">
3
+
4
+ </manifest>
@@ -0,0 +1,115 @@
1
+ // See https://facebook.github.io/react-native/docs/native-modules-android
2
+ package com.adadaptedreactnativesdk;
3
+
4
+ import android.content.pm.PackageInfo;
5
+ import android.content.pm.PackageManager;
6
+ import android.util.DisplayMetrics;
7
+ import android.util.Log;
8
+ import org.json.*;
9
+ import java.io.IOException;
10
+ import java.util.Locale;
11
+ import java.util.TimeZone;
12
+ import com.facebook.react.bridge.ReactApplicationContext;
13
+ import com.facebook.react.bridge.ReactContextBaseJavaModule;
14
+ import com.facebook.react.bridge.ReactMethod;
15
+ import com.facebook.react.bridge.Promise;
16
+ import com.google.android.gms.ads.identifier.AdvertisingIdClient;
17
+ import com.google.android.gms.common.GooglePlayServicesNotAvailableException;
18
+ import com.google.android.gms.common.GooglePlayServicesRepairableException;
19
+ import android.telephony.TelephonyManager;
20
+ import android.content.Context;
21
+
22
+ class AdadaptedReactNativeSdkModule(val _reactContext: ReactApplicationContext) : ReactContextBaseJavaModule(_reactContext) {
23
+ val reactContext = _reactContext;
24
+
25
+ val TAG: String = "ReactNative";
26
+ val UNKNOWN_VALUE: String = "Unknown";
27
+
28
+ override fun getName(): String {
29
+ return "AdadaptedReactNativeSdk";
30
+ }
31
+
32
+ @ReactMethod
33
+ fun getDeviceInfo(promise: Promise) {
34
+ val deviceDisplayMetrics: DisplayMetrics = reactContext.getResources().getDisplayMetrics();
35
+ var gaidInfo: AdvertisingIdClient.Info? = null;
36
+ var bundleVersion: String = UNKNOWN_VALUE;
37
+ var deviceCarrier: String = "n/a";
38
+ var deviceWidth: Int = 0;
39
+ var deviceHeight: Int = 0;
40
+ var deviceDensity: String = "";
41
+ var gaid: String = "";
42
+ var adTrackingEnabled: Boolean = false;
43
+
44
+ val mTelephonyMgr: TelephonyManager = reactContext.getSystemService(Context.TELEPHONY_SERVICE) as TelephonyManager;
45
+
46
+ if (mTelephonyMgr != null && mTelephonyMgr.getNetworkOperatorName() != null) {
47
+ deviceCarrier = mTelephonyMgr.getNetworkOperatorName();
48
+ }
49
+
50
+ try {
51
+ gaidInfo = AdvertisingIdClient.getAdvertisingIdInfo(reactContext);
52
+ }
53
+ catch (ex: GooglePlayServicesNotAvailableException) {
54
+ logGaidException();
55
+ }
56
+ catch (ex: GooglePlayServicesRepairableException) {
57
+ logGaidException();
58
+ }
59
+ catch (ex: IOException) {
60
+ logGaidException();
61
+ }
62
+
63
+ try {
64
+ val packageInfo: PackageInfo = reactContext.getPackageManager().getPackageInfo(reactContext.getPackageName(), 0);
65
+
66
+ if (packageInfo != null) {
67
+ bundleVersion = packageInfo.versionName;
68
+ }
69
+ }
70
+ catch(ex: PackageManager.NameNotFoundException) {
71
+ bundleVersion = UNKNOWN_VALUE;
72
+ }
73
+
74
+ if (gaidInfo != null) {
75
+ gaid = gaidInfo.getId();
76
+ adTrackingEnabled = !gaidInfo.isLimitAdTrackingEnabled();
77
+ }
78
+
79
+ if (deviceDisplayMetrics != null) {
80
+ deviceWidth = deviceDisplayMetrics.widthPixels;
81
+ deviceHeight = deviceDisplayMetrics.heightPixels;
82
+ deviceDensity = deviceDisplayMetrics.density.toString();
83
+ }
84
+
85
+ // Create the HashMap that will be turned into a final JSON result.
86
+ var finalDeviceData: HashMap<String, Any> = HashMap<String, Any>();
87
+
88
+ finalDeviceData.put("udid", gaid);
89
+ finalDeviceData.put("deviceName", android.os.Build.DEVICE);
90
+ finalDeviceData.put("systemName", "android");
91
+ finalDeviceData.put("systemVersion", android.os.Build.VERSION.RELEASE);
92
+ finalDeviceData.put("deviceCarrier", deviceCarrier);
93
+ finalDeviceData.put("deviceModel", android.os.Build.MODEL);
94
+ finalDeviceData.put("deviceWidth", deviceWidth);
95
+ finalDeviceData.put("deviceHeight", deviceHeight);
96
+ finalDeviceData.put("deviceScreenDensity", deviceDensity);
97
+ finalDeviceData.put("deviceLocale", Locale.getDefault().toString());
98
+ finalDeviceData.put("bundleId", reactContext.getPackageName());
99
+ finalDeviceData.put("bundleVersion", bundleVersion);
100
+ finalDeviceData.put("deviceTimezone", TimeZone.getDefault().getID());
101
+ finalDeviceData.put("isAdTrackingEnabled", adTrackingEnabled);
102
+
103
+ promise.resolve(JSONObject(finalDeviceData as Map<*, *>?).toString());
104
+ }
105
+
106
+ fun logGaidException() {
107
+ Log.w(TAG, "Problem retrieving Google Play Advertiser Info");
108
+ Log.w(TAG, "GAID_UNAVAILABLE");
109
+ }
110
+
111
+ @ReactMethod
112
+ fun storeCurrentSessionId(sessionId: String) {
113
+ // noop
114
+ }
115
+ }
@@ -0,0 +1,20 @@
1
+ package com.adadaptedreactnativesdk
2
+
3
+ import java.util.Arrays
4
+ import java.util.Collections
5
+
6
+ import com.facebook.react.ReactPackage
7
+ import com.facebook.react.bridge.NativeModule
8
+ import com.facebook.react.bridge.ReactApplicationContext
9
+ import com.facebook.react.uimanager.ViewManager
10
+ import com.facebook.react.bridge.JavaScriptModule
11
+
12
+ class AdadaptedReactNativeSdkPackage : ReactPackage {
13
+ override fun createNativeModules(reactContext: ReactApplicationContext): List<NativeModule> {
14
+ return Arrays.asList<NativeModule>(AdadaptedReactNativeSdkModule(reactContext))
15
+ }
16
+
17
+ override fun createViewManagers(reactContext: ReactApplicationContext): List<ViewManager<*, *>> {
18
+ return emptyList<ViewManager<*, *>>()
19
+ }
20
+ }
@@ -29,7 +29,7 @@ android {
29
29
  compileSdkVersion getExtOrIntegerDefault('compileSdkVersion')
30
30
  buildToolsVersion getExtOrDefault('buildToolsVersion')
31
31
  defaultConfig {
32
- minSdkVersion 16
32
+ minSdkVersion 21
33
33
  targetSdkVersion getExtOrIntegerDefault('targetSdkVersion')
34
34
  versionCode 1
35
35
  versionName "1.0"
@@ -88,7 +88,7 @@ class AdZone extends React.Component {
88
88
  source: {
89
89
  uri: currentAd.creative_url
90
90
  },
91
- androidHardwareAccelerationDisabled: true,
91
+ androidLayerType: "hardware",
92
92
  automaticallyAdjustContentInsets: false,
93
93
  style: styles.webView,
94
94
  onTouchStart: e => {
@@ -1 +1 @@
1
- {"version":3,"sources":["AdZone.tsx"],"names":["AdZone","React","Component","constructor","props","context","startingAdIndex","Math","floor","random","adZoneData","ads","length","state","adIndexShown","touchStartCoords","undefined","componentDidMount","initializeAd","componentWillUnmount","cycleAdTimer","clearTimeout","render","styles","generateStyles","currentAd","finalMainViewStyle","mainView","creative_url","width","height","uri","webView","e","setState","x","nativeEvent","pageX","y","pageY","touchEndCoords","abs","xyDragDistanceAllowed","onAdZoneSelected","action_type","AdActionType","EXTERNAL","action_path","Linking","openURL","then","CONTENT","payload","detailed_list_items","onAddToListTriggered","triggerReportAdEvent","ReportedEventType","INTERACTION","cycleDisplayedAd","eventType","currentTs","round","Date","getTime","adadaptedApiRequests","reportAdEvent","app_id","appId","session_id","sessionId","udid","events","ad_id","impression_id","event_type","created_at","deviceOs","apiEnv","createAdTimer","timerLength","setTimeout","nextAdIndex","refresh_time","IMPRESSION","StyleSheet","create"],"mappings":";;;;;;;AAIA;;AACA;;AACA;;AACA;;AAOA;;AAEA;;;;;;;;AAwFA;AACA;AACA;AACO,MAAMA,MAAN,SAAqBC,KAAK,CAACC,SAA3B,CAAmD;AACtD;AACJ;AACA;AACA;;AAGI;AACJ;AACA;AACIC,EAAAA,WAAW,CAACC,KAAD,EAAeC,OAAf,EAA8B;AACrC,UAAMD,KAAN,EAAaC,OAAb,EADqC,CAGrC;;AAHqC;;AAIrC,UAAMC,eAAe,GAAGC,IAAI,CAACC,KAAL,CACpBD,IAAI,CAACE,MAAL,KAAgB,KAAKL,KAAL,CAAWM,UAAX,CAAsBC,GAAtB,CAA0BC,MADtB,CAAxB;AAIA,SAAKC,KAAL,GAAa;AACTC,MAAAA,YAAY,EAAER,eAD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AAG,CAAlB;;AAEA,QAAI,KAAKpE,KAAL,CAAWC,YAAX,GAA0B,KAAKV,KAAL,CAAWM,UAAX,CAAsBC,GAAtB,CAA0BC,MAA1B,GAAmC,CAAjE,EAAoE;AAChEqE,MAAAA,WAAW,GAAG,KAAKpE,KAAL,CAAWC,YAAX,GAA0B,CAAxC;AACH;;AAED,SAAKoB,QAAL,CACI;AACIpB,MAAAA,YAAY,EAAEmE;AADlB,KADJ,EAII,MAAM;AACF,WAAK/D,YAAL;AACH,KANL;AAQH;AAED;AACJ;AACA;;;AACYA,EAAAA,YAAR,GAA6B;AACzB;AACA,SAAK4D,aAAL,CACI,KAAK1E,KAAL,CAAWM,UAAX,CAAsBC,GAAtB,CAA0B,KAAKE,KAAL,CAAWC,YAArC,EAAmDoE,YAAnD,GACI,IAFR,EAFyB,CAOzB;;AACA,SAAK3B,oBAAL,CACI,KAAKnD,KAAL,CAAWM,UAAX,CAAsBC,GAAtB,CAA0B,KAAKE,KAAL,CAAWC,YAArC,CADJ,EAEI0C,qCAAkB2B,UAFtB;AAIH;AAED;AACJ;AACA;AACA;;;AACY3D,EAAAA,cAAR,GAAmC;AAC/B,WAAO4D,wBAAWC,MAAX,CAAkB;AACrB1D,MAAAA,QAAQ,EAAE;AACNE,QAAAA,KAAK,EAAE,MADD;AAENC,QAAAA,MAAM,EAAE;AAFF,OADW;AAKrBE,MAAAA,OAAO,EAAE;AACLH,QAAAA,KAAK,EAAE,MADF;AAELC,QAAAA,MAAM,EAAE;AAFH;AALY,KAAlB,CAAP;AAUH;;AA/OqD","sourcesContent":["/**\n * Component for creating an {@link AdZone}.\n * @module\n */\nimport * as React from \"react\";\nimport { Linking, StyleSheet, View, ViewStyle } from \"react-native\";\nimport * as adadaptedApiRequests from \"../api/adadaptedApiRequests\";\nimport {\n Ad,\n AdActionType,\n DetailedListItem,\n ReportedEventType,\n Zone,\n} from \"../api/adadaptedApiTypes\";\nimport { WebView } from \"react-native-webview\";\nimport { ApiEnv, DeviceOS } from \"../index\";\nimport { safeInvoke } from \"../util\";\n\n/**\n * Props interface for {@link AdZone}.\n */\ninterface Props {\n /**\n * The app ID.\n */\n appId: string;\n /**\n * The session ID.\n */\n sessionId: string;\n /**\n * The UDID.\n */\n udid: string;\n /**\n * The touch sensitivity of the Ad Zone in both the X and Y directions.\n * This is used to determine the click/press sensitivity when the\n * Ad Zone is being touched by the user as a regular touch or while\n * scrolling the view. If the amount of touch \"drag\" distance in either\n * X or Y direction is less than this value, we will treat the action as\n * a click/press on the Ad Zone.\n */\n xyDragDistanceAllowed: number;\n /**\n * The device OS used for API requests.\n */\n deviceOs: DeviceOS;\n /**\n * The API environment to use when making an API request.\n */\n apiEnv: ApiEnv;\n /**\n * The ad zone data.\n */\n adZoneData: Zone;\n /**\n * Callback that gets triggered when an \"add to list\" item/items are clicked.\n * @param items - The array of items to \"add to list\".\n */\n onAddToListTriggered?(items: DetailedListItem[]): void;\n}\n\n/**\n * State interface for {@link AdZone}.\n */\ninterface State {\n /**\n * Tracks the current ad index being shown.\n */\n adIndexShown: number;\n /**\n * Tracks the coordinates when the user started touching the Ad View.\n */\n touchStartCoords: TouchCoordinates | undefined;\n}\n\n/**\n * Interface for tracking \"touch\" coordinates.\n */\ninterface TouchCoordinates {\n /**\n * The X coordinate for the touch.\n */\n x: number;\n /**\n * The Y coordinate for the touch.\n */\n y: number;\n}\n\n/**\n * Defines the style typing for the component.\n */\ninterface StyleDef {\n /**\n * Styles for the main View element.\n */\n mainView: ViewStyle;\n /**\n * Styles for the WebView element.\n */\n webView: ViewStyle;\n}\n\n/**\n * Creates the AdZone component.\n */\nexport class AdZone extends React.Component<Props, State> {\n /**\n * Timer used for cycling through ads in the zone\n * based on the ad \"refresh time\" for each ad.\n */\n private cycleAdTimer: ReturnType<typeof setTimeout> | undefined;\n\n /**\n * @inheritDoc\n */\n constructor(props: Props, context?: any) {\n super(props, context);\n\n // Generates a random number between 0 and (number of available ads - 1).\n const startingAdIndex = Math.floor(\n Math.random() * this.props.adZoneData.ads.length\n );\n\n this.state = {\n adIndexShown: startingAdIndex,\n touchStartCoords: undefined,\n };\n }\n\n /**\n * @inheritDoc\n */\n public componentDidMount(): void {\n this.initializeAd();\n }\n\n /**\n * @inheritDoc\n */\n public componentWillUnmount(): void {\n if (this.cycleAdTimer) {\n clearTimeout(this.cycleAdTimer);\n }\n }\n\n /**\n * @inheritDoc\n */\n public render(): JSX.Element {\n // Generate the styles each render in case the ad is updated with\n // new settings that need to be reflected in the styles of the view.\n const styles = this.generateStyles();\n const currentAd: Ad | undefined =\n this.props.adZoneData.ads[this.state.adIndexShown] || undefined;\n const finalMainViewStyle = styles.mainView;\n\n if (!currentAd || !currentAd.creative_url) {\n // If there is no ad to display, make the view take up no space.\n finalMainViewStyle.width = 0;\n finalMainViewStyle.height = 0;\n }\n\n return (\n <View style={finalMainViewStyle}>\n {currentAd && currentAd.creative_url ? (\n <WebView\n source={{\n uri: currentAd.creative_url,\n }}\n androidHardwareAccelerationDisabled={true}\n automaticallyAdjustContentInsets={false}\n style={styles.webView}\n onTouchStart={(e) => {\n this.setState({\n touchStartCoords: {\n x: e.nativeEvent.pageX,\n y: e.nativeEvent.pageY,\n },\n });\n }}\n onTouchEnd={(e) => {\n if (this.state.touchStartCoords) {\n const touchEndCoords: TouchCoordinates = {\n x: e.nativeEvent.pageX,\n y: e.nativeEvent.pageY,\n };\n\n if (\n Math.abs(\n this.state.touchStartCoords.x -\n touchEndCoords.x\n ) < this.props.xyDragDistanceAllowed &&\n Math.abs(\n this.state.touchStartCoords.y -\n touchEndCoords.y\n ) < this.props.xyDragDistanceAllowed\n ) {\n this.onAdZoneSelected(currentAd);\n }\n\n // Make sure to reset the start coords\n this.setState({\n touchStartCoords: undefined,\n });\n }\n }}\n />\n ) : undefined}\n </View>\n );\n }\n\n /**\n * Triggers when the user selects the ad zone.\n * @param currentAd - The ad currently displayed.\n */\n private onAdZoneSelected(currentAd: Ad): void {\n // Determine the \"action type\" and perform that specific action.\n if (\n currentAd.action_type === AdActionType.EXTERNAL &&\n currentAd.action_path\n ) {\n // Action Type: EXTERNAL\n Linking.openURL(currentAd.action_path).then();\n } else if (\n currentAd.action_type === AdActionType.CONTENT &&\n currentAd.payload &&\n currentAd.payload.detailed_list_items\n ) {\n safeInvoke(\n this.props.onAddToListTriggered,\n currentAd.payload.detailed_list_items\n );\n }\n\n this.triggerReportAdEvent(currentAd, ReportedEventType.INTERACTION);\n if (this.cycleAdTimer) {\n clearTimeout(this.cycleAdTimer);\n }\n this.cycleDisplayedAd();\n }\n\n /**\n * Triggered when we need to report an ad event to the API.\n * @param currentAd - The ad to send an event for.\n * @param eventType - The event type for the reported event.\n */\n private triggerReportAdEvent(\n currentAd: Ad,\n eventType: ReportedEventType\n ): void {\n // The event timestamp has to be sent as a unix timestamp.\n const currentTs = Math.round(new Date().getTime() / 1000);\n\n // Log the taken action/event with the API.\n adadaptedApiRequests\n .reportAdEvent(\n {\n app_id: this.props.appId,\n session_id: this.props.sessionId,\n udid: this.props.udid,\n events: [\n {\n ad_id: currentAd.ad_id,\n impression_id: currentAd.impression_id,\n event_type: eventType,\n created_at: currentTs,\n },\n ],\n },\n this.props.deviceOs,\n this.props.apiEnv\n )\n .then(() => {\n // Do nothing with the response for now...\n });\n }\n\n /**\n * Generates a new timer for cycling to the next ad.\n * @param timerLength - The length of time(in milliseconds) to initialize\n * the timer with.\n */\n private createAdTimer(timerLength: number): void {\n if (this.props.adZoneData.ads.length > 0) {\n this.cycleAdTimer = setTimeout(() => {\n this.cycleDisplayedAd();\n }, timerLength);\n }\n }\n\n /**\n * Cycles to the next ad to display in the current available sequence of ads.\n */\n private cycleDisplayedAd(): void {\n // Start by determining the next ad index to display.\n let nextAdIndex = 0;\n\n if (this.state.adIndexShown < this.props.adZoneData.ads.length - 1) {\n nextAdIndex = this.state.adIndexShown + 1;\n }\n\n this.setState(\n {\n adIndexShown: nextAdIndex,\n },\n () => {\n this.initializeAd();\n }\n );\n }\n\n /**\n * Performs all ad initialization tasks when a new ad is being displayed.\n */\n private initializeAd(): void {\n // Create the new timer based on the new ad index.\n this.createAdTimer(\n this.props.adZoneData.ads[this.state.adIndexShown].refresh_time *\n 1000\n );\n\n // Trigger an impression event for the ad.\n this.triggerReportAdEvent(\n this.props.adZoneData.ads[this.state.adIndexShown],\n ReportedEventType.IMPRESSION\n );\n }\n\n /**\n * Generates all component related styles.\n * @returns the styles needed for the component.\n */\n private generateStyles(): StyleDef {\n return StyleSheet.create({\n mainView: {\n width: \"100%\",\n height: \"100%\",\n },\n webView: {\n width: \"100%\",\n height: \"100%\",\n },\n });\n }\n}\n"]}
1
+ {"version":3,"sources":["AdZone.tsx"],"names":["AdZone","React","Component","constructor","props","context","startingAdIndex","Math","floor","random","adZoneData","ads","length","state","adIndexShown","touchStartCoords","undefined","componentDidMount","initializeAd","componentWillUnmount","cycleAdTimer","clearTimeout","render","styles","generateStyles","currentAd","finalMainViewStyle","mainView","creative_url","width","height","uri","webView","e","setState","x","nativeEvent","pageX","y","pageY","touchEndCoords","abs","xyDragDistanceAllowed","onAdZoneSelected","action_type","AdActionType","EXTERNAL","action_path","Linking","openURL","then","CONTENT","payload","detailed_list_items","onAddToListTriggered","triggerReportAdEvent","ReportedEventType","INTERACTION","cycleDisplayedAd","eventType","currentTs","round","Date","getTime","adadaptedApiRequests","reportAdEvent","app_id","appId","session_id","sessionId","udid","events","ad_id","impression_id","event_type","created_at","deviceOs","apiEnv","createAdTimer","timerLength","setTimeout","nextAdIndex","refresh_time","IMPRESSION","StyleSheet","create"],"mappings":";;;;;;;AAIA;;AACA;;AACA;;AACA;;AAOA;;AAEA;;;;;;;;AAwFA;AACA;AACA;AACO,MAAMA,MAAN,SAAqBC,KAAK,CAACC,SAA3B,CAAmD;AACtD;AACJ;AACA;AACA;;AAGI;AACJ;AACA;AACIC,EAAAA,WAAW,CAACC,KAAD,EAAeC,OAAf,EAA8B;AACrC,UAAMD,KAAN,EAAaC,OAAb,EADqC,CAGrC;;AAHqC;;AAIrC,UAAMC,e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,YAAL,GAAoB4D,UAAU,CAAC,MAAM;AACjC,aAAKtB,gBAAL;AACH,OAF6B,EAE3BqB,WAF2B,CAA9B;AAGH;AACJ;AAED;AACJ;AACA;;;AACYrB,EAAAA,gBAAR,GAAiC;AAC7B;AACA,QAAIuB,WAAW,GAAG,CAAlB;;AAEA,QAAI,KAAKpE,KAAL,CAAWC,YAAX,GAA0B,KAAKV,KAAL,CAAWM,UAAX,CAAsBC,GAAtB,CAA0BC,MAA1B,GAAmC,CAAjE,EAAoE;AAChEqE,MAAAA,WAAW,GAAG,KAAKpE,KAAL,CAAWC,YAAX,GAA0B,CAAxC;AACH;;AAED,SAAKoB,QAAL,CACI;AACIpB,MAAAA,YAAY,EAAEmE;AADlB,KADJ,EAII,MAAM;AACF,WAAK/D,YAAL;AACH,KANL;AAQH;AAED;AACJ;AACA;;;AACYA,EAAAA,YAAR,GAA6B;AACzB;AACA,SAAK4D,aAAL,CACI,KAAK1E,KAAL,CAAWM,UAAX,CAAsBC,GAAtB,CAA0B,KAAKE,KAAL,CAAWC,YAArC,EAAmDoE,YAAnD,GACI,IAFR,EAFyB,CAOzB;;AACA,SAAK3B,oBAAL,CACI,KAAKnD,KAAL,CAAWM,UAAX,CAAsBC,GAAtB,CAA0B,KAAKE,KAAL,CAAWC,YAArC,CADJ,EAEI0C,qCAAkB2B,UAFtB;AAIH;AAED;AACJ;AACA;AACA;;;AACY3D,EAAAA,cAAR,GAAmC;AAC/B,WAAO4D,wBAAWC,MAAX,CAAkB;AACrB1D,MAAAA,QAAQ,EAAE;AACNE,QAAAA,KAAK,EAAE,MADD;AAENC,QAAAA,MAAM,EAAE;AAFF,OADW;AAKrBE,MAAAA,OAAO,EAAE;AACLH,QAAAA,KAAK,EAAE,MADF;AAELC,QAAAA,MAAM,EAAE;AAFH;AALY,KAAlB,CAAP;AAUH;;AA/OqD","sourcesContent":["/**\n * Component for creating an {@link AdZone}.\n * @module\n */\nimport * as React from \"react\";\nimport { Linking, StyleSheet, View, ViewStyle } from \"react-native\";\nimport * as adadaptedApiRequests from \"../api/adadaptedApiRequests\";\nimport {\n Ad,\n AdActionType,\n DetailedListItem,\n ReportedEventType,\n Zone,\n} from \"../api/adadaptedApiTypes\";\nimport { WebView } from \"react-native-webview\";\nimport { ApiEnv, DeviceOS } from \"../index\";\nimport { safeInvoke } from \"../util\";\n\n/**\n * Props interface for {@link AdZone}.\n */\ninterface Props {\n /**\n * The app ID.\n */\n appId: string;\n /**\n * The session ID.\n */\n sessionId: string;\n /**\n * The UDID.\n */\n udid: string;\n /**\n * The touch sensitivity of the Ad Zone in both the X and Y directions.\n * This is used to determine the click/press sensitivity when the\n * Ad Zone is being touched by the user as a regular touch or while\n * scrolling the view. If the amount of touch \"drag\" distance in either\n * X or Y direction is less than this value, we will treat the action as\n * a click/press on the Ad Zone.\n */\n xyDragDistanceAllowed: number;\n /**\n * The device OS used for API requests.\n */\n deviceOs: DeviceOS;\n /**\n * The API environment to use when making an API request.\n */\n apiEnv: ApiEnv;\n /**\n * The ad zone data.\n */\n adZoneData: Zone;\n /**\n * Callback that gets triggered when an \"add to list\" item/items are clicked.\n * @param items - The array of items to \"add to list\".\n */\n onAddToListTriggered?(items: DetailedListItem[]): void;\n}\n\n/**\n * State interface for {@link AdZone}.\n */\ninterface State {\n /**\n * Tracks the current ad index being shown.\n */\n adIndexShown: number;\n /**\n * Tracks the coordinates when the user started touching the Ad View.\n */\n touchStartCoords: TouchCoordinates | undefined;\n}\n\n/**\n * Interface for tracking \"touch\" coordinates.\n */\ninterface TouchCoordinates {\n /**\n * The X coordinate for the touch.\n */\n x: number;\n /**\n * The Y coordinate for the touch.\n */\n y: number;\n}\n\n/**\n * Defines the style typing for the component.\n */\ninterface StyleDef {\n /**\n * Styles for the main View element.\n */\n mainView: ViewStyle;\n /**\n * Styles for the WebView element.\n */\n webView: ViewStyle;\n}\n\n/**\n * Creates the AdZone component.\n */\nexport class AdZone extends React.Component<Props, State> {\n /**\n * Timer used for cycling through ads in the zone\n * based on the ad \"refresh time\" for each ad.\n */\n private cycleAdTimer: ReturnType<typeof setTimeout> | undefined;\n\n /**\n * @inheritDoc\n */\n constructor(props: Props, context?: any) {\n super(props, context);\n\n // Generates a random number between 0 and (number of available ads - 1).\n const startingAdIndex = Math.floor(\n Math.random() * this.props.adZoneData.ads.length\n );\n\n this.state = {\n adIndexShown: startingAdIndex,\n touchStartCoords: undefined,\n };\n }\n\n /**\n * @inheritDoc\n */\n public componentDidMount(): void {\n this.initializeAd();\n }\n\n /**\n * @inheritDoc\n */\n public componentWillUnmount(): void {\n if (this.cycleAdTimer) {\n clearTimeout(this.cycleAdTimer);\n }\n }\n\n /**\n * @inheritDoc\n */\n public render(): JSX.Element {\n // Generate the styles each render in case the ad is updated with\n // new settings that need to be reflected in the styles of the view.\n const styles = this.generateStyles();\n const currentAd: Ad | undefined =\n this.props.adZoneData.ads[this.state.adIndexShown] || undefined;\n const finalMainViewStyle = styles.mainView;\n\n if (!currentAd || !currentAd.creative_url) {\n // If there is no ad to display, make the view take up no space.\n finalMainViewStyle.width = 0;\n finalMainViewStyle.height = 0;\n }\n\n return (\n <View style={finalMainViewStyle}>\n {currentAd && currentAd.creative_url ? (\n <WebView\n source={{\n uri: currentAd.creative_url,\n }}\n androidLayerType=\"hardware\"\n automaticallyAdjustContentInsets={false}\n style={styles.webView}\n onTouchStart={(e) => {\n this.setState({\n touchStartCoords: {\n x: e.nativeEvent.pageX,\n y: e.nativeEvent.pageY,\n },\n });\n }}\n onTouchEnd={(e) => {\n if (this.state.touchStartCoords) {\n const touchEndCoords: TouchCoordinates = {\n x: e.nativeEvent.pageX,\n y: e.nativeEvent.pageY,\n };\n\n if (\n Math.abs(\n this.state.touchStartCoords.x -\n touchEndCoords.x\n ) < this.props.xyDragDistanceAllowed &&\n Math.abs(\n this.state.touchStartCoords.y -\n touchEndCoords.y\n ) < this.props.xyDragDistanceAllowed\n ) {\n this.onAdZoneSelected(currentAd);\n }\n\n // Make sure to reset the start coords\n this.setState({\n touchStartCoords: undefined,\n });\n }\n }}\n />\n ) : undefined}\n </View>\n );\n }\n\n /**\n * Triggers when the user selects the ad zone.\n * @param currentAd - The ad currently displayed.\n */\n private onAdZoneSelected(currentAd: Ad): void {\n // Determine the \"action type\" and perform that specific action.\n if (\n currentAd.action_type === AdActionType.EXTERNAL &&\n currentAd.action_path\n ) {\n // Action Type: EXTERNAL\n Linking.openURL(currentAd.action_path).then();\n } else if (\n currentAd.action_type === AdActionType.CONTENT &&\n currentAd.payload &&\n currentAd.payload.detailed_list_items\n ) {\n safeInvoke(\n this.props.onAddToListTriggered,\n currentAd.payload.detailed_list_items\n );\n }\n\n this.triggerReportAdEvent(currentAd, ReportedEventType.INTERACTION);\n if (this.cycleAdTimer) {\n clearTimeout(this.cycleAdTimer);\n }\n this.cycleDisplayedAd();\n }\n\n /**\n * Triggered when we need to report an ad event to the API.\n * @param currentAd - The ad to send an event for.\n * @param eventType - The event type for the reported event.\n */\n private triggerReportAdEvent(\n currentAd: Ad,\n eventType: ReportedEventType\n ): void {\n // The event timestamp has to be sent as a unix timestamp.\n const currentTs = Math.round(new Date().getTime() / 1000);\n\n // Log the taken action/event with the API.\n adadaptedApiRequests\n .reportAdEvent(\n {\n app_id: this.props.appId,\n session_id: this.props.sessionId,\n udid: this.props.udid,\n events: [\n {\n ad_id: currentAd.ad_id,\n impression_id: currentAd.impression_id,\n event_type: eventType,\n created_at: currentTs,\n },\n ],\n },\n this.props.deviceOs,\n this.props.apiEnv\n )\n .then(() => {\n // Do nothing with the response for now...\n });\n }\n\n /**\n * Generates a new timer for cycling to the next ad.\n * @param timerLength - The length of time(in milliseconds) to initialize\n * the timer with.\n */\n private createAdTimer(timerLength: number): void {\n if (this.props.adZoneData.ads.length > 0) {\n this.cycleAdTimer = setTimeout(() => {\n this.cycleDisplayedAd();\n }, timerLength);\n }\n }\n\n /**\n * Cycles to the next ad to display in the current available sequence of ads.\n */\n private cycleDisplayedAd(): void {\n // Start by determining the next ad index to display.\n let nextAdIndex = 0;\n\n if (this.state.adIndexShown < this.props.adZoneData.ads.length - 1) {\n nextAdIndex = this.state.adIndexShown + 1;\n }\n\n this.setState(\n {\n adIndexShown: nextAdIndex,\n },\n () => {\n this.initializeAd();\n }\n );\n }\n\n /**\n * Performs all ad initialization tasks when a new ad is being displayed.\n */\n private initializeAd(): void {\n // Create the new timer based on the new ad index.\n this.createAdTimer(\n this.props.adZoneData.ads[this.state.adIndexShown].refresh_time *\n 1000\n );\n\n // Trigger an impression event for the ad.\n this.triggerReportAdEvent(\n this.props.adZoneData.ads[this.state.adIndexShown],\n ReportedEventType.IMPRESSION\n );\n }\n\n /**\n * Generates all component related styles.\n * @returns the styles needed for the component.\n */\n private generateStyles(): StyleDef {\n return StyleSheet.create({\n mainView: {\n width: \"100%\",\n height: \"100%\",\n },\n webView: {\n width: \"100%\",\n height: \"100%\",\n },\n });\n }\n}\n"]}
@@ -79,7 +79,7 @@ export class AdZone extends React.Component {
79
79
  source: {
80
80
  uri: currentAd.creative_url
81
81
  },
82
- androidHardwareAccelerationDisabled: true,
82
+ androidLayerType: "hardware",
83
83
  automaticallyAdjustContentInsets: false,
84
84
  style: styles.webView,
85
85
  onTouchStart: e => {
@@ -1 +1 @@
1
- {"version":3,"sources":["AdZone.tsx"],"names":["React","Linking","StyleSheet","View","adadaptedApiRequests","AdActionType","ReportedEventType","WebView","safeInvoke","AdZone","Component","constructor","props","context","startingAdIndex","Math","floor","random","adZoneData","ads","length","state","adIndexShown","touchStartCoords","undefined","componentDidMount","initializeAd","componentWillUnmount","cycleAdTimer","clearTimeout","render","styles","generateStyles","currentAd","finalMainViewStyle","mainView","creative_url","width","height","uri","webView","e","setState","x","nativeEvent","pageX","y","pageY","touchEndCoords","abs","xyDragDistanceAllowed","onAdZoneSelected","action_type","EXTERNAL","action_path","openURL","then","CONTENT","payload","detailed_list_items","onAddToListTriggered","triggerReportAdEvent","INTERACTION","cycleDisplayedAd","eventType","currentTs","round","Date","getTime","reportAdEvent","app_id","appId","session_id","sessionId","udid","events","ad_id","impression_id","event_type","created_at","deviceOs","apiEnv","createAdTimer","timerLength","setTimeout","nextAdIndex","refresh_time","IMPRESSION","create"],"mappings":";;AAAA;AACA;AACA;AACA;AACA,OAAO,KAAKA,KAAZ,MAAuB,OAAvB;AACA,SAASC,OAAT,EAAkBC,UAAlB,EAA8BC,IAA9B,QAAqD,cAArD;AACA,OAAO,KAAKC,oBAAZ,MAAsC,6BAAtC;AACA,SAEIC,YAFJ,EAIIC,iBAJJ,QAMO,0BANP;AAOA,SAASC,OAAT,QAAwB,sBAAxB;AAEA,SAASC,UAAT,QAA2B,SAA3B;AAEA;AACA;AACA;;AAoFA;AACA;AACA;AACA,OAAO,MAAMC,MAAN,SAAqBT,KAAK,CAACU,SAA3B,CAAmD;AACtD;AACJ;AACA;AACA;;AAGI;AACJ;AACA;AACIC,EAAAA,WAAW,CAACC,KAAD,EAAeC,OAAf,EAA8B;AACrC,UAAMD,KAAN,EAAaC,OAAb,EADqC,CAGrC;;AAHqC;;AAIrC,UAAMC,eAAe,GAAGC,IAAI,CAACC,KAAL,CACpBD,IAAI,CAACE,MAAL,KAAgB,KAAKL,KAAL,CAAWM,UAAX,CAAsBC,GAAtB,CAA0BC,MADtB,CAAxB;AAIA,SAAKC,KAAL,GAAa;AACTC,MAAAA,YAAY,EAAER,eADL;AAETS,MAAAA,gBAAgB,EAAEC;AAFT,KAAb;AAIH;AAED;AACJ;AACA;;;AACWC,EAAAA,iBAAP,GAAiC;AAC7B,SAAKC,YAAL;AACH;AAED;AACJ;AACA;;;AACWC,EAAAA,oBAAP,GAAoC;AAChC,QAAI,KAAKC,YAAT,EAAuB;AACnBC,MAAAA,YAAY,CAAC,KAAKD,YAAN,CAAZ;AACH;AACJ;AAED;AACJ;AACA;;;AACWE,EAAAA,MAAP,GAA6B;AACzB;AACA;AACA,UAAMC,MAAM,GAAG,KAAKC,cAAL,EAAf;AACA,UAAMC,SAAyB,GAC3B,KAAKrB,KAAL,CAAWM,UAAX,CAAsB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;AACzB;AACA,SAAKwD,aAAL,CACI,KAAKtE,KAAL,CAAWM,UAAX,CAAsBC,GAAtB,CAA0B,KAAKE,KAAL,CAAWC,YAArC,EAAmDgE,YAAnD,GACI,IAFR,EAFyB,CAOzB;;AACA,SAAKzB,oBAAL,CACI,KAAKjD,KAAL,CAAWM,UAAX,CAAsBC,GAAtB,CAA0B,KAAKE,KAAL,CAAWC,YAArC,CADJ,EAEIhB,iBAAiB,CAACiF,UAFtB;AAIH;AAED;AACJ;AACA;AACA;;;AACYvD,EAAAA,cAAR,GAAmC;AAC/B,WAAO9B,UAAU,CAACsF,MAAX,CAAkB;AACrBrD,MAAAA,QAAQ,EAAE;AACNE,QAAAA,KAAK,EAAE,MADD;AAENC,QAAAA,MAAM,EAAE;AAFF,OADW;AAKrBE,MAAAA,OAAO,EAAE;AACLH,QAAAA,KAAK,EAAE,MADF;AAELC,QAAAA,MAAM,EAAE;AAFH;AALY,KAAlB,CAAP;AAUH;;AA/OqD","sourcesContent":["/**\n * Component for creating an {@link AdZone}.\n * @module\n */\nimport * as React from \"react\";\nimport { Linking, StyleSheet, View, ViewStyle } from \"react-native\";\nimport * as adadaptedApiRequests from \"../api/adadaptedApiRequests\";\nimport {\n Ad,\n AdActionType,\n DetailedListItem,\n ReportedEventType,\n Zone,\n} from \"../api/adadaptedApiTypes\";\nimport { WebView } from \"react-native-webview\";\nimport { ApiEnv, DeviceOS } from \"../index\";\nimport { safeInvoke } from \"../util\";\n\n/**\n * Props interface for {@link AdZone}.\n */\ninterface Props {\n /**\n * The app ID.\n */\n appId: string;\n /**\n * The session ID.\n */\n sessionId: string;\n /**\n * The UDID.\n */\n udid: string;\n /**\n * The touch sensitivity of the Ad Zone in both the X and Y directions.\n * This is used to determine the click/press sensitivity when the\n * Ad Zone is being touched by the user as a regular touch or while\n * scrolling the view. If the amount of touch \"drag\" distance in either\n * X or Y direction is less than this value, we will treat the action as\n * a click/press on the Ad Zone.\n */\n xyDragDistanceAllowed: number;\n /**\n * The device OS used for API requests.\n */\n deviceOs: DeviceOS;\n /**\n * The API environment to use when making an API request.\n */\n apiEnv: ApiEnv;\n /**\n * The ad zone data.\n */\n adZoneData: Zone;\n /**\n * Callback that gets triggered when an \"add to list\" item/items are clicked.\n * @param items - The array of items to \"add to list\".\n */\n onAddToListTriggered?(items: DetailedListItem[]): void;\n}\n\n/**\n * State interface for {@link AdZone}.\n */\ninterface State {\n /**\n * Tracks the current ad index being shown.\n */\n adIndexShown: number;\n /**\n * Tracks the coordinates when the user started touching the Ad View.\n */\n touchStartCoords: TouchCoordinates | undefined;\n}\n\n/**\n * Interface for tracking \"touch\" coordinates.\n */\ninterface TouchCoordinates {\n /**\n * The X coordinate for the touch.\n */\n x: number;\n /**\n * The Y coordinate for the touch.\n */\n y: number;\n}\n\n/**\n * Defines the style typing for the component.\n */\ninterface StyleDef {\n /**\n * Styles for the main View element.\n */\n mainView: ViewStyle;\n /**\n * Styles for the WebView element.\n */\n webView: ViewStyle;\n}\n\n/**\n * Creates the AdZone component.\n */\nexport class AdZone extends React.Component<Props, State> {\n /**\n * Timer used for cycling through ads in the zone\n * based on the ad \"refresh time\" for each ad.\n */\n private cycleAdTimer: ReturnType<typeof setTimeout> | undefined;\n\n /**\n * @inheritDoc\n */\n constructor(props: Props, context?: any) {\n super(props, context);\n\n // Generates a random number between 0 and (number of available ads - 1).\n const startingAdIndex = Math.floor(\n Math.random() * this.props.adZoneData.ads.length\n );\n\n this.state = {\n adIndexShown: startingAdIndex,\n touchStartCoords: undefined,\n };\n }\n\n /**\n * @inheritDoc\n */\n public componentDidMount(): void {\n this.initializeAd();\n }\n\n /**\n * @inheritDoc\n */\n public componentWillUnmount(): void {\n if (this.cycleAdTimer) {\n clearTimeout(this.cycleAdTimer);\n }\n }\n\n /**\n * @inheritDoc\n */\n public render(): JSX.Element {\n // Generate the styles each render in case the ad is updated with\n // new settings that need to be reflected in the styles of the view.\n const styles = this.generateStyles();\n const currentAd: Ad | undefined =\n this.props.adZoneData.ads[this.state.adIndexShown] || undefined;\n const finalMainViewStyle = styles.mainView;\n\n if (!currentAd || !currentAd.creative_url) {\n // If there is no ad to display, make the view take up no space.\n finalMainViewStyle.width = 0;\n finalMainViewStyle.height = 0;\n }\n\n return (\n <View style={finalMainViewStyle}>\n {currentAd && currentAd.creative_url ? (\n <WebView\n source={{\n uri: currentAd.creative_url,\n }}\n androidHardwareAccelerationDisabled={true}\n automaticallyAdjustContentInsets={false}\n style={styles.webView}\n onTouchStart={(e) => {\n this.setState({\n touchStartCoords: {\n x: e.nativeEvent.pageX,\n y: e.nativeEvent.pageY,\n },\n });\n }}\n onTouchEnd={(e) => {\n if (this.state.touchStartCoords) {\n const touchEndCoords: TouchCoordinates = {\n x: e.nativeEvent.pageX,\n y: e.nativeEvent.pageY,\n };\n\n if (\n Math.abs(\n this.state.touchStartCoords.x -\n touchEndCoords.x\n ) < this.props.xyDragDistanceAllowed &&\n Math.abs(\n this.state.touchStartCoords.y -\n touchEndCoords.y\n ) < this.props.xyDragDistanceAllowed\n ) {\n this.onAdZoneSelected(currentAd);\n }\n\n // Make sure to reset the start coords\n this.setState({\n touchStartCoords: undefined,\n });\n }\n }}\n />\n ) : undefined}\n </View>\n );\n }\n\n /**\n * Triggers when the user selects the ad zone.\n * @param currentAd - The ad currently displayed.\n */\n private onAdZoneSelected(currentAd: Ad): void {\n // Determine the \"action type\" and perform that specific action.\n if (\n currentAd.action_type === AdActionType.EXTERNAL &&\n currentAd.action_path\n ) {\n // Action Type: EXTERNAL\n Linking.openURL(currentAd.action_path).then();\n } else if (\n currentAd.action_type === AdActionType.CONTENT &&\n currentAd.payload &&\n currentAd.payload.detailed_list_items\n ) {\n safeInvoke(\n this.props.onAddToListTriggered,\n currentAd.payload.detailed_list_items\n );\n }\n\n this.triggerReportAdEvent(currentAd, ReportedEventType.INTERACTION);\n if (this.cycleAdTimer) {\n clearTimeout(this.cycleAdTimer);\n }\n this.cycleDisplayedAd();\n }\n\n /**\n * Triggered when we need to report an ad event to the API.\n * @param currentAd - The ad to send an event for.\n * @param eventType - The event type for the reported event.\n */\n private triggerReportAdEvent(\n currentAd: Ad,\n eventType: ReportedEventType\n ): void {\n // The event timestamp has to be sent as a unix timestamp.\n const currentTs = Math.round(new Date().getTime() / 1000);\n\n // Log the taken action/event with the API.\n adadaptedApiRequests\n .reportAdEvent(\n {\n app_id: this.props.appId,\n session_id: this.props.sessionId,\n udid: this.props.udid,\n events: [\n {\n ad_id: currentAd.ad_id,\n impression_id: currentAd.impression_id,\n event_type: eventType,\n created_at: currentTs,\n },\n ],\n },\n this.props.deviceOs,\n this.props.apiEnv\n )\n .then(() => {\n // Do nothing with the response for now...\n });\n }\n\n /**\n * Generates a new timer for cycling to the next ad.\n * @param timerLength - The length of time(in milliseconds) to initialize\n * the timer with.\n */\n private createAdTimer(timerLength: number): void {\n if (this.props.adZoneData.ads.length > 0) {\n this.cycleAdTimer = setTimeout(() => {\n this.cycleDisplayedAd();\n }, timerLength);\n }\n }\n\n /**\n * Cycles to the next ad to display in the current available sequence of ads.\n */\n private cycleDisplayedAd(): void {\n // Start by determining the next ad index to display.\n let nextAdIndex = 0;\n\n if (this.state.adIndexShown < this.props.adZoneData.ads.length - 1) {\n nextAdIndex = this.state.adIndexShown + 1;\n }\n\n this.setState(\n {\n adIndexShown: nextAdIndex,\n },\n () => {\n this.initializeAd();\n }\n );\n }\n\n /**\n * Performs all ad initialization tasks when a new ad is being displayed.\n */\n private initializeAd(): void {\n // Create the new timer based on the new ad index.\n this.createAdTimer(\n this.props.adZoneData.ads[this.state.adIndexShown].refresh_time *\n 1000\n );\n\n // Trigger an impression event for the ad.\n this.triggerReportAdEvent(\n this.props.adZoneData.ads[this.state.adIndexShown],\n ReportedEventType.IMPRESSION\n );\n }\n\n /**\n * Generates all component related styles.\n * @returns the styles needed for the component.\n */\n private generateStyles(): StyleDef {\n return StyleSheet.create({\n mainView: {\n width: \"100%\",\n height: \"100%\",\n },\n webView: {\n width: \"100%\",\n height: \"100%\",\n },\n });\n }\n}\n"]}
1
+ {"version":3,"sources":["AdZone.tsx"],"names":["React","Linking","StyleSheet","View","adadaptedApiRequests","AdActionType","ReportedEventType","WebView","safeInvoke","AdZone","Component","constructor","props","context","startingAdIndex","Math","floor","random","adZoneData","ads","length","state","adIndexShown","touchStartCoords","undefined","componentDidMount","initializeAd","componentWillUnmount","cycleAdTimer","clearTimeout","render","styles","generateStyles","currentAd","finalMainViewStyle","mainView","creative_url","width","height","uri","webView","e","setState","x","nativeEvent","pageX","y","pageY","touchEndCoords","abs","xyDragDistanceAllowed","onAdZoneSelected","action_type","EXTERNAL","action_path","openURL","then","CONTENT","payload","detailed_list_items","onAddToListTriggered","triggerReportAdEvent","INTERACTION","cycleDisplayedAd","eventType","currentTs","round","Date","getTime","reportAdEvent","app_id","appId","session_id","sessionId","udid","events","ad_id","impression_id","event_type","created_at","deviceOs","apiEnv","createAdTimer","timerLength","setTimeout","nextAdIndex","refresh_time","IMPRESSION","create"],"mappings":";;AAAA;AACA;AACA;AACA;AACA,OAAO,KAAKA,KAAZ,MAAuB,OAAvB;AACA,SAASC,OAAT,EAAkBC,UAAlB,EAA8BC,IAA9B,QAAqD,cAArD;AACA,OAAO,KAAKC,oBAAZ,MAAsC,6BAAtC;AACA,SAEIC,YAFJ,EAIIC,iBAJJ,QAMO,0BANP;AAOA,SAASC,OAAT,QAAwB,sBAAxB;AAEA,SAASC,UAAT,QAA2B,SAA3B;AAEA;AACA;AACA;;AAoFA;AACA;AACA;AACA,OAAO,MAAMC,MAAN,SAAqBT,KAAK,CAACU,SAA3B,CAAmD;AACtD;AACJ;AACA;AACA;;AAGI;AACJ;AACA;AACIC,EAAAA,WAAW,CAACC,KAAD,EAAeC,OAAf,EAA8B;AACrC,UAAMD,KAAN,EAAaC,OAAb,EADqC,CAGrC;;AAHqC;;AAIrC,UAAMC,eAAe,GAAGC,IAAI,CAACC,KAAL,CACpBD,IAAI,CAACE,MAAL,KAAgB,KAAKL,KAAL,CAAWM,UAAX,CAAsBC,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AAL;AACH,OAF6B,EAE3BoB,WAF2B,CAA9B;AAGH;AACJ;AAED;AACJ;AACA;;;AACYpB,EAAAA,gBAAR,GAAiC;AAC7B;AACA,QAAIsB,WAAW,GAAG,CAAlB;;AAEA,QAAI,KAAKhE,KAAL,CAAWC,YAAX,GAA0B,KAAKV,KAAL,CAAWM,UAAX,CAAsBC,GAAtB,CAA0BC,MAA1B,GAAmC,CAAjE,EAAoE;AAChEiE,MAAAA,WAAW,GAAG,KAAKhE,KAAL,CAAWC,YAAX,GAA0B,CAAxC;AACH;;AAED,SAAKoB,QAAL,CACI;AACIpB,MAAAA,YAAY,EAAE+D;AADlB,KADJ,EAII,MAAM;AACF,WAAK3D,YAAL;AACH,KANL;AAQH;AAED;AACJ;AACA;;;AACYA,EAAAA,YAAR,GAA6B;AACzB;AACA,SAAKwD,aAAL,CACI,KAAKtE,KAAL,CAAWM,UAAX,CAAsBC,GAAtB,CAA0B,KAAKE,KAAL,CAAWC,YAArC,EAAmDgE,YAAnD,GACI,IAFR,EAFyB,CAOzB;;AACA,SAAKzB,oBAAL,CACI,KAAKjD,KAAL,CAAWM,UAAX,CAAsBC,GAAtB,CAA0B,KAAKE,KAAL,CAAWC,YAArC,CADJ,EAEIhB,iBAAiB,CAACiF,UAFtB;AAIH;AAED;AACJ;AACA;AACA;;;AACYvD,EAAAA,cAAR,GAAmC;AAC/B,WAAO9B,UAAU,CAACsF,MAAX,CAAkB;AACrBrD,MAAAA,QAAQ,EAAE;AACNE,QAAAA,KAAK,EAAE,MADD;AAENC,QAAAA,MAAM,EAAE;AAFF,OADW;AAKrBE,MAAAA,OAAO,EAAE;AACLH,QAAAA,KAAK,EAAE,MADF;AAELC,QAAAA,MAAM,EAAE;AAFH;AALY,KAAlB,CAAP;AAUH;;AA/OqD","sourcesContent":["/**\n * Component for creating an {@link AdZone}.\n * @module\n */\nimport * as React from \"react\";\nimport { Linking, StyleSheet, View, ViewStyle } from \"react-native\";\nimport * as adadaptedApiRequests from \"../api/adadaptedApiRequests\";\nimport {\n Ad,\n AdActionType,\n DetailedListItem,\n ReportedEventType,\n Zone,\n} from \"../api/adadaptedApiTypes\";\nimport { WebView } from \"react-native-webview\";\nimport { ApiEnv, DeviceOS } from \"../index\";\nimport { safeInvoke } from \"../util\";\n\n/**\n * Props interface for {@link AdZone}.\n */\ninterface Props {\n /**\n * The app ID.\n */\n appId: string;\n /**\n * The session ID.\n */\n sessionId: string;\n /**\n * The UDID.\n */\n udid: string;\n /**\n * The touch sensitivity of the Ad Zone in both the X and Y directions.\n * This is used to determine the click/press sensitivity when the\n * Ad Zone is being touched by the user as a regular touch or while\n * scrolling the view. If the amount of touch \"drag\" distance in either\n * X or Y direction is less than this value, we will treat the action as\n * a click/press on the Ad Zone.\n */\n xyDragDistanceAllowed: number;\n /**\n * The device OS used for API requests.\n */\n deviceOs: DeviceOS;\n /**\n * The API environment to use when making an API request.\n */\n apiEnv: ApiEnv;\n /**\n * The ad zone data.\n */\n adZoneData: Zone;\n /**\n * Callback that gets triggered when an \"add to list\" item/items are clicked.\n * @param items - The array of items to \"add to list\".\n */\n onAddToListTriggered?(items: DetailedListItem[]): void;\n}\n\n/**\n * State interface for {@link AdZone}.\n */\ninterface State {\n /**\n * Tracks the current ad index being shown.\n */\n adIndexShown: number;\n /**\n * Tracks the coordinates when the user started touching the Ad View.\n */\n touchStartCoords: TouchCoordinates | undefined;\n}\n\n/**\n * Interface for tracking \"touch\" coordinates.\n */\ninterface TouchCoordinates {\n /**\n * The X coordinate for the touch.\n */\n x: number;\n /**\n * The Y coordinate for the touch.\n */\n y: number;\n}\n\n/**\n * Defines the style typing for the component.\n */\ninterface StyleDef {\n /**\n * Styles for the main View element.\n */\n mainView: ViewStyle;\n /**\n * Styles for the WebView element.\n */\n webView: ViewStyle;\n}\n\n/**\n * Creates the AdZone component.\n */\nexport class AdZone extends React.Component<Props, State> {\n /**\n * Timer used for cycling through ads in the zone\n * based on the ad \"refresh time\" for each ad.\n */\n private cycleAdTimer: ReturnType<typeof setTimeout> | undefined;\n\n /**\n * @inheritDoc\n */\n constructor(props: Props, context?: any) {\n super(props, context);\n\n // Generates a random number between 0 and (number of available ads - 1).\n const startingAdIndex = Math.floor(\n Math.random() * this.props.adZoneData.ads.length\n );\n\n this.state = {\n adIndexShown: startingAdIndex,\n touchStartCoords: undefined,\n };\n }\n\n /**\n * @inheritDoc\n */\n public componentDidMount(): void {\n this.initializeAd();\n }\n\n /**\n * @inheritDoc\n */\n public componentWillUnmount(): void {\n if (this.cycleAdTimer) {\n clearTimeout(this.cycleAdTimer);\n }\n }\n\n /**\n * @inheritDoc\n */\n public render(): JSX.Element {\n // Generate the styles each render in case the ad is updated with\n // new settings that need to be reflected in the styles of the view.\n const styles = this.generateStyles();\n const currentAd: Ad | undefined =\n this.props.adZoneData.ads[this.state.adIndexShown] || undefined;\n const finalMainViewStyle = styles.mainView;\n\n if (!currentAd || !currentAd.creative_url) {\n // If there is no ad to display, make the view take up no space.\n finalMainViewStyle.width = 0;\n finalMainViewStyle.height = 0;\n }\n\n return (\n <View style={finalMainViewStyle}>\n {currentAd && currentAd.creative_url ? (\n <WebView\n source={{\n uri: currentAd.creative_url,\n }}\n androidLayerType=\"hardware\"\n automaticallyAdjustContentInsets={false}\n style={styles.webView}\n onTouchStart={(e) => {\n this.setState({\n touchStartCoords: {\n x: e.nativeEvent.pageX,\n y: e.nativeEvent.pageY,\n },\n });\n }}\n onTouchEnd={(e) => {\n if (this.state.touchStartCoords) {\n const touchEndCoords: TouchCoordinates = {\n x: e.nativeEvent.pageX,\n y: e.nativeEvent.pageY,\n };\n\n if (\n Math.abs(\n this.state.touchStartCoords.x -\n touchEndCoords.x\n ) < this.props.xyDragDistanceAllowed &&\n Math.abs(\n this.state.touchStartCoords.y -\n touchEndCoords.y\n ) < this.props.xyDragDistanceAllowed\n ) {\n this.onAdZoneSelected(currentAd);\n }\n\n // Make sure to reset the start coords\n this.setState({\n touchStartCoords: undefined,\n });\n }\n }}\n />\n ) : undefined}\n </View>\n );\n }\n\n /**\n * Triggers when the user selects the ad zone.\n * @param currentAd - The ad currently displayed.\n */\n private onAdZoneSelected(currentAd: Ad): void {\n // Determine the \"action type\" and perform that specific action.\n if (\n currentAd.action_type === AdActionType.EXTERNAL &&\n currentAd.action_path\n ) {\n // Action Type: EXTERNAL\n Linking.openURL(currentAd.action_path).then();\n } else if (\n currentAd.action_type === AdActionType.CONTENT &&\n currentAd.payload &&\n currentAd.payload.detailed_list_items\n ) {\n safeInvoke(\n this.props.onAddToListTriggered,\n currentAd.payload.detailed_list_items\n );\n }\n\n this.triggerReportAdEvent(currentAd, ReportedEventType.INTERACTION);\n if (this.cycleAdTimer) {\n clearTimeout(this.cycleAdTimer);\n }\n this.cycleDisplayedAd();\n }\n\n /**\n * Triggered when we need to report an ad event to the API.\n * @param currentAd - The ad to send an event for.\n * @param eventType - The event type for the reported event.\n */\n private triggerReportAdEvent(\n currentAd: Ad,\n eventType: ReportedEventType\n ): void {\n // The event timestamp has to be sent as a unix timestamp.\n const currentTs = Math.round(new Date().getTime() / 1000);\n\n // Log the taken action/event with the API.\n adadaptedApiRequests\n .reportAdEvent(\n {\n app_id: this.props.appId,\n session_id: this.props.sessionId,\n udid: this.props.udid,\n events: [\n {\n ad_id: currentAd.ad_id,\n impression_id: currentAd.impression_id,\n event_type: eventType,\n created_at: currentTs,\n },\n ],\n },\n this.props.deviceOs,\n this.props.apiEnv\n )\n .then(() => {\n // Do nothing with the response for now...\n });\n }\n\n /**\n * Generates a new timer for cycling to the next ad.\n * @param timerLength - The length of time(in milliseconds) to initialize\n * the timer with.\n */\n private createAdTimer(timerLength: number): void {\n if (this.props.adZoneData.ads.length > 0) {\n this.cycleAdTimer = setTimeout(() => {\n this.cycleDisplayedAd();\n }, timerLength);\n }\n }\n\n /**\n * Cycles to the next ad to display in the current available sequence of ads.\n */\n private cycleDisplayedAd(): void {\n // Start by determining the next ad index to display.\n let nextAdIndex = 0;\n\n if (this.state.adIndexShown < this.props.adZoneData.ads.length - 1) {\n nextAdIndex = this.state.adIndexShown + 1;\n }\n\n this.setState(\n {\n adIndexShown: nextAdIndex,\n },\n () => {\n this.initializeAd();\n }\n );\n }\n\n /**\n * Performs all ad initialization tasks when a new ad is being displayed.\n */\n private initializeAd(): void {\n // Create the new timer based on the new ad index.\n this.createAdTimer(\n this.props.adZoneData.ads[this.state.adIndexShown].refresh_time *\n 1000\n );\n\n // Trigger an impression event for the ad.\n this.triggerReportAdEvent(\n this.props.adZoneData.ads[this.state.adIndexShown],\n ReportedEventType.IMPRESSION\n );\n }\n\n /**\n * Generates all component related styles.\n * @returns the styles needed for the component.\n */\n private generateStyles(): StyleDef {\n return StyleSheet.create({\n mainView: {\n width: \"100%\",\n height: \"100%\",\n },\n webView: {\n width: \"100%\",\n height: \"100%\",\n },\n });\n }\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adadapted/react-native-sdk",
3
- "version": "3.1.8",
3
+ "version": "3.1.9",
4
4
  "description": "The AdAdapted react-native SDK.",
5
5
  "main": "lib/commonjs/index.js",
6
6
  "module": "lib/module/index.js",
@@ -46,16 +46,12 @@
46
46
  "homepage": "https://gitlab.com/adadapted/adadapted-react-native-sdk#readme",
47
47
  "dependencies": {
48
48
  "axios": "^0.21.4",
49
- "react": "16.13.1",
50
- "react-dom": "16.13.1",
51
- "react-native": "^0.70.5",
52
- "react-native-base64": "^0.2.1",
53
- "react-native-modal": "^11.5.6",
54
- "react-native-webview": "^11.0.0"
49
+ "react-native-base64": "^0.2.1"
55
50
  },
56
51
  "peerDependencies": {
57
52
  "react": "*",
58
- "react-native": "*"
53
+ "react-native": "*",
54
+ "react-native-webview": "*"
59
55
  },
60
56
  "devDependencies": {
61
57
  "@babel/plugin-transform-typescript": "^7.12.1",
@@ -63,12 +59,12 @@
63
59
  "@babel/preset-react": "^7.12.7",
64
60
  "@babel/preset-typescript": "^7.12.7",
65
61
  "@react-native-community/bob": "^0.17.1",
66
- "@types/enzyme": "^3.10.8",
62
+ "@types/enzyme": "3.10.8",
67
63
  "@types/enzyme-adapter-react-16": "^1.0.6",
68
64
  "@types/jest": "^26.0.20",
69
- "@types/react": "16.14.2",
70
- "@types/react-dom": "16.9.10",
71
- "@types/react-native": "0.63.46",
65
+ "@types/react": "17.0.1",
66
+ "@types/react-dom": "17.0.1",
67
+ "@types/react-native": "0.64.1",
72
68
  "@types/react-native-base64": "^0.1.0",
73
69
  "@types/react-router-native": "^5.1.0",
74
70
  "@typescript-eslint/eslint-plugin": "^4.13.0",
@@ -83,8 +79,11 @@
83
79
  "eslint-plugin-prefer-arrow": "^1.2.2",
84
80
  "eslint-plugin-react": "^7.22.0",
85
81
  "jest": "^26.6.3",
86
- "jest-enzyme": "^7.1.2",
82
+ "jest-enzyme": "7.1.2",
87
83
  "prettier": "^2.2.1",
84
+ "react": "17.0.1",
85
+ "react-native": "^0.70.6",
86
+ "react-native-webview": "11.23.1",
88
87
  "react-router-native": "^5.2.0",
89
88
  "ts-jest": "^26.4.4",
90
89
  "tslint": "^6.1.3",
@@ -169,7 +169,7 @@ export class AdZone extends React.Component<Props, State> {
169
169
  source={{
170
170
  uri: currentAd.creative_url,
171
171
  }}
172
- androidHardwareAccelerationDisabled={true}
172
+ androidLayerType="hardware"
173
173
  automaticallyAdjustContentInsets={false}
174
174
  style={styles.webView}
175
175
  onTouchStart={(e) => {