@adadapted/react-native-sdk 3.4.0 → 3.5.1
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.
- package/adadapted-react-native-sdk.podspec +1 -1
- package/lib/commonjs/api/adadaptedApiRequests.js +10 -11
- package/lib/commonjs/api/adadaptedApiRequests.js.map +1 -1
- package/lib/commonjs/api/adadaptedApiTypes.js +57 -0
- package/lib/commonjs/api/adadaptedApiTypes.js.map +1 -1
- package/lib/commonjs/componentTypes/AdZone.js +11 -0
- package/lib/commonjs/componentTypes/AdZone.js.map +1 -0
- package/lib/commonjs/componentTypes/Device.js +28 -0
- package/lib/commonjs/componentTypes/Device.js.map +1 -0
- package/lib/commonjs/componentTypes/Environment.js +61 -0
- package/lib/commonjs/componentTypes/Environment.js.map +1 -0
- package/lib/commonjs/components/AdZone.js +12 -17
- package/lib/commonjs/components/AdZone.js.map +1 -1
- package/lib/commonjs/components/ReportAdButton.js +1 -2
- package/lib/commonjs/components/ReportAdButton.js.map +1 -1
- package/lib/commonjs/index.js +97 -118
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/util.js +0 -1
- package/lib/commonjs/util.js.map +1 -1
- package/lib/module/api/adadaptedApiRequests.js +9 -9
- package/lib/module/api/adadaptedApiRequests.js.map +1 -1
- package/lib/module/api/adadaptedApiTypes.js +57 -0
- package/lib/module/api/adadaptedApiTypes.js.map +1 -1
- package/lib/module/componentTypes/AdZone.js +7 -0
- package/lib/module/componentTypes/AdZone.js.map +1 -0
- package/lib/module/componentTypes/Device.js +24 -0
- package/lib/module/componentTypes/Device.js.map +1 -0
- package/lib/module/componentTypes/Environment.js +57 -0
- package/lib/module/componentTypes/Environment.js.map +1 -0
- package/lib/module/components/AdZone.js +11 -15
- package/lib/module/components/AdZone.js.map +1 -1
- package/lib/module/index.js +92 -122
- package/lib/module/index.js.map +1 -1
- package/lib/module/util.js +0 -1
- package/lib/module/util.js.map +1 -1
- package/lib/typescript/index.d.ts +2 -0
- package/lib/typescript/index.d.ts.map +1 -0
- package/lib/typescript/jest.setup.d.ts +6 -0
- package/lib/typescript/jest.setup.d.ts.map +1 -0
- package/lib/typescript/src/api/adadaptedApiRequests.d.ts +10 -9
- package/lib/typescript/src/api/adadaptedApiRequests.d.ts.map +1 -1
- package/lib/typescript/src/api/adadaptedApiTypes.d.ts +11 -4
- package/lib/typescript/src/api/adadaptedApiTypes.d.ts.map +1 -1
- package/lib/typescript/src/componentTypes/AdZone.d.ts +95 -0
- package/lib/typescript/src/componentTypes/AdZone.d.ts.map +1 -0
- package/lib/typescript/src/componentTypes/Device.d.ts +80 -0
- package/lib/typescript/src/componentTypes/Device.d.ts.map +1 -0
- package/lib/typescript/src/componentTypes/Environment.d.ts +57 -0
- package/lib/typescript/src/componentTypes/Environment.d.ts.map +1 -0
- package/lib/typescript/src/components/AdZone.d.ts +2 -55
- package/lib/typescript/src/components/AdZone.d.ts.map +1 -1
- package/lib/typescript/src/index.d.ts +38 -142
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/types.d.ts.map +1 -1
- package/package.json +43 -34
- package/src/api/adadaptedApiRequests.mock.ts +2 -2
- package/src/api/adadaptedApiRequests.ts +27 -26
- package/src/api/adadaptedApiTypes.ts +11 -5
- package/src/componentTypes/AdZone.ts +97 -0
- package/src/componentTypes/Device.ts +79 -0
- package/src/componentTypes/Environment.ts +58 -0
- package/src/components/AdZone.tsx +42 -120
- package/src/index.tsx +189 -287
- package/src/types.tsx +6 -5
- package/src/util.ts +6 -7
- package/android/.project +0 -34
- package/android/.settings/org.eclipse.buildship.core.prefs +0 -13
- package/android/bin/.project +0 -34
- package/android/bin/.settings/org.eclipse.buildship.core.prefs +0 -13
- package/android/bin/build.gradle +0 -132
- package/android/bin/gradle.properties +0 -4
- package/android/bin/src/main/AndroidManifest.xml +0 -4
- package/android/bin/src/main/java/com/adadaptedreactnativesdk/AdadaptedReactNativeSdkModule.kt +0 -115
- package/android/bin/src/main/java/com/adadaptedreactnativesdk/AdadaptedReactNativeSdkPackage.kt +0 -20
- package/lib/module/package.json +0 -1
package/src/types.tsx
CHANGED
|
@@ -9,8 +9,9 @@ export type nil = null | undefined;
|
|
|
9
9
|
* Extracts the type of a React component's props from the React component type T.
|
|
10
10
|
* Usage example: type MyComponentProps = ExtractReactPropsType<typeof MyComponent>;
|
|
11
11
|
*/
|
|
12
|
-
export type ExtractReactPropsType<T> =
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
12
|
+
export type ExtractReactPropsType<T> =
|
|
13
|
+
T extends React.ComponentType<infer P>
|
|
14
|
+
? P
|
|
15
|
+
: T extends React.Component<infer P>
|
|
16
|
+
? P
|
|
17
|
+
: never;
|
package/src/util.ts
CHANGED
|
@@ -19,7 +19,7 @@ export function safeInvoke<R>(func: (() => R) | nil): R | undefined;
|
|
|
19
19
|
*/
|
|
20
20
|
export function safeInvoke<A1, R>(
|
|
21
21
|
func: ((arg1: A1) => R) | nil,
|
|
22
|
-
arg1: NoInfer<A1
|
|
22
|
+
arg1: NoInfer<A1>,
|
|
23
23
|
): R | undefined;
|
|
24
24
|
/**
|
|
25
25
|
* See main definition above.
|
|
@@ -32,7 +32,7 @@ export function safeInvoke<A1, R>(
|
|
|
32
32
|
export function safeInvoke<A1, A2, R>(
|
|
33
33
|
func: ((arg1: A1, arg2: A2) => R) | nil,
|
|
34
34
|
arg1: NoInfer<A1>,
|
|
35
|
-
arg2: NoInfer<A2
|
|
35
|
+
arg2: NoInfer<A2>,
|
|
36
36
|
): R | undefined;
|
|
37
37
|
/**
|
|
38
38
|
* See main definition above.
|
|
@@ -47,7 +47,7 @@ export function safeInvoke<A1, A2, A3, R>(
|
|
|
47
47
|
func: ((arg1: A1, arg2: A2, arg3: A3) => R) | nil,
|
|
48
48
|
arg1: NoInfer<A1>,
|
|
49
49
|
arg2: NoInfer<A2>,
|
|
50
|
-
arg3: NoInfer<A3
|
|
50
|
+
arg3: NoInfer<A3>,
|
|
51
51
|
): R | undefined;
|
|
52
52
|
/**
|
|
53
53
|
* See main definition above.
|
|
@@ -64,7 +64,7 @@ export function safeInvoke<A1, A2, A3, A4, R>(
|
|
|
64
64
|
arg1: NoInfer<A1>,
|
|
65
65
|
arg2: NoInfer<A2>,
|
|
66
66
|
arg3: NoInfer<A3>,
|
|
67
|
-
arg4: NoInfer<A4
|
|
67
|
+
arg4: NoInfer<A4>,
|
|
68
68
|
): R | undefined;
|
|
69
69
|
/**
|
|
70
70
|
* See main definition above.
|
|
@@ -83,7 +83,7 @@ export function safeInvoke<A1, A2, A3, A4, A5, R>(
|
|
|
83
83
|
arg2: NoInfer<A2>,
|
|
84
84
|
arg3: NoInfer<A3>,
|
|
85
85
|
arg4: NoInfer<A4>,
|
|
86
|
-
arg5: NoInfer<A5
|
|
86
|
+
arg5: NoInfer<A5>,
|
|
87
87
|
): R | undefined;
|
|
88
88
|
/**
|
|
89
89
|
* See main definition above.
|
|
@@ -106,7 +106,7 @@ export function safeInvoke<A1, A2, A3, A4, A5, A6, R>(
|
|
|
106
106
|
arg3: NoInfer<A3>,
|
|
107
107
|
arg4: NoInfer<A4>,
|
|
108
108
|
arg5: NoInfer<A5>,
|
|
109
|
-
arg6: NoInfer<A6
|
|
109
|
+
arg6: NoInfer<A6>,
|
|
110
110
|
): R | undefined;
|
|
111
111
|
/**
|
|
112
112
|
* See main definition above.
|
|
@@ -114,7 +114,6 @@ export function safeInvoke<A1, A2, A3, A4, A5, A6, R>(
|
|
|
114
114
|
* @param args - All arguments to call with the function.
|
|
115
115
|
* @returns the method to be called if its defined.
|
|
116
116
|
*/
|
|
117
|
-
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
118
117
|
export function safeInvoke(func: Function | nil, ...args: any[]): any {
|
|
119
118
|
if (func) {
|
|
120
119
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
package/android/.project
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
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>
|
|
@@ -1,13 +0,0 @@
|
|
|
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/zulu-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
|
package/android/bin/.project
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
-
<projectDescription>
|
|
3
|
-
<name>android</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>
|
|
@@ -1,13 +0,0 @@
|
|
|
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=
|
|
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
|
package/android/bin/build.gradle
DELETED
|
@@ -1,132 +0,0 @@
|
|
|
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
|
-
mavenCentral()
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
dependencies {
|
|
11
|
-
classpath 'com.android.tools.build:gradle:8.7.2'
|
|
12
|
-
// noinspection DifferentKotlinGradleVersion
|
|
13
|
-
classpath("com.facebook.react:react-native-gradle-plugin:0.75.1")
|
|
14
|
-
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version")
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
apply plugin: 'com.android.library'
|
|
19
|
-
apply plugin: 'kotlin-android'
|
|
20
|
-
|
|
21
|
-
def getExtOrDefault(name) {
|
|
22
|
-
return rootProject.ext.has(name) ? rootProject.ext.get(name) : project.properties['AdadaptedReactNativeSdk_' + name]
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
def getExtOrIntegerDefault(name) {
|
|
26
|
-
return rootProject.ext.has(name) ? rootProject.ext.get(name) : (project.properties['AdadaptedReactNativeSdk_' + name]).toInteger()
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
android {
|
|
30
|
-
namespace "com.adadapted.adadaptedreactnativesdk"
|
|
31
|
-
compileSdkVersion getExtOrIntegerDefault('compileSdkVersion')
|
|
32
|
-
buildToolsVersion getExtOrDefault('buildToolsVersion')
|
|
33
|
-
defaultConfig {
|
|
34
|
-
minSdkVersion 28
|
|
35
|
-
targetSdkVersion getExtOrIntegerDefault('targetSdkVersion')
|
|
36
|
-
versionCode 1
|
|
37
|
-
versionName "1.0"
|
|
38
|
-
}
|
|
39
|
-
buildTypes {
|
|
40
|
-
release {
|
|
41
|
-
minifyEnabled false
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
lintOptions {
|
|
45
|
-
disable 'GradleCompatible'
|
|
46
|
-
}
|
|
47
|
-
compileOptions {
|
|
48
|
-
sourceCompatibility JavaVersion.VERSION_17
|
|
49
|
-
targetCompatibility JavaVersion.VERSION_17
|
|
50
|
-
}
|
|
51
|
-
kotlin {
|
|
52
|
-
jvmToolchain(17)
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
repositories {
|
|
57
|
-
mavenCentral()
|
|
58
|
-
google()
|
|
59
|
-
|
|
60
|
-
def found = false
|
|
61
|
-
def defaultDir = null
|
|
62
|
-
def androidSourcesName = 'React Native sources'
|
|
63
|
-
|
|
64
|
-
if (rootProject.ext.has('reactNativeAndroidRoot')) {
|
|
65
|
-
defaultDir = rootProject.ext.get('reactNativeAndroidRoot')
|
|
66
|
-
} else {
|
|
67
|
-
defaultDir = new File(
|
|
68
|
-
projectDir,
|
|
69
|
-
'/../../../node_modules/react-native/android'
|
|
70
|
-
)
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
if (defaultDir.exists()) {
|
|
74
|
-
maven {
|
|
75
|
-
url defaultDir.toString()
|
|
76
|
-
name androidSourcesName
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
logger.info(":${project.name}:reactNativeAndroidRoot ${defaultDir.canonicalPath}")
|
|
80
|
-
found = true
|
|
81
|
-
} else {
|
|
82
|
-
def parentDir = rootProject.projectDir
|
|
83
|
-
|
|
84
|
-
1.upto(5, {
|
|
85
|
-
if (found) return true
|
|
86
|
-
parentDir = parentDir.parentFile
|
|
87
|
-
|
|
88
|
-
def androidSourcesDir = new File(
|
|
89
|
-
parentDir,
|
|
90
|
-
'node_modules/react-native'
|
|
91
|
-
)
|
|
92
|
-
|
|
93
|
-
def androidPrebuiltBinaryDir = new File(
|
|
94
|
-
parentDir,
|
|
95
|
-
'node_modules/react-native/android'
|
|
96
|
-
)
|
|
97
|
-
|
|
98
|
-
if (androidPrebuiltBinaryDir.exists()) {
|
|
99
|
-
maven {
|
|
100
|
-
url androidPrebuiltBinaryDir.toString()
|
|
101
|
-
name androidSourcesName
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
logger.info(":${project.name}:reactNativeAndroidRoot ${androidPrebuiltBinaryDir.canonicalPath}")
|
|
105
|
-
found = true
|
|
106
|
-
} else if (androidSourcesDir.exists()) {
|
|
107
|
-
maven {
|
|
108
|
-
url androidSourcesDir.toString()
|
|
109
|
-
name androidSourcesName
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
logger.info(":${project.name}:reactNativeAndroidRoot ${androidSourcesDir.canonicalPath}")
|
|
113
|
-
found = true
|
|
114
|
-
}
|
|
115
|
-
})
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
if (!found) {
|
|
119
|
-
throw new FileNotFoundException(
|
|
120
|
-
"${project.name}: unable to locate React Native android sources. " +
|
|
121
|
-
"Ensure you have you installed React Native as a dependency in your project and try again."
|
|
122
|
-
)
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
def kotlin_version = getExtOrDefault('kotlinVersion')
|
|
127
|
-
|
|
128
|
-
dependencies {
|
|
129
|
-
// noinspection GradleDynamicVersion
|
|
130
|
-
api 'com.facebook.react:react-native:0.20.1'
|
|
131
|
-
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
|
|
132
|
-
}
|
package/android/bin/src/main/java/com/adadaptedreactnativesdk/AdadaptedReactNativeSdkModule.kt
DELETED
|
@@ -1,115 +0,0 @@
|
|
|
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
|
-
}
|
package/android/bin/src/main/java/com/adadaptedreactnativesdk/AdadaptedReactNativeSdkPackage.kt
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
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
|
-
}
|
package/lib/module/package.json
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"type":"module"}
|