airbridge-react-native-sdk-restricted 2.8.8 → 4.1.0

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.
Files changed (268) hide show
  1. package/.github/workflows/build.yml +249 -159
  2. package/.github/workflows/documentation.yml +76 -0
  3. package/.github/workflows/qa.yml +187 -0
  4. package/.github/workflows/release.yml +26 -0
  5. package/airbridge-react-native-sdk-restricted.podspec +10 -7
  6. package/airbridge_sdk.json +4 -0
  7. package/android/build.gradle +22 -5
  8. package/android/{copy-config.gradle → copy-airbridge-json.gradle} +2 -2
  9. package/android/src/main/java/co/ab180/airbridge/reactnative/AirbridgeReactNative.kt +141 -0
  10. package/android/src/main/java/co/ab180/airbridge/reactnative/common/AirbridgeLifecycleIntegration.kt +7 -0
  11. package/android/src/main/java/co/ab180/airbridge/reactnative/extension/AirbridgeOptionBuilderApply.kt +79 -0
  12. package/android/src/main/java/co/ab180/airbridge/reactnative/extension/JSONConvert.kt +33 -0
  13. package/android/src/main/java/co/ab180/airbridge/reactnative/module/AttributionInteractor.kt +54 -0
  14. package/android/src/main/java/co/ab180/airbridge/reactnative/module/DeeplinkInteractor.kt +45 -0
  15. package/android/src/main/java/co/ab180/airbridge/reactnative/module/EventInteractor.kt +22 -0
  16. package/android/src/main/java/co/ab180/airbridge/reactnative/module/FetchInteractor.kt +51 -0
  17. package/android/src/main/java/co/ab180/airbridge/reactnative/module/PlacementInteractor.kt +56 -0
  18. package/android/src/main/java/co/ab180/airbridge/reactnative/module/RegisterInteractor.kt +108 -0
  19. package/android/src/main/java/co/ab180/airbridge/reactnative/module/SwitchInteractor.kt +43 -0
  20. package/android/src/main/java/co/ab180/airbridge/reactnative/module/WebInterfaceInteractor.kt +24 -0
  21. package/build/document/.nojekyll +1 -0
  22. package/build/document/assets/highlight.css +22 -0
  23. package/build/document/assets/icons.js +18 -0
  24. package/build/document/assets/icons.svg +1 -0
  25. package/build/document/assets/main.js +60 -0
  26. package/build/document/assets/navigation.js +1 -0
  27. package/build/document/assets/search.js +1 -0
  28. package/build/document/assets/style.css +1448 -0
  29. package/build/document/classes/Airbridge.html +113 -0
  30. package/build/document/classes/AirbridgeAttribute.html +49 -0
  31. package/build/document/classes/AirbridgeCategory.html +28 -0
  32. package/build/document/index.html +8 -0
  33. package/build/document/modules.html +4 -0
  34. package/build/source/Airbridge.d.ts +230 -0
  35. package/build/source/Airbridge.js +277 -0
  36. package/build/source/Airbridge.js.map +1 -0
  37. package/build/source/architecture/Interactor.d.ts +2 -0
  38. package/build/source/architecture/Interactor.js +7 -0
  39. package/build/source/architecture/Interactor.js.map +1 -0
  40. package/build/source/architecture/module.d.ts +1 -0
  41. package/build/source/architecture/module.js +2 -0
  42. package/build/source/architecture/module.js.map +1 -0
  43. package/build/source/constant/AirbridgeAttribute.d.ts +51 -0
  44. package/build/source/constant/AirbridgeAttribute.js +144 -0
  45. package/build/source/constant/AirbridgeAttribute.js.map +1 -0
  46. package/build/source/constant/AirbridgeCategory.d.ts +30 -0
  47. package/build/source/constant/AirbridgeCategory.js +81 -0
  48. package/build/source/constant/AirbridgeCategory.js.map +1 -0
  49. package/build/source/module/Attribution.d.ts +16 -0
  50. package/build/source/module/Attribution.js +39 -0
  51. package/build/source/module/Attribution.js.map +1 -0
  52. package/build/source/module/Deeplink.d.ts +17 -0
  53. package/build/source/module/Deeplink.js +40 -0
  54. package/build/source/module/Deeplink.js.map +1 -0
  55. package/build/source/module/Event.d.ts +14 -0
  56. package/build/source/module/Event.js +50 -0
  57. package/build/source/module/Event.js.map +1 -0
  58. package/build/source/module/Fetch.d.ts +19 -0
  59. package/build/source/module/Fetch.js +100 -0
  60. package/build/source/module/Fetch.js.map +1 -0
  61. package/build/source/module/Placement.d.ts +18 -0
  62. package/build/source/module/Placement.js +95 -0
  63. package/build/source/module/Placement.js.map +1 -0
  64. package/build/source/module/Register.d.ts +49 -0
  65. package/build/source/module/Register.js +138 -0
  66. package/build/source/module/Register.js.map +1 -0
  67. package/build/source/module/Switch.d.ts +24 -0
  68. package/build/source/module/Switch.js +39 -0
  69. package/build/source/module/Switch.js.map +1 -0
  70. package/build/source/module/WebInterface.d.ts +16 -0
  71. package/build/source/module/WebInterface.js +46 -0
  72. package/build/source/module/WebInterface.js.map +1 -0
  73. package/build/source/module.d.ts +3 -0
  74. package/build/source/module.js +4 -0
  75. package/build/source/module.js.map +1 -0
  76. package/build/source/utility/check.d.ts +13 -0
  77. package/build/source/utility/check.js +15 -0
  78. package/build/source/utility/check.js.map +1 -0
  79. package/build/source/utility/compute.d.ts +3 -0
  80. package/build/source/utility/compute.js +5 -0
  81. package/build/source/utility/compute.js.map +1 -0
  82. package/build/source/utility/create.d.ts +5 -0
  83. package/build/source/utility/create.js +12 -0
  84. package/build/source/utility/create.js.map +1 -0
  85. package/build/source/utility/extract.d.ts +3 -0
  86. package/build/source/utility/extract.js +4 -0
  87. package/build/source/utility/extract.js.map +1 -0
  88. package/build/source/utility/json.d.ts +11 -0
  89. package/build/source/utility/json.js +137 -0
  90. package/build/source/utility/json.js.map +1 -0
  91. package/build/source/utility/log.d.ts +4 -0
  92. package/build/source/utility/log.js +9 -0
  93. package/build/source/utility/log.js.map +1 -0
  94. package/changelog.md +7 -0
  95. package/ios/AirbridgeReactNative/AirbridgeReactNative.h +23 -0
  96. package/ios/AirbridgeReactNative/AirbridgeReactNative.m +36 -0
  97. package/ios/AirbridgeReactNative/AirbridgeReactNative.swift +95 -0
  98. package/ios/AirbridgeReactNative/Extension/AirbridgeOptionBuilderApply.swift +86 -0
  99. package/ios/AirbridgeReactNative/Extension/DataFromHex.swift +21 -0
  100. package/ios/AirbridgeReactNative/Extension/Logger.swift +62 -0
  101. package/ios/AirbridgeReactNative/Module/AirbridgeModuleExtern.m +133 -0
  102. package/ios/AirbridgeReactNative/Module/AttributionInteractor.swift +43 -0
  103. package/ios/AirbridgeReactNative/Module/DeeplinkInteractor.swift +49 -0
  104. package/ios/AirbridgeReactNative/Module/EventInteractor.swift +26 -0
  105. package/ios/AirbridgeReactNative/Module/FetchInteractor.swift +66 -0
  106. package/ios/AirbridgeReactNative/Module/PlacementInteractor.swift +72 -0
  107. package/ios/AirbridgeReactNative/Module/RegisterInteractor.swift +104 -0
  108. package/ios/AirbridgeReactNative/Module/SwitchInteractor.swift +48 -0
  109. package/ios/AirbridgeReactNative/Module/WebInterfaceInteractor.swift +30 -0
  110. package/ios/{copy-config.rb → copy-airbridge-json.rb} +1 -1
  111. package/package.json +18 -27
  112. package/qa/Gemfile +3 -4
  113. package/qa/Gemfile.lock +28 -17
  114. package/qa/airbridge_qa.json +6 -0
  115. package/qa/android/app/build.gradle +30 -26
  116. package/qa/android/app/src/main/AndroidManifest.xml +159 -7
  117. package/qa/android/app/src/main/java/co/ab180/airbridge/qa/application/ConfigurationLoader.kt +5 -5
  118. package/qa/android/app/src/main/java/co/ab180/airbridge/qa/application/MainActivity.kt +2 -2
  119. package/qa/android/app/src/main/java/co/ab180/airbridge/qa/application/module/IdentifiersInteractor.kt +8 -17
  120. package/qa/android/app/src/main/java/co/ab180/airbridge/qa/application/module/InstallReferrerInteractor.kt +13 -22
  121. package/qa/android/app/src/main/java/co/ab180/airbridge/qa/application/module/ModuleInjector.kt +1 -2
  122. package/qa/android/app/src/main/res/values/airbridge.xml +16 -0
  123. package/qa/android/build.gradle +4 -2
  124. package/qa/android/gradle/wrapper/gradle-wrapper.properties +1 -1
  125. package/qa/android/gradle.properties +0 -2
  126. package/qa/android/gradlew +1 -1
  127. package/qa/android/settings.gradle +3 -1
  128. package/qa/ios/AirbridgeQA/AirbridgeQA.entitlements +11 -0
  129. package/qa/ios/AirbridgeQA/AppDelegate.mm +40 -30
  130. package/qa/ios/AirbridgeQA/DeviceInfoInteractor.swift +0 -1
  131. package/qa/ios/AirbridgeQA/IdentifiersInteractor.swift +4 -8
  132. package/qa/ios/AirbridgeQA/Images.xcassets/AppIcon.appiconset/AppIcon-20@2x.png +0 -0
  133. package/qa/ios/AirbridgeQA/Images.xcassets/AppIcon.appiconset/AppIcon-20@2x~ipad.png +0 -0
  134. package/qa/ios/AirbridgeQA/Images.xcassets/AppIcon.appiconset/AppIcon-20@3x.png +0 -0
  135. package/qa/ios/AirbridgeQA/Images.xcassets/AppIcon.appiconset/AppIcon-20~ipad.png +0 -0
  136. package/qa/ios/AirbridgeQA/Images.xcassets/AppIcon.appiconset/AppIcon-29.png +0 -0
  137. package/qa/ios/AirbridgeQA/Images.xcassets/AppIcon.appiconset/AppIcon-29@2x.png +0 -0
  138. package/qa/ios/AirbridgeQA/Images.xcassets/AppIcon.appiconset/AppIcon-29@2x~ipad.png +0 -0
  139. package/qa/ios/AirbridgeQA/Images.xcassets/AppIcon.appiconset/AppIcon-29@3x.png +0 -0
  140. package/qa/ios/AirbridgeQA/Images.xcassets/AppIcon.appiconset/AppIcon-29~ipad.png +0 -0
  141. package/qa/ios/AirbridgeQA/Images.xcassets/AppIcon.appiconset/AppIcon-40@2x.png +0 -0
  142. package/qa/ios/AirbridgeQA/Images.xcassets/AppIcon.appiconset/AppIcon-40@2x~ipad.png +0 -0
  143. package/qa/ios/AirbridgeQA/Images.xcassets/AppIcon.appiconset/AppIcon-40@3x.png +0 -0
  144. package/qa/ios/AirbridgeQA/Images.xcassets/AppIcon.appiconset/AppIcon-40~ipad.png +0 -0
  145. package/qa/ios/AirbridgeQA/Images.xcassets/AppIcon.appiconset/AppIcon-60@2x~car.png +0 -0
  146. package/qa/ios/AirbridgeQA/Images.xcassets/AppIcon.appiconset/AppIcon-60@3x~car.png +0 -0
  147. package/qa/ios/AirbridgeQA/Images.xcassets/AppIcon.appiconset/AppIcon-83.5@2x~ipad.png +0 -0
  148. package/qa/ios/AirbridgeQA/Images.xcassets/AppIcon.appiconset/AppIcon@2x.png +0 -0
  149. package/qa/ios/AirbridgeQA/Images.xcassets/AppIcon.appiconset/AppIcon@2x~ipad.png +0 -0
  150. package/qa/ios/AirbridgeQA/Images.xcassets/AppIcon.appiconset/AppIcon@3x.png +0 -0
  151. package/qa/ios/AirbridgeQA/Images.xcassets/AppIcon.appiconset/AppIcon~ios-marketing.png +0 -0
  152. package/qa/ios/AirbridgeQA/Images.xcassets/AppIcon.appiconset/AppIcon~ipad.png +0 -0
  153. package/qa/ios/AirbridgeQA/Images.xcassets/AppIcon.appiconset/Contents.json +113 -32
  154. package/qa/ios/AirbridgeQA.xcodeproj/project.pbxproj +47 -10
  155. package/qa/ios/InternalLibrary/airbridge-ios-sdk-qa-library.podspec +32 -0
  156. package/qa/ios/InternalLibrary/airbridge-ios-sdk-restricted.podspec +32 -0
  157. package/qa/ios/Library/airbridge-ios-sdk-qa-library.podspec +6 -1
  158. package/qa/ios/Podfile +13 -1
  159. package/qa/ios/Podfile.lock +678 -313
  160. package/qa/ios/Script/prepare-build-parameter.rb +23 -0
  161. package/qa/metro.config.js +5 -2
  162. package/qa/package-lock.json +3360 -1435
  163. package/qa/package.json +29 -30
  164. package/qa/source/App.js +11 -5
  165. package/qa/source/common/FCMService.js +39 -15
  166. package/qa/source/navigations/Stack.js +8 -1
  167. package/qa/source/pages/AppInfo.js +40 -0
  168. package/qa/source/pages/Browse.js +16 -19
  169. package/qa/source/pages/DeviceInfo.js +10 -4
  170. package/qa/source/pages/Event.js +70 -60
  171. package/qa/source/pages/Home.js +77 -17
  172. package/qa/source/pages/Identifiers.js +10 -6
  173. package/qa/source/pages/Placement.js +3 -3
  174. package/qa/source/pages/Skad.js +76 -0
  175. package/qa/source/pages/UserInfo.js +47 -28
  176. package/readme.md +6 -6
  177. package/script/BuildDocument.sh +10 -0
  178. package/{scripts/build-qa.sh → script/BuildQA.sh} +5 -4
  179. package/script/BuildSource.sh +14 -0
  180. package/script/ChangeInternalSDK.sh +22 -0
  181. package/script/ChangeProductionSDK.sh +37 -0
  182. package/script/ChangeRestricted.sh +34 -0
  183. package/script/PrepareBuildParameter.sh +28 -0
  184. package/source/Airbridge.ts +340 -0
  185. package/source/architecture/Interactor.ts +10 -0
  186. package/source/architecture/module.ts +1 -0
  187. package/source/constant/AirbridgeAttribute.ts +188 -0
  188. package/source/constant/AirbridgeCategory.ts +104 -0
  189. package/source/module/Attribution.ts +56 -0
  190. package/source/module/Deeplink.ts +59 -0
  191. package/source/module/Event.ts +71 -0
  192. package/source/module/Fetch.ts +137 -0
  193. package/source/module/Placement.ts +134 -0
  194. package/source/module/Register.ts +203 -0
  195. package/source/module/Switch.ts +61 -0
  196. package/source/module/WebInterface.ts +55 -0
  197. package/source/module.ts +3 -0
  198. package/source/tsconfig.json +14 -0
  199. package/source/utility/check.ts +46 -0
  200. package/source/utility/compute.ts +9 -0
  201. package/source/utility/create.ts +12 -0
  202. package/source/utility/extract.ts +5 -0
  203. package/source/utility/json.ts +180 -0
  204. package/source/utility/log.ts +14 -0
  205. package/test/jest.json +13 -0
  206. package/test/mock.ts +112 -0
  207. package/test/module/Deeplink.test.ts +29 -0
  208. package/test/tsconfig.json +8 -0
  209. package/.eslintrc.json +0 -44
  210. package/.gitattributes +0 -1
  211. package/.github/actions/add-github-check/action.yml +0 -78
  212. package/.github/actions/add-github-comment/action.yml +0 -48
  213. package/.github/actions/add-slack-message/action.yml +0 -32
  214. package/.github/actions/edit-github-check/action.yml +0 -59
  215. package/.github/actions/edit-github-comment/action.yml +0 -41
  216. package/.github/workflows/release-restricted.yml +0 -35
  217. package/android/src/main/java/co/ab180/airbridge/reactnative/AirbridgeAttribution.java +0 -78
  218. package/android/src/main/java/co/ab180/airbridge/reactnative/AirbridgeDeeplink.java +0 -97
  219. package/android/src/main/java/co/ab180/airbridge/reactnative/AirbridgeEvent.java +0 -76
  220. package/android/src/main/java/co/ab180/airbridge/reactnative/AirbridgeLifecycle.java +0 -31
  221. package/android/src/main/java/co/ab180/airbridge/reactnative/AirbridgeLifecycleIntegration.java +0 -8
  222. package/android/src/main/java/co/ab180/airbridge/reactnative/AirbridgePlacement.java +0 -42
  223. package/android/src/main/java/co/ab180/airbridge/reactnative/AirbridgeRN.java +0 -112
  224. package/android/src/main/java/co/ab180/airbridge/reactnative/AirbridgeState.java +0 -174
  225. package/android/src/main/java/co/ab180/airbridge/reactnative/ConfigReader.java +0 -154
  226. package/android/src/main/java/co/ab180/airbridge/reactnative/Get.java +0 -84
  227. package/index.d.ts +0 -338
  228. package/index.js +0 -8
  229. package/ios/AirbridgeRN/ARNConfigReader.h +0 -19
  230. package/ios/AirbridgeRN/ARNConfigReader.m +0 -77
  231. package/ios/AirbridgeRN/ARNGet.h +0 -20
  232. package/ios/AirbridgeRN/ARNGet.m +0 -40
  233. package/ios/AirbridgeRN/ARNHex.h +0 -16
  234. package/ios/AirbridgeRN/ARNHex.m +0 -44
  235. package/ios/AirbridgeRN/AirbridgeAttribution.h +0 -19
  236. package/ios/AirbridgeRN/AirbridgeAttribution.m +0 -47
  237. package/ios/AirbridgeRN/AirbridgeDeeplink.h +0 -20
  238. package/ios/AirbridgeRN/AirbridgeDeeplink.m +0 -59
  239. package/ios/AirbridgeRN/AirbridgeEvent.h +0 -17
  240. package/ios/AirbridgeRN/AirbridgeEvent.m +0 -63
  241. package/ios/AirbridgeRN/AirbridgePlacement.h +0 -17
  242. package/ios/AirbridgeRN/AirbridgePlacement.m +0 -38
  243. package/ios/AirbridgeRN/AirbridgeRN.h +0 -71
  244. package/ios/AirbridgeRN/AirbridgeRN.m +0 -80
  245. package/ios/AirbridgeRN/AirbridgeState.h +0 -17
  246. package/ios/AirbridgeRN/AirbridgeState.m +0 -94
  247. package/ios/AirbridgeRN.xcodeproj/project.pbxproj +0 -417
  248. package/qa/android/app/src/main/java/co/ab180/airbridge/qa/application/module/UserInfoInteractor.kt +0 -74
  249. package/qa/ios/AirbridgeQA/UserInfoInteractor.m +0 -57
  250. package/qa/ios/AirbridgeQA/UserInfoInteractor.swift +0 -49
  251. package/qa/source/pages/appInfo.js +0 -22
  252. package/scripts/addiOSFramework.js +0 -48
  253. package/scripts/change_restricted.sh +0 -21
  254. package/scripts/update_native_version.sh +0 -104
  255. package/src/Airbridge.js +0 -82
  256. package/src/Deeplink.js +0 -75
  257. package/src/Event.js +0 -38
  258. package/src/Placement.js +0 -56
  259. package/src/State.js +0 -175
  260. package/src/WebInterface.js +0 -135
  261. package/src/tool/Log.js +0 -40
  262. package/src/tool/_.js +0 -56
  263. package/src/type/AirbridgeAttributes.js +0 -40
  264. package/src/type/AirbridgeCategory.js +0 -35
  265. package/src/type/AirbridgeProduct.js +0 -18
  266. package/src/typedef/EventOption.js +0 -9
  267. package/src/typedef/Product.js +0 -10
  268. package/src/typedef/User.js +0 -9
@@ -1,174 +0,0 @@
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
- }
@@ -1,154 +0,0 @@
1
- package co.ab180.airbridge.reactnative;
2
-
3
- import android.app.Activity;
4
- import android.content.Context;
5
- import android.content.res.AssetManager;
6
- import android.util.Log;
7
-
8
- import org.json.JSONException;
9
- import org.json.JSONObject;
10
-
11
- import java.io.BufferedReader;
12
- import java.io.IOException;
13
- import java.io.InputStreamReader;
14
- import java.util.Map;
15
- import java.util.HashMap;
16
-
17
- import javax.annotation.Nonnull;
18
- import javax.annotation.Nullable;
19
-
20
- import co.ab180.airbridge.AirbridgeConfig;
21
- import co.ab180.airbridge.OnAttributionResultReceiveListener;
22
-
23
- class ConfigReader {
24
- private ConfigReader() {
25
- }
26
-
27
- static AirbridgeConfig build(
28
- @Nonnull Context context,
29
- @Nonnull String appName,
30
- @Nonnull String appToken,
31
- @Nullable Map<String, Object> airbridgeJSON
32
- ) {
33
- AirbridgeConfig.Builder configBuilder = new AirbridgeConfig.Builder(appName, appToken);
34
-
35
- setJsonObject(context, configBuilder, airbridgeJSON);
36
-
37
- configBuilder.setPlatform("react_native");
38
-
39
- configBuilder.setLifecycleIntegration(activity -> {
40
- AirbridgeLifecycleIntegration callback = AirbridgeLifecycle.getLifecycleIntegration();
41
- if (callback == null) {
42
- return null;
43
- } else {
44
- return callback.getDataString(activity);
45
- }
46
- });
47
-
48
- configBuilder.setOnAttributionResultReceiveListener(AirbridgeAttribution::processAttribution);
49
-
50
- return configBuilder.build();
51
- }
52
-
53
- private static void setJsonObject(
54
- @Nonnull Context context,
55
- AirbridgeConfig.Builder configBuilder,
56
- @Nullable Map<String, Object> airbridgeJSON) {
57
-
58
- JSONObject configObject;
59
- if (airbridgeJSON == null) {
60
- configObject = loadJsonAsset(context);
61
- } else {
62
- configObject = loadAirbridgeJSON(airbridgeJSON);
63
- }
64
-
65
- Number sessionTimeoutSeconds = Get.type(Number.class, configObject, "sessionTimeoutSeconds");
66
- if (sessionTimeoutSeconds != null) {
67
- configBuilder.setSessionTimeoutSeconds(sessionTimeoutSeconds.longValue());
68
- }
69
-
70
- Boolean autoStartTrackingEnabled = Get.type(Boolean.class, configObject, "autoStartTrackingEnabled");
71
- if (autoStartTrackingEnabled != null) {
72
- configBuilder.setAutoStartTrackingEnabled(autoStartTrackingEnabled);
73
- }
74
-
75
- Boolean userInfoHashEnabled = Get.type(Boolean.class, configObject, "userInfoHashEnabled");
76
- if (userInfoHashEnabled != null) {
77
- configBuilder.setUserInfoHashEnabled(userInfoHashEnabled);
78
- }
79
-
80
- Boolean trackAirbridgeLinkOnly = Get.type(Boolean.class, configObject, "trackAirbridgeLinkOnly");
81
- if (trackAirbridgeLinkOnly != null) {
82
- configBuilder.setTrackAirbridgeLinkOnly(trackAirbridgeLinkOnly);
83
- }
84
-
85
- Boolean locationCollectionEnabled = Get.type(Boolean.class, configObject, "locationCollectionEnabled");
86
- if (locationCollectionEnabled != null) {
87
- configBuilder.setLocationCollectionEnabled(locationCollectionEnabled);
88
- }
89
-
90
- Boolean facebookDeferredAppLinkEnabled = Get.type(Boolean.class, configObject, "facebookDeferredAppLinkEnabled");
91
- if (facebookDeferredAppLinkEnabled != null) {
92
- configBuilder.setFacebookDeferredAppLinkEnabled(facebookDeferredAppLinkEnabled);
93
- }
94
-
95
- // The two keys(facebookInstallReferrer, metaInstallReferrer) are mutually exclusive.
96
- String facebookInstallReferrer = Get.type(String.class, configObject, "facebookInstallReferrer");
97
- if (facebookInstallReferrer != null) {
98
- configBuilder.setMetaInstallReferrer(facebookInstallReferrer);
99
- }
100
- String metaInstallReferrer = Get.type(String.class, configObject, "metaInstallReferrer");
101
- if (metaInstallReferrer != null) {
102
- configBuilder.setMetaInstallReferrer(metaInstallReferrer);
103
- }
104
-
105
- String secretId = Get.type(String.class, configObject, "sdkSignatureSecretID");
106
- String secretKey = Get.type(String.class, configObject, "sdkSignatureSecret");
107
- if (secretId != null && secretKey != null) {
108
- configBuilder.setSDKSignatureSecret(secretId, secretKey);
109
- }
110
-
111
- String logLevel = Get.type(String.class, configObject, "logLevel");
112
- Map<String, Integer> logLevelMap = new HashMap<String, Integer>() {{
113
- put("debug", Log.VERBOSE);
114
- put("info", Log.INFO);
115
- put("warning", Log.WARN);
116
- put("error", Log.ERROR);
117
- put("fault", Log.ASSERT);
118
- }};
119
- Integer resultLogLevel = logLevelMap.get(logLevel != null ? logLevel.toLowerCase() : null);
120
- resultLogLevel = resultLogLevel != null ? resultLogLevel : Log.WARN;
121
- configBuilder.setLogLevel(resultLogLevel);
122
-
123
- }
124
-
125
- private static JSONObject loadJsonAsset(@Nonnull Context context) {
126
- JSONObject configObject = null;
127
- AssetManager assetManager = context.getAssets();
128
- try {
129
- BufferedReader reader = new BufferedReader(
130
- new InputStreamReader(assetManager.open("airbridge.json"))
131
- );
132
-
133
- StringBuilder builder = new StringBuilder();
134
-
135
- String line = reader.readLine();
136
- while (line != null) {
137
- builder.append(line);
138
- line = reader.readLine();
139
- }
140
-
141
- configObject = new JSONObject(builder.toString());
142
- } catch (IOException ignored) {
143
- // when do not use airbridge.json file
144
- } catch (JSONException e) {
145
- Log.w("AirbridgeRN", "airbridge.json is not json format");
146
- }
147
- return configObject;
148
- }
149
-
150
- private static JSONObject loadAirbridgeJSON(@Nonnull Map<String, Object> airbridgeJSON) {
151
- return new JSONObject(airbridgeJSON);
152
- }
153
-
154
- }
@@ -1,84 +0,0 @@
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
- }