airbridge-react-native-sdk-restricted 2.5.2
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/.eslintrc.json +44 -0
- package/.gitattributes +1 -0
- package/airbridge-react-native-sdk.podspec +32 -0
- package/android/build/.transforms/08e8d929b7926845ebd25bc2ae9e2874/results.bin +1 -0
- package/android/build/.transforms/08e8d929b7926845ebd25bc2ae9e2874/transformed/classes/classes.dex +0 -0
- package/android/build/.transforms/14ea77658b61f201debed3d92aea1c0f/results.bin +1 -0
- package/android/build/.transforms/14ea77658b61f201debed3d92aea1c0f/transformed/classes/classes.dex +0 -0
- package/android/build/.transforms/33560bbaf5632b59753ef78fcd7b7f8d/results.bin +1 -0
- package/android/build/.transforms/33560bbaf5632b59753ef78fcd7b7f8d/transformed/classes/classes.dex +0 -0
- package/android/build/.transforms/38fa05fa6fd488a5dec6d7bdb333bfd1/results.bin +1 -0
- package/android/build/.transforms/38fa05fa6fd488a5dec6d7bdb333bfd1/transformed/classes/classes.dex +0 -0
- package/android/build/.transforms/405120ecc1eb36e3127f0c3846387eb6/results.bin +1 -0
- package/android/build/.transforms/405120ecc1eb36e3127f0c3846387eb6/transformed/classes/classes.dex +0 -0
- package/android/build/.transforms/61c549f58a941c195c4ffb5f43fed2ef/results.bin +1 -0
- package/android/build/.transforms/61c549f58a941c195c4ffb5f43fed2ef/transformed/classes/classes.dex +0 -0
- package/android/build/.transforms/75c8746e5247a4500eb6ae4ca2ef0a2e/results.bin +1 -0
- package/android/build/.transforms/75c8746e5247a4500eb6ae4ca2ef0a2e/transformed/classes/classes.dex +0 -0
- package/android/build/.transforms/85f88a3c5a226a3333c60b94378960e9/results.bin +1 -0
- package/android/build/.transforms/85f88a3c5a226a3333c60b94378960e9/transformed/classes/classes.dex +0 -0
- package/android/build/.transforms/8f01556cdda8590f3b7cee54078417e1/results.bin +1 -0
- package/android/build/.transforms/8f01556cdda8590f3b7cee54078417e1/transformed/classes/classes.dex +0 -0
- package/android/build/.transforms/905b1aa9b91e69e71e9ed75a0c99581c/results.bin +1 -0
- package/android/build/.transforms/905b1aa9b91e69e71e9ed75a0c99581c/transformed/classes/classes.dex +0 -0
- package/android/build/.transforms/983e33cb97b3d1caf80afe6b7ca652b3/results.bin +1 -0
- package/android/build/.transforms/983e33cb97b3d1caf80afe6b7ca652b3/transformed/classes/classes.dex +0 -0
- package/android/build/.transforms/b398922a5d6aaf33784a06f933228695/results.bin +1 -0
- package/android/build/.transforms/b398922a5d6aaf33784a06f933228695/transformed/classes/classes.dex +0 -0
- package/android/build/.transforms/b4ff5fb2fdb627c9a67ad50ae0347ece/results.bin +1 -0
- package/android/build/.transforms/b4ff5fb2fdb627c9a67ad50ae0347ece/transformed/classes/classes.dex +0 -0
- package/android/build/.transforms/d89a0ea59a0fb9c21321de6f1be36c2b/results.bin +1 -0
- package/android/build/.transforms/d89a0ea59a0fb9c21321de6f1be36c2b/transformed/classes/classes.dex +0 -0
- package/android/build/.transforms/dca3c4e952522adb6e9c477431cc0881/results.bin +1 -0
- package/android/build/.transforms/dca3c4e952522adb6e9c477431cc0881/transformed/classes/classes.dex +0 -0
- package/android/build/.transforms/e6b9f6a4f6dc26d29d4ac4172b428541/results.bin +1 -0
- package/android/build/.transforms/e6b9f6a4f6dc26d29d4ac4172b428541/transformed/classes/classes.dex +0 -0
- package/android/build/.transforms/e8ebcf4ab4a209e222c80ef37e9122e2/results.bin +1 -0
- package/android/build/.transforms/e8ebcf4ab4a209e222c80ef37e9122e2/transformed/classes/classes.dex +0 -0
- package/android/build/generated/source/buildConfig/debug/co/ab180/airbridge/reactnative/BuildConfig.java +10 -0
- package/android/build/intermediates/aapt_friendly_merged_manifests/debug/aapt/AndroidManifest.xml +10 -0
- package/android/build/intermediates/aapt_friendly_merged_manifests/debug/aapt/output-metadata.json +18 -0
- package/android/build/intermediates/aar_metadata/debug/aar-metadata.properties +5 -0
- package/android/build/intermediates/annotation_processor_list/debug/annotationProcessors.json +1 -0
- package/android/build/intermediates/compile_library_classes_jar/debug/classes.jar +0 -0
- package/android/build/intermediates/compile_r_class_jar/debug/R.jar +0 -0
- package/android/build/intermediates/compile_symbol_list/debug/R.txt +1956 -0
- package/android/build/intermediates/incremental/debug/packageDebugResources/compile-file-map.properties +1 -0
- package/android/build/intermediates/incremental/debug/packageDebugResources/merger.xml +2 -0
- package/android/build/intermediates/incremental/mergeDebugJniLibFolders/merger.xml +2 -0
- package/android/build/intermediates/incremental/mergeDebugShaders/merger.xml +2 -0
- package/android/build/intermediates/incremental/packageDebugAssets/merger.xml +2 -0
- package/android/build/intermediates/incremental/packageDebugResources/compile-file-map.properties +1 -0
- package/android/build/intermediates/incremental/packageDebugResources/merger.xml +2 -0
- package/android/build/intermediates/javac/debug/classes/co/ab180/airbridge/reactnative/AirbridgeAttribution.class +0 -0
- package/android/build/intermediates/javac/debug/classes/co/ab180/airbridge/reactnative/AirbridgeDeeplink$1.class +0 -0
- package/android/build/intermediates/javac/debug/classes/co/ab180/airbridge/reactnative/AirbridgeDeeplink.class +0 -0
- package/android/build/intermediates/javac/debug/classes/co/ab180/airbridge/reactnative/AirbridgeEvent.class +0 -0
- package/android/build/intermediates/javac/debug/classes/co/ab180/airbridge/reactnative/AirbridgePlacement.class +0 -0
- package/android/build/intermediates/javac/debug/classes/co/ab180/airbridge/reactnative/AirbridgeRN.class +0 -0
- package/android/build/intermediates/javac/debug/classes/co/ab180/airbridge/reactnative/AirbridgeState$1.class +0 -0
- package/android/build/intermediates/javac/debug/classes/co/ab180/airbridge/reactnative/AirbridgeState.class +0 -0
- package/android/build/intermediates/javac/debug/classes/co/ab180/airbridge/reactnative/BuildConfig.class +0 -0
- package/android/build/intermediates/javac/debug/classes/co/ab180/airbridge/reactnative/ConfigReader$1.class +0 -0
- package/android/build/intermediates/javac/debug/classes/co/ab180/airbridge/reactnative/ConfigReader$2.class +0 -0
- package/android/build/intermediates/javac/debug/classes/co/ab180/airbridge/reactnative/ConfigReader.class +0 -0
- package/android/build/intermediates/javac/debug/classes/co/ab180/airbridge/reactnative/Get.class +0 -0
- package/android/build/intermediates/local_only_symbol_list/debug/R-def.txt +2 -0
- package/android/build/intermediates/manifest_merge_blame_file/debug/manifest-merger-blame-debug-report.txt +15 -0
- package/android/build/intermediates/merged_manifest/debug/AndroidManifest.xml +10 -0
- package/android/build/intermediates/navigation_json/debug/navigation.json +1 -0
- package/android/build/intermediates/packaged_manifests/debug/output-metadata.json +18 -0
- package/android/build/intermediates/runtime_library_classes_jar/debug/classes.jar +0 -0
- package/android/build/intermediates/symbol_list_with_package_name/debug/package-aware-r.txt +1449 -0
- package/android/build/outputs/logs/manifest-merger-debug-report.txt +33 -0
- package/android/build/tmp/compileDebugJavaWithJavac/previous-compilation-data.bin +0 -0
- package/android/build.gradle +27 -0
- package/android/copy-config.gradle +18 -0
- package/android/gradle/wrapper/gradle-wrapper.jar +0 -0
- package/android/gradle/wrapper/gradle-wrapper.properties +6 -0
- package/android/gradlew +172 -0
- package/android/gradlew.bat +84 -0
- package/android/src/main/AndroidManifest.xml +8 -0
- package/android/src/main/java/co/ab180/airbridge/reactnative/AirbridgeAttribution.java +78 -0
- package/android/src/main/java/co/ab180/airbridge/reactnative/AirbridgeDeeplink.java +97 -0
- package/android/src/main/java/co/ab180/airbridge/reactnative/AirbridgeEvent.java +76 -0
- package/android/src/main/java/co/ab180/airbridge/reactnative/AirbridgePlacement.java +42 -0
- package/android/src/main/java/co/ab180/airbridge/reactnative/AirbridgeRN.java +82 -0
- package/android/src/main/java/co/ab180/airbridge/reactnative/AirbridgeState.java +174 -0
- package/android/src/main/java/co/ab180/airbridge/reactnative/ConfigReader.java +108 -0
- package/android/src/main/java/co/ab180/airbridge/reactnative/Get.java +84 -0
- package/changelog.md +56 -0
- package/index.d.ts +292 -0
- package/index.js +8 -0
- package/ios/AirbridgeRN/ARNConfigReader.h +19 -0
- package/ios/AirbridgeRN/ARNConfigReader.m +79 -0
- package/ios/AirbridgeRN/ARNGet.h +20 -0
- package/ios/AirbridgeRN/ARNGet.m +40 -0
- package/ios/AirbridgeRN/AirbridgeAttribution.h +19 -0
- package/ios/AirbridgeRN/AirbridgeAttribution.m +47 -0
- package/ios/AirbridgeRN/AirbridgeDeeplink.h +20 -0
- package/ios/AirbridgeRN/AirbridgeDeeplink.m +59 -0
- package/ios/AirbridgeRN/AirbridgeEvent.h +17 -0
- package/ios/AirbridgeRN/AirbridgeEvent.m +63 -0
- package/ios/AirbridgeRN/AirbridgePlacement.h +17 -0
- package/ios/AirbridgeRN/AirbridgePlacement.m +38 -0
- package/ios/AirbridgeRN/AirbridgeRN.h +71 -0
- package/ios/AirbridgeRN/AirbridgeRN.m +59 -0
- package/ios/AirbridgeRN/AirbridgeState.h +17 -0
- package/ios/AirbridgeRN/AirbridgeState.m +89 -0
- package/ios/AirbridgeRN.xcodeproj/project.pbxproj +409 -0
- package/ios/copy-config.rb +26 -0
- package/package.json +43 -0
- package/readme.md +11 -0
- package/src/Airbridge.js +82 -0
- package/src/Deeplink.js +75 -0
- package/src/Event.js +38 -0
- package/src/Placement.js +56 -0
- package/src/State.js +167 -0
- package/src/WebInterface.js +135 -0
- package/src/tool/Log.js +40 -0
- package/src/tool/_.js +56 -0
- package/src/type/AirbridgeAttributes.js +16 -0
- package/src/type/AirbridgeCategory.js +18 -0
- package/src/type/AirbridgeProduct.js +13 -0
- package/src/typedef/EventOption.js +9 -0
- package/src/typedef/Product.js +10 -0
- package/src/typedef/User.js +9 -0
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
package co.ab180.airbridge.reactnative;
|
|
2
|
+
|
|
3
|
+
import android.app.Application;
|
|
4
|
+
import android.content.Intent;
|
|
5
|
+
|
|
6
|
+
import com.facebook.react.ReactPackage;
|
|
7
|
+
import com.facebook.react.bridge.JavaScriptModule;
|
|
8
|
+
import com.facebook.react.bridge.NativeModule;
|
|
9
|
+
import com.facebook.react.bridge.ReactApplicationContext;
|
|
10
|
+
import com.facebook.react.uimanager.ViewManager;
|
|
11
|
+
|
|
12
|
+
import java.util.Arrays;
|
|
13
|
+
import java.util.Collections;
|
|
14
|
+
import java.util.List;
|
|
15
|
+
|
|
16
|
+
import javax.annotation.Nonnull;
|
|
17
|
+
|
|
18
|
+
import co.ab180.airbridge.Airbridge;
|
|
19
|
+
|
|
20
|
+
public class AirbridgeRN implements ReactPackage {
|
|
21
|
+
|
|
22
|
+
//
|
|
23
|
+
// init
|
|
24
|
+
//
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Initialize Airbridge SDK
|
|
28
|
+
* <p>
|
|
29
|
+
* You should call this method on MainApplication#onCreate
|
|
30
|
+
*
|
|
31
|
+
* @param application
|
|
32
|
+
* context from MainApplication#onCreate
|
|
33
|
+
* @param appName
|
|
34
|
+
* App Name in English
|
|
35
|
+
* @param appToken
|
|
36
|
+
* App Token
|
|
37
|
+
*/
|
|
38
|
+
public static void init(@Nonnull Application application, @Nonnull String appName, @Nonnull String appToken) {
|
|
39
|
+
Airbridge.init(application, ConfigReader.build(appName, appToken, application));
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
//
|
|
43
|
+
// deeplink
|
|
44
|
+
//
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* You can give deeplink information to Airbridge SDK with this method
|
|
48
|
+
*
|
|
49
|
+
* @param intent
|
|
50
|
+
* intent from MainActivity#onResume
|
|
51
|
+
*/
|
|
52
|
+
public static void processDeeplinkData(final Intent intent) {
|
|
53
|
+
AirbridgeDeeplink.processDeeplinkData(intent);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
//
|
|
57
|
+
// override
|
|
58
|
+
//
|
|
59
|
+
|
|
60
|
+
@Override
|
|
61
|
+
@Nonnull
|
|
62
|
+
public List<NativeModule> createNativeModules(@Nonnull ReactApplicationContext reactContext) {
|
|
63
|
+
return Arrays.<NativeModule>asList(
|
|
64
|
+
new AirbridgeEvent(reactContext),
|
|
65
|
+
new AirbridgeDeeplink(reactContext),
|
|
66
|
+
new AirbridgeState(reactContext),
|
|
67
|
+
new AirbridgePlacement(reactContext),
|
|
68
|
+
new AirbridgeAttribution(reactContext)
|
|
69
|
+
);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
// Deprecated from RN 0.47
|
|
73
|
+
public List<Class<? extends JavaScriptModule>> createJSModules() {
|
|
74
|
+
return Collections.emptyList();
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
@Override
|
|
78
|
+
@Nonnull
|
|
79
|
+
public List<ViewManager> createViewManagers(@Nonnull ReactApplicationContext reactContext) {
|
|
80
|
+
return Collections.emptyList();
|
|
81
|
+
}
|
|
82
|
+
}
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
package co.ab180.airbridge.reactnative;
|
|
2
|
+
|
|
3
|
+
import com.facebook.react.bridge.Promise;
|
|
4
|
+
import com.facebook.react.bridge.ReactApplicationContext;
|
|
5
|
+
import com.facebook.react.bridge.ReactContextBaseJavaModule;
|
|
6
|
+
import com.facebook.react.bridge.ReactMethod;
|
|
7
|
+
import com.facebook.react.bridge.ReadableMap;
|
|
8
|
+
|
|
9
|
+
import java.util.HashMap;
|
|
10
|
+
import java.util.Map;
|
|
11
|
+
|
|
12
|
+
import javax.annotation.Nonnull;
|
|
13
|
+
import javax.annotation.Nullable;
|
|
14
|
+
|
|
15
|
+
import co.ab180.airbridge.Airbridge;
|
|
16
|
+
import co.ab180.airbridge.AirbridgeCallback;
|
|
17
|
+
|
|
18
|
+
public class AirbridgeState extends ReactContextBaseJavaModule {
|
|
19
|
+
public AirbridgeState(ReactApplicationContext reactContext) {
|
|
20
|
+
super(reactContext);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
//
|
|
24
|
+
// react native method
|
|
25
|
+
//
|
|
26
|
+
|
|
27
|
+
@ReactMethod
|
|
28
|
+
public void setUser(@Nullable ReadableMap user) {
|
|
29
|
+
HashMap userMap = null;
|
|
30
|
+
if (user != null) {
|
|
31
|
+
userMap = user.toHashMap();
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
String id = Get.type(String.class, userMap, "ID");
|
|
35
|
+
String email = Get.type(String.class, userMap, "email");
|
|
36
|
+
String phone = Get.type(String.class, userMap, "phone");
|
|
37
|
+
Map<String, String> alias = Get.type(HashMap.class, userMap, "alias");
|
|
38
|
+
Map<String, ?> attributes = Get.type(HashMap.class, userMap, "attributes");
|
|
39
|
+
|
|
40
|
+
Airbridge.getCurrentUser().setId(id);
|
|
41
|
+
Airbridge.getCurrentUser().setEmail(email);
|
|
42
|
+
Airbridge.getCurrentUser().setPhone(phone);
|
|
43
|
+
|
|
44
|
+
if (alias != null) {
|
|
45
|
+
for (Map.Entry<String, String> entry : alias.entrySet()) {
|
|
46
|
+
Airbridge.getCurrentUser().setAlias(entry.getKey(), entry.getValue());
|
|
47
|
+
}
|
|
48
|
+
} else {
|
|
49
|
+
Airbridge.getCurrentUser().clearAlias();
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
if (attributes != null) {
|
|
53
|
+
for (Map.Entry<String, ?> entry : attributes.entrySet()) {
|
|
54
|
+
String key = entry.getKey();
|
|
55
|
+
Object value = entry.getValue();
|
|
56
|
+
|
|
57
|
+
if (value instanceof String) {
|
|
58
|
+
Airbridge.getCurrentUser().setAttribute(key, (String) value);
|
|
59
|
+
} else if (value instanceof Long) {
|
|
60
|
+
Airbridge.getCurrentUser().setAttribute(key, (Long) value);
|
|
61
|
+
} else if (value instanceof Integer) {
|
|
62
|
+
Airbridge.getCurrentUser().setAttribute(key, (Integer) value);
|
|
63
|
+
} else if (value instanceof Double || value instanceof Float) {
|
|
64
|
+
Airbridge.getCurrentUser().setAttribute(key, ((Number) value).floatValue());
|
|
65
|
+
} else if (value instanceof Boolean) {
|
|
66
|
+
Airbridge.getCurrentUser().setAttribute(key, (Boolean) value);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
} else {
|
|
70
|
+
Airbridge.getCurrentUser().clearAttributes();
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
@ReactMethod
|
|
75
|
+
public void updateUser(@Nullable ReadableMap user) {
|
|
76
|
+
HashMap userMap = null;
|
|
77
|
+
if (user != null) {
|
|
78
|
+
userMap = user.toHashMap();
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
String id = Get.type(String.class, userMap, "ID");
|
|
82
|
+
String email = Get.type(String.class, userMap, "email");
|
|
83
|
+
String phone = Get.type(String.class, userMap, "phone");
|
|
84
|
+
Map<String, String> alias = Get.type(HashMap.class, userMap, "alias");
|
|
85
|
+
Map<String, ?> attributes = Get.type(HashMap.class, userMap, "attributes");
|
|
86
|
+
|
|
87
|
+
if (id != null) {
|
|
88
|
+
Airbridge.getCurrentUser().setId(id);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
if (email != null) {
|
|
92
|
+
Airbridge.getCurrentUser().setEmail(email);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
if (phone != null) {
|
|
96
|
+
Airbridge.getCurrentUser().setPhone(phone);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
if (alias != null) {
|
|
100
|
+
for (Map.Entry<String, String> entry : alias.entrySet()) {
|
|
101
|
+
Airbridge.getCurrentUser().setAlias(entry.getKey(), entry.getValue());
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
if (attributes != null) {
|
|
106
|
+
for (Map.Entry<String, ?> entry : attributes.entrySet()) {
|
|
107
|
+
String key = entry.getKey();
|
|
108
|
+
Object value = entry.getValue();
|
|
109
|
+
|
|
110
|
+
if (value instanceof String) {
|
|
111
|
+
Airbridge.getCurrentUser().setAttribute(key, (String) value);
|
|
112
|
+
} else if (value instanceof Long) {
|
|
113
|
+
Airbridge.getCurrentUser().setAttribute(key, (Long) value);
|
|
114
|
+
} else if (value instanceof Integer) {
|
|
115
|
+
Airbridge.getCurrentUser().setAttribute(key, (Integer) value);
|
|
116
|
+
} else if (value instanceof Double || value instanceof Float) {
|
|
117
|
+
Airbridge.getCurrentUser().setAttribute(key, ((Number) value).floatValue());
|
|
118
|
+
} else if (value instanceof Boolean) {
|
|
119
|
+
Airbridge.getCurrentUser().setAttribute(key, (Boolean) value);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
@ReactMethod
|
|
126
|
+
public void startTracking() {
|
|
127
|
+
Airbridge.startTracking();
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
@ReactMethod
|
|
131
|
+
public void deviceUUID(final Promise promise) {
|
|
132
|
+
Airbridge.getDeviceInfo().getUUID(new AirbridgeCallback.SimpleCallback<String>() {
|
|
133
|
+
@Override
|
|
134
|
+
public void onSuccess(String uuid) {
|
|
135
|
+
promise.resolve(uuid);
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
@Override
|
|
139
|
+
public void onFailure(Throwable throwable) {
|
|
140
|
+
promise.reject(throwable);
|
|
141
|
+
}
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
@ReactMethod
|
|
146
|
+
public void setDeviceAlias(String key, String value) {
|
|
147
|
+
Airbridge.setDeviceAlias(key, value);
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
@ReactMethod
|
|
151
|
+
public void removeDeviceAlias(String key) {
|
|
152
|
+
Airbridge.removeDeviceAlias(key);
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
@ReactMethod
|
|
156
|
+
public void clearDeviceAlias() {
|
|
157
|
+
Airbridge.clearDeviceAlias();
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
@ReactMethod
|
|
161
|
+
public void registerPushToken(String token) {
|
|
162
|
+
Airbridge.registerPushToken(token);
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
//
|
|
166
|
+
// override
|
|
167
|
+
//
|
|
168
|
+
|
|
169
|
+
@Override
|
|
170
|
+
@Nonnull
|
|
171
|
+
public String getName() {
|
|
172
|
+
return "AirbridgeState";
|
|
173
|
+
}
|
|
174
|
+
}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
package co.ab180.airbridge.reactnative;
|
|
2
|
+
|
|
3
|
+
import android.content.Context;
|
|
4
|
+
import android.content.res.AssetManager;
|
|
5
|
+
import android.util.Log;
|
|
6
|
+
|
|
7
|
+
import org.json.JSONException;
|
|
8
|
+
import org.json.JSONObject;
|
|
9
|
+
|
|
10
|
+
import java.io.BufferedReader;
|
|
11
|
+
import java.io.IOException;
|
|
12
|
+
import java.io.InputStreamReader;
|
|
13
|
+
import java.util.Map;
|
|
14
|
+
import java.util.HashMap;
|
|
15
|
+
|
|
16
|
+
import co.ab180.airbridge.AirbridgeConfig;
|
|
17
|
+
import co.ab180.airbridge.OnAttributionResultReceiveListener;
|
|
18
|
+
|
|
19
|
+
class ConfigReader {
|
|
20
|
+
private ConfigReader() {}
|
|
21
|
+
|
|
22
|
+
static AirbridgeConfig build(String appName, String appToken, Context context) {
|
|
23
|
+
AirbridgeConfig.Builder configBuilder = new AirbridgeConfig.Builder(appName, appToken);
|
|
24
|
+
|
|
25
|
+
JSONObject configObject = null;
|
|
26
|
+
AssetManager assetManager = context.getAssets();
|
|
27
|
+
try {
|
|
28
|
+
BufferedReader reader = new BufferedReader(
|
|
29
|
+
new InputStreamReader(
|
|
30
|
+
assetManager.open("airbridge.json")
|
|
31
|
+
)
|
|
32
|
+
);
|
|
33
|
+
|
|
34
|
+
StringBuilder builder = new StringBuilder();
|
|
35
|
+
|
|
36
|
+
String line = reader.readLine();
|
|
37
|
+
while (line != null) {
|
|
38
|
+
builder.append(line);
|
|
39
|
+
line = reader.readLine();
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
configObject = new JSONObject(builder.toString());
|
|
43
|
+
} catch (IOException ignored) {
|
|
44
|
+
// when do not use airbridge.json file
|
|
45
|
+
} catch (JSONException e) {
|
|
46
|
+
Log.w("AirbridgeRN", "airbridge.json is not json format");
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
Number sessionTimeoutSeconds = Get.type(Number.class, configObject, "sessionTimeoutSeconds");
|
|
50
|
+
if (sessionTimeoutSeconds != null) {
|
|
51
|
+
configBuilder.setSessionTimeoutSeconds(sessionTimeoutSeconds.longValue());
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
Boolean autoStartTrackingEnabled = Get.type(Boolean.class, configObject, "autoStartTrackingEnabled");
|
|
55
|
+
if (autoStartTrackingEnabled != null) {
|
|
56
|
+
configBuilder.setAutoStartTrackingEnabled(autoStartTrackingEnabled);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
Boolean userInfoHashEnabled = Get.type(Boolean.class, configObject, "userInfoHashEnabled");
|
|
60
|
+
if (userInfoHashEnabled != null) {
|
|
61
|
+
configBuilder.setUserInfoHashEnabled(userInfoHashEnabled);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
Boolean trackAirbridgeLinkOnly = Get.type(Boolean.class, configObject, "trackAirbridgeLinkOnly");
|
|
65
|
+
if (trackAirbridgeLinkOnly != null) {
|
|
66
|
+
configBuilder.setTrackAirbridgeLinkOnly(trackAirbridgeLinkOnly);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
Boolean locationCollectionEnabled = Get.type(Boolean.class, configObject, "locationCollectionEnabled");
|
|
70
|
+
if (locationCollectionEnabled != null) {
|
|
71
|
+
configBuilder.setLocationCollectionEnabled(locationCollectionEnabled);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
Boolean facebookDeferredAppLinkEnabled = Get.type(Boolean.class, configObject, "facebookDeferredAppLinkEnabled");
|
|
75
|
+
if (facebookDeferredAppLinkEnabled != null) {
|
|
76
|
+
configBuilder.setFacebookDeferredAppLinkEnabled(facebookDeferredAppLinkEnabled);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
String secretId = Get.type(String.class, configObject, "sdkSignatureSecretID");
|
|
80
|
+
String secretKey = Get.type(String.class, configObject, "sdkSignatureSecret");
|
|
81
|
+
if (secretId != null && secretKey != null) {
|
|
82
|
+
configBuilder.setSDKSignatureSecret(secretId, secretKey);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
String logLevel = Get.type(String.class, configObject, "logLevel");
|
|
86
|
+
Map<String, Integer> logLevelMap = new HashMap<String, Integer>() {{
|
|
87
|
+
put("debug", Log.VERBOSE);
|
|
88
|
+
put("info", Log.INFO);
|
|
89
|
+
put("warning", Log.WARN);
|
|
90
|
+
put("error", Log.ERROR);
|
|
91
|
+
put("fault", Log.ASSERT);
|
|
92
|
+
}};
|
|
93
|
+
Integer resultLogLevel = logLevelMap.get(logLevel != null ? logLevel.toLowerCase() : null);
|
|
94
|
+
resultLogLevel = resultLogLevel != null ? resultLogLevel : Log.WARN;
|
|
95
|
+
configBuilder.setLogLevel(resultLogLevel);
|
|
96
|
+
|
|
97
|
+
configBuilder.setPlatform("react_native");
|
|
98
|
+
|
|
99
|
+
configBuilder.setOnAttributionResultReceiveListener(new OnAttributionResultReceiveListener() {
|
|
100
|
+
@Override
|
|
101
|
+
public void onAttributionResultReceived(Map<String, String> attribution) {
|
|
102
|
+
AirbridgeAttribution.processAttribution(attribution);
|
|
103
|
+
}
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
return configBuilder.build();
|
|
107
|
+
}
|
|
108
|
+
}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
package co.ab180.airbridge.reactnative;
|
|
2
|
+
|
|
3
|
+
import org.json.JSONObject;
|
|
4
|
+
|
|
5
|
+
import java.util.ArrayList;
|
|
6
|
+
import java.util.HashMap;
|
|
7
|
+
|
|
8
|
+
public class Get {
|
|
9
|
+
static <T> T type(Class<T> type, Object object) {
|
|
10
|
+
if (object == null || type.isInstance(object)) {
|
|
11
|
+
return type.cast(object);
|
|
12
|
+
} else {
|
|
13
|
+
return null;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
static <T> T type(Class<T> type, HashMap map, String key) {
|
|
18
|
+
if (map == null) {
|
|
19
|
+
return null;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
Object value = map.get(key);
|
|
23
|
+
|
|
24
|
+
return Get.type(type, value);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
static <T> T type(Class<T> type, ArrayList array, int index) {
|
|
28
|
+
if (array == null || index < 0 || index > array.size()) {
|
|
29
|
+
return null;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
Object object = array.get(index);
|
|
33
|
+
|
|
34
|
+
return Get.type(type, object);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
static <T> T type(Class<T> type, JSONObject object, String key) {
|
|
38
|
+
if (object == null) {
|
|
39
|
+
return null;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
Object value = object.opt(key);
|
|
43
|
+
|
|
44
|
+
return Get.type(type, value);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
static <T extends Number> T type(Class<T> type, Number number) {
|
|
48
|
+
if (number == null) {
|
|
49
|
+
return null;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
if (type.isAssignableFrom(Number.class)) {
|
|
53
|
+
return type.cast(number);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
if(type.isAssignableFrom(Byte.class)) {
|
|
57
|
+
|
|
58
|
+
return type.cast(number.byteValue());
|
|
59
|
+
|
|
60
|
+
} else if (type.isAssignableFrom(Short.class)) {
|
|
61
|
+
|
|
62
|
+
return type.cast(number.shortValue());
|
|
63
|
+
|
|
64
|
+
} else if (type.isAssignableFrom(Integer.class)) {
|
|
65
|
+
|
|
66
|
+
return type.cast(number.intValue());
|
|
67
|
+
|
|
68
|
+
} else if (type.isAssignableFrom(Long.class)) {
|
|
69
|
+
|
|
70
|
+
return type.cast(number.longValue());
|
|
71
|
+
|
|
72
|
+
} else if (type.isAssignableFrom(Float.class)) {
|
|
73
|
+
|
|
74
|
+
return type.cast(number.floatValue());
|
|
75
|
+
|
|
76
|
+
} else if (type.isAssignableFrom(Double.class)) {
|
|
77
|
+
|
|
78
|
+
return type.cast(number.doubleValue());
|
|
79
|
+
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
return null;
|
|
83
|
+
}
|
|
84
|
+
}
|
package/changelog.md
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
## Unreleased
|
|
2
|
+
|
|
3
|
+
**ADDED**
|
|
4
|
+
* Add restricted version
|
|
5
|
+
|
|
6
|
+
## 2.5.2
|
|
7
|
+
|
|
8
|
+
**FIXED**
|
|
9
|
+
* Solve issue that ABUser’s copy method may crash App in edge case for iOS
|
|
10
|
+
* Update `Airbridge iOS SDK` to 1.34.9
|
|
11
|
+
|
|
12
|
+
## 2.5.1
|
|
13
|
+
|
|
14
|
+
**FIXED**
|
|
15
|
+
* Update `Airbridge Android SDK` to 2.22.0
|
|
16
|
+
* Update `Airbridge iOS SDK` to 1.34.0
|
|
17
|
+
|
|
18
|
+
## 2.5.0
|
|
19
|
+
|
|
20
|
+
**FIXED**
|
|
21
|
+
* Update `Airbridge Android SDK` to 2.21.5
|
|
22
|
+
* Update `Airbridge iOS SDK` to 1.32.1
|
|
23
|
+
|
|
24
|
+
## 2.4.0
|
|
25
|
+
|
|
26
|
+
**ADDED**
|
|
27
|
+
* Add SDK logLevel interface
|
|
28
|
+
|
|
29
|
+
## 2.3.0
|
|
30
|
+
|
|
31
|
+
**ADDED**
|
|
32
|
+
* Add SDK Signature feature that protect Airbridge SDK from SDK spoofing.
|
|
33
|
+
|
|
34
|
+
**FIXED**
|
|
35
|
+
* Update `Airbridge Android SDK` to 2.21.0
|
|
36
|
+
* Update `Airbridge iOS SDK` to 1.32.0
|
|
37
|
+
|
|
38
|
+
## 2.2.0
|
|
39
|
+
|
|
40
|
+
**ADDED**
|
|
41
|
+
* Add WebInterface for Hybrid App web interface
|
|
42
|
+
|
|
43
|
+
## 2.1.3
|
|
44
|
+
|
|
45
|
+
**FIXED**
|
|
46
|
+
* solve issue that deeplink event can be lost when open app with deeplink when app is closed not on background with using uninstall tracking.
|
|
47
|
+
|
|
48
|
+
## 2.1.2
|
|
49
|
+
|
|
50
|
+
**FIXED**
|
|
51
|
+
- solve issue that open event may be lost if registerPushToken method is used
|
|
52
|
+
|
|
53
|
+
## 2.1.1
|
|
54
|
+
|
|
55
|
+
**FIXED**
|
|
56
|
+
- solve issue that npm package is unnecessary big
|