webtonative 1.0.74 → 1.0.75-beta.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.
Files changed (376) hide show
  1. package/.editorconfig +10 -0
  2. package/.prettierrc.json +7 -0
  3. package/README.md +31 -2
  4. package/build/ATTConsent/index.d.ts +17 -0
  5. package/build/ATTConsent/index.d.ts.map +1 -0
  6. package/build/ATTConsent/index.js +54 -0
  7. package/build/ATTConsent/index.js.map +1 -0
  8. package/build/ATTConsent/types.d.ts +15 -0
  9. package/build/ATTConsent/types.d.ts.map +1 -0
  10. package/build/ATTConsent/types.js +3 -0
  11. package/build/ATTConsent/types.js.map +1 -0
  12. package/build/AdMob/index.d.ts +31 -0
  13. package/build/AdMob/index.d.ts.map +1 -0
  14. package/build/AdMob/index.js +102 -0
  15. package/build/AdMob/index.js.map +1 -0
  16. package/build/AdMob/types.d.ts +25 -0
  17. package/build/AdMob/types.d.ts.map +1 -0
  18. package/build/AdMob/types.js +4 -0
  19. package/build/AdMob/types.js.map +1 -0
  20. package/build/AppReview/index.d.ts +7 -0
  21. package/build/AppReview/index.d.ts.map +1 -0
  22. package/build/AppReview/index.js +22 -0
  23. package/build/AppReview/index.js.map +1 -0
  24. package/build/AppReview/types.d.ts +8 -0
  25. package/build/AppReview/types.d.ts.map +1 -0
  26. package/build/AppReview/types.js +4 -0
  27. package/build/AppReview/types.js.map +1 -0
  28. package/build/AppsFlyer/index.d.ts +15 -0
  29. package/build/AppsFlyer/index.d.ts.map +1 -0
  30. package/build/AppsFlyer/index.js +43 -0
  31. package/build/AppsFlyer/index.js.map +1 -0
  32. package/build/AppsFlyer/types.d.ts +10 -0
  33. package/build/AppsFlyer/types.d.ts.map +1 -0
  34. package/build/AppsFlyer/types.js +3 -0
  35. package/build/AppsFlyer/types.js.map +1 -0
  36. package/build/BackgroundLocation/index.d.ts +12 -0
  37. package/build/BackgroundLocation/index.d.ts.map +1 -0
  38. package/build/BackgroundLocation/index.js +65 -0
  39. package/build/BackgroundLocation/index.js.map +1 -0
  40. package/build/BackgroundLocation/types.d.ts +32 -0
  41. package/build/BackgroundLocation/types.d.ts.map +1 -0
  42. package/build/BackgroundLocation/types.js +3 -0
  43. package/build/BackgroundLocation/types.js.map +1 -0
  44. package/build/Beacon/index.d.ts +7 -0
  45. package/build/Beacon/index.d.ts.map +1 -0
  46. package/build/Beacon/index.js +30 -0
  47. package/build/Beacon/index.js.map +1 -0
  48. package/build/Beacon/types.d.ts +19 -0
  49. package/build/Beacon/types.d.ts.map +1 -0
  50. package/build/Beacon/types.js +3 -0
  51. package/build/Beacon/types.js.map +1 -0
  52. package/build/Biometric/index.d.ts +27 -0
  53. package/build/Biometric/index.d.ts.map +1 -0
  54. package/build/Biometric/index.js +125 -0
  55. package/build/Biometric/index.js.map +1 -0
  56. package/build/Biometric/types.d.ts +24 -0
  57. package/build/Biometric/types.d.ts.map +1 -0
  58. package/build/Biometric/types.js +3 -0
  59. package/build/Biometric/types.js.map +1 -0
  60. package/build/Bluetooth/index.d.ts +17 -0
  61. package/build/Bluetooth/index.d.ts.map +1 -0
  62. package/build/Bluetooth/index.js +67 -0
  63. package/build/Bluetooth/index.js.map +1 -0
  64. package/build/Bluetooth/types.d.ts +34 -0
  65. package/build/Bluetooth/types.d.ts.map +1 -0
  66. package/build/Bluetooth/types.js +3 -0
  67. package/build/Bluetooth/types.js.map +1 -0
  68. package/build/BottomNavigation/index.d.ts +11 -0
  69. package/build/BottomNavigation/index.d.ts.map +1 -0
  70. package/build/BottomNavigation/index.js +41 -0
  71. package/build/BottomNavigation/index.js.map +1 -0
  72. package/build/BottomNavigation/types.d.ts +9 -0
  73. package/build/BottomNavigation/types.d.ts.map +1 -0
  74. package/build/BottomNavigation/types.js +3 -0
  75. package/build/BottomNavigation/types.js.map +1 -0
  76. package/build/Clipboard/index.d.ts +12 -0
  77. package/build/Clipboard/index.d.ts.map +1 -0
  78. package/build/Clipboard/index.js +45 -0
  79. package/build/Clipboard/index.js.map +1 -0
  80. package/build/Clipboard/types.d.ts +20 -0
  81. package/build/Clipboard/types.d.ts.map +1 -0
  82. package/build/Clipboard/types.js +4 -0
  83. package/build/Clipboard/types.js.map +1 -0
  84. package/build/Facebook/events.d.ts +13 -0
  85. package/build/Facebook/events.d.ts.map +1 -0
  86. package/build/Facebook/events.js +44 -0
  87. package/build/Facebook/events.js.map +1 -0
  88. package/build/Facebook/index.d.ts +3 -0
  89. package/build/Facebook/index.d.ts.map +1 -0
  90. package/build/Facebook/index.js +29 -0
  91. package/build/Facebook/index.js.map +1 -0
  92. package/build/Facebook/types.d.ts +22 -0
  93. package/build/Facebook/types.d.ts.map +1 -0
  94. package/build/Facebook/types.js +3 -0
  95. package/build/Facebook/types.js.map +1 -0
  96. package/build/Firebase/Analytics/index.d.ts +32 -0
  97. package/build/Firebase/Analytics/index.d.ts.map +1 -0
  98. package/build/Firebase/Analytics/index.js +110 -0
  99. package/build/Firebase/Analytics/index.js.map +1 -0
  100. package/build/Firebase/Messaging/index.d.ts +17 -0
  101. package/build/Firebase/Messaging/index.d.ts.map +1 -0
  102. package/build/Firebase/Messaging/index.js +64 -0
  103. package/build/Firebase/Messaging/index.js.map +1 -0
  104. package/build/Firebase/index.d.ts +4 -0
  105. package/build/Firebase/index.d.ts.map +1 -0
  106. package/build/Firebase/index.js +31 -0
  107. package/build/Firebase/index.js.map +1 -0
  108. package/build/Firebase/types.d.ts +58 -0
  109. package/build/Firebase/types.d.ts.map +1 -0
  110. package/build/Firebase/types.js +4 -0
  111. package/build/Firebase/types.js.map +1 -0
  112. package/build/FirebaseAnalytics/index.d.ts +3 -0
  113. package/build/FirebaseAnalytics/index.d.ts.map +1 -0
  114. package/build/FirebaseAnalytics/index.js +29 -0
  115. package/build/FirebaseAnalytics/index.js.map +1 -0
  116. package/build/Haptics/index.d.ts +7 -0
  117. package/build/Haptics/index.d.ts.map +1 -0
  118. package/build/Haptics/index.js +21 -0
  119. package/build/Haptics/index.js.map +1 -0
  120. package/build/Haptics/types.d.ts +8 -0
  121. package/build/Haptics/types.d.ts.map +1 -0
  122. package/build/Haptics/types.js +3 -0
  123. package/build/Haptics/types.js.map +1 -0
  124. package/build/InAppPurchase/index.d.ts +23 -0
  125. package/build/InAppPurchase/index.d.ts.map +1 -0
  126. package/build/InAppPurchase/index.js +81 -0
  127. package/build/InAppPurchase/index.js.map +1 -0
  128. package/build/InAppPurchase/types.d.ts +30 -0
  129. package/build/InAppPurchase/types.d.ts.map +1 -0
  130. package/build/InAppPurchase/types.js +3 -0
  131. package/build/InAppPurchase/types.js.map +1 -0
  132. package/build/InAppUpdate/index.d.ts +12 -0
  133. package/build/InAppUpdate/index.d.ts.map +1 -0
  134. package/build/InAppUpdate/index.js +39 -0
  135. package/build/InAppUpdate/index.js.map +1 -0
  136. package/build/InAppUpdate/types.d.ts +15 -0
  137. package/build/InAppUpdate/types.d.ts.map +1 -0
  138. package/build/InAppUpdate/types.js +3 -0
  139. package/build/InAppUpdate/types.js.map +1 -0
  140. package/build/MediaPlayer/index.d.ts +17 -0
  141. package/build/MediaPlayer/index.d.ts.map +1 -0
  142. package/build/MediaPlayer/index.js +56 -0
  143. package/build/MediaPlayer/index.js.map +1 -0
  144. package/build/MediaPlayer/types.d.ts +14 -0
  145. package/build/MediaPlayer/types.d.ts.map +1 -0
  146. package/build/MediaPlayer/types.js +3 -0
  147. package/build/MediaPlayer/types.js.map +1 -0
  148. package/build/NativeContacts/index.d.ts +12 -0
  149. package/build/NativeContacts/index.d.ts.map +1 -0
  150. package/build/NativeContacts/index.js +51 -0
  151. package/build/NativeContacts/index.js.map +1 -0
  152. package/build/NativeContacts/types.d.ts +14 -0
  153. package/build/NativeContacts/types.d.ts.map +1 -0
  154. package/build/NativeContacts/types.js +3 -0
  155. package/build/NativeContacts/types.js.map +1 -0
  156. package/build/Notification/index.d.ts +11 -0
  157. package/build/Notification/index.d.ts.map +1 -0
  158. package/build/Notification/index.js +42 -0
  159. package/build/Notification/index.js.map +1 -0
  160. package/build/Notification/types.d.ts +14 -0
  161. package/build/Notification/types.d.ts.map +1 -0
  162. package/build/Notification/types.js +3 -0
  163. package/build/Notification/types.js.map +1 -0
  164. package/build/OneSignal/index.d.ts +4 -0
  165. package/build/OneSignal/index.d.ts.map +1 -0
  166. package/build/OneSignal/index.js +59 -0
  167. package/build/OneSignal/index.js.map +1 -0
  168. package/build/OneSignal/types.d.ts +11 -0
  169. package/build/OneSignal/types.d.ts.map +1 -0
  170. package/build/OneSignal/types.js +4 -0
  171. package/build/OneSignal/types.js.map +1 -0
  172. package/build/Printing/index.d.ts +7 -0
  173. package/build/Printing/index.d.ts.map +1 -0
  174. package/build/Printing/index.js +20 -0
  175. package/build/Printing/index.js.map +1 -0
  176. package/build/Printing/types.d.ts +9 -0
  177. package/build/Printing/types.d.ts.map +1 -0
  178. package/build/Printing/types.js +3 -0
  179. package/build/Printing/types.js.map +1 -0
  180. package/build/README.md +33 -0
  181. package/build/Screen/index.d.ts +9 -0
  182. package/build/Screen/index.d.ts.map +1 -0
  183. package/build/Screen/index.js +35 -0
  184. package/build/Screen/index.js.map +1 -0
  185. package/build/Screen/types.d.ts +6 -0
  186. package/build/Screen/types.d.ts.map +1 -0
  187. package/build/Screen/types.js +4 -0
  188. package/build/Screen/types.js.map +1 -0
  189. package/build/Siri/index.d.ts +7 -0
  190. package/build/Siri/index.d.ts.map +1 -0
  191. package/build/Siri/index.js +26 -0
  192. package/build/Siri/index.js.map +1 -0
  193. package/build/Siri/types.d.ts +14 -0
  194. package/build/Siri/types.d.ts.map +1 -0
  195. package/build/Siri/types.js +3 -0
  196. package/build/Siri/types.js.map +1 -0
  197. package/build/SocialLogin/apple.d.ts +12 -0
  198. package/build/SocialLogin/apple.d.ts.map +1 -0
  199. package/build/SocialLogin/apple.js +32 -0
  200. package/build/SocialLogin/apple.js.map +1 -0
  201. package/build/SocialLogin/facebook.d.ts +22 -0
  202. package/build/SocialLogin/facebook.d.ts.map +1 -0
  203. package/build/SocialLogin/facebook.js +61 -0
  204. package/build/SocialLogin/facebook.js.map +1 -0
  205. package/build/SocialLogin/google.d.ts +22 -0
  206. package/build/SocialLogin/google.d.ts.map +1 -0
  207. package/build/SocialLogin/google.js +61 -0
  208. package/build/SocialLogin/google.js.map +1 -0
  209. package/build/SocialLogin/index.d.ts +17 -0
  210. package/build/SocialLogin/index.d.ts.map +1 -0
  211. package/build/SocialLogin/index.js +23 -0
  212. package/build/SocialLogin/index.js.map +1 -0
  213. package/build/SocialLogin/types.d.ts +39 -0
  214. package/build/SocialLogin/types.d.ts.map +1 -0
  215. package/build/SocialLogin/types.js +3 -0
  216. package/build/SocialLogin/types.js.map +1 -0
  217. package/build/Stripe/index.d.ts +3 -0
  218. package/build/Stripe/index.d.ts.map +1 -0
  219. package/build/Stripe/index.js +49 -0
  220. package/build/Stripe/index.js.map +1 -0
  221. package/build/Stripe/types.d.ts +32 -0
  222. package/build/Stripe/types.d.ts.map +1 -0
  223. package/build/Stripe/types.js +3 -0
  224. package/build/Stripe/types.js.map +1 -0
  225. package/build/VoiceSearch/index.d.ts +13 -0
  226. package/build/VoiceSearch/index.d.ts.map +1 -0
  227. package/build/VoiceSearch/index.js +34 -0
  228. package/build/VoiceSearch/index.js.map +1 -0
  229. package/build/VoiceSearch/types.d.ts +10 -0
  230. package/build/VoiceSearch/types.d.ts.map +1 -0
  231. package/build/VoiceSearch/types.js +3 -0
  232. package/build/VoiceSearch/types.js.map +1 -0
  233. package/build/barcode/barcode-scan.d.ts +16 -0
  234. package/build/barcode/barcode-scan.d.ts.map +1 -0
  235. package/build/barcode/barcode-scan.js +40 -0
  236. package/build/barcode/barcode-scan.js.map +1 -0
  237. package/build/barcode/barcode-types.d.ts +18 -0
  238. package/build/barcode/barcode-types.d.ts.map +1 -0
  239. package/build/barcode/barcode-types.js +3 -0
  240. package/build/barcode/barcode-types.js.map +1 -0
  241. package/build/barcode/formats.d.ts +18 -0
  242. package/build/barcode/formats.d.ts.map +1 -0
  243. package/build/barcode/formats.js +23 -0
  244. package/build/barcode/formats.js.map +1 -0
  245. package/build/barcode/index.d.ts +5 -0
  246. package/build/barcode/index.d.ts.map +1 -0
  247. package/build/barcode/index.js +13 -0
  248. package/build/barcode/index.js.map +1 -0
  249. package/build/barcode/types.d.ts +17 -0
  250. package/build/barcode/types.d.ts.map +1 -0
  251. package/build/barcode/types.js +22 -0
  252. package/build/barcode/types.js.map +1 -0
  253. package/build/index.d.ts +15 -0
  254. package/build/index.d.ts.map +1 -0
  255. package/build/index.js +110 -0
  256. package/build/index.js.map +1 -0
  257. package/build/package.json +155 -0
  258. package/build/types/index.d.ts +49 -0
  259. package/build/types/index.d.ts.map +1 -0
  260. package/build/types/index.js +4 -0
  261. package/build/types/index.js.map +1 -0
  262. package/build/utills.d.ts +12 -0
  263. package/build/utills.d.ts.map +1 -0
  264. package/build/utills.js +111 -0
  265. package/build/utills.js.map +1 -0
  266. package/build/webtonative.min.js +1 -0
  267. package/buildScript.ts +35 -0
  268. package/client.ts +106 -0
  269. package/index.d.ts +65 -0
  270. package/package.json +36 -31
  271. package/src/ATTConsent/index.ts +51 -0
  272. package/src/ATTConsent/types.ts +17 -0
  273. package/src/AdMob/index.ts +113 -0
  274. package/src/AdMob/types.ts +37 -0
  275. package/src/AppReview/index.ts +19 -0
  276. package/src/AppReview/types.ts +12 -0
  277. package/src/AppsFlyer/index.ts +46 -0
  278. package/src/AppsFlyer/types.ts +10 -0
  279. package/src/BackgroundLocation/index.ts +78 -0
  280. package/src/BackgroundLocation/types.ts +34 -0
  281. package/src/Beacon/index.ts +28 -0
  282. package/src/Beacon/types.ts +22 -0
  283. package/src/Biometric/index.ts +126 -0
  284. package/src/Biometric/types.ts +27 -0
  285. package/src/Bluetooth/index.ts +71 -0
  286. package/src/Bluetooth/types.ts +40 -0
  287. package/src/BottomNavigation/index.ts +39 -0
  288. package/src/BottomNavigation/types.ts +9 -0
  289. package/src/Clipboard/index.ts +48 -0
  290. package/src/Clipboard/types.ts +30 -0
  291. package/src/Facebook/events.ts +45 -0
  292. package/src/Facebook/index.ts +3 -0
  293. package/src/Facebook/types.ts +24 -0
  294. package/src/Firebase/Analytics/index.ts +127 -0
  295. package/src/Firebase/Messaging/index.ts +73 -0
  296. package/src/Firebase/index.ts +4 -0
  297. package/src/Firebase/types.ts +74 -0
  298. package/src/FirebaseAnalytics/index.ts +3 -0
  299. package/src/Haptics/index.ts +17 -0
  300. package/src/Haptics/types.ts +8 -0
  301. package/src/InAppPurchase/index.ts +92 -0
  302. package/src/InAppPurchase/types.ts +35 -0
  303. package/src/InAppUpdate/index.ts +40 -0
  304. package/src/InAppUpdate/types.ts +17 -0
  305. package/src/MediaPlayer/index.ts +56 -0
  306. package/src/MediaPlayer/types.ts +15 -0
  307. package/src/NativeContacts/index.ts +50 -0
  308. package/src/NativeContacts/types.ts +16 -0
  309. package/src/Notification/index.ts +41 -0
  310. package/src/Notification/types.ts +16 -0
  311. package/src/OneSignal/index.ts +54 -0
  312. package/src/OneSignal/types.ts +15 -0
  313. package/src/Printing/index.ts +17 -0
  314. package/src/Printing/types.ts +9 -0
  315. package/src/Screen/index.ts +34 -0
  316. package/src/Screen/types.ts +8 -0
  317. package/src/Siri/index.ts +23 -0
  318. package/src/Siri/types.ts +14 -0
  319. package/src/SocialLogin/apple.ts +31 -0
  320. package/src/SocialLogin/facebook.ts +64 -0
  321. package/src/SocialLogin/google.ts +64 -0
  322. package/src/SocialLogin/index.ts +20 -0
  323. package/src/SocialLogin/types.ts +52 -0
  324. package/src/Stripe/index.ts +54 -0
  325. package/src/Stripe/types.ts +37 -0
  326. package/src/VoiceSearch/index.ts +37 -0
  327. package/src/VoiceSearch/types.ts +12 -0
  328. package/src/barcode/barcode-scan.ts +59 -0
  329. package/src/barcode/barcode-types.ts +22 -0
  330. package/src/barcode/formats.ts +19 -0
  331. package/src/barcode/index.ts +5 -0
  332. package/src/barcode/types.ts +18 -0
  333. package/src/index.ts +105 -0
  334. package/src/types/index.ts +71 -0
  335. package/src/utills.ts +110 -0
  336. package/tsconfig.json +27 -0
  337. package/webpack.config.js +57 -0
  338. package/ATTConsent/index.js +0 -1
  339. package/AdMob/index.js +0 -1
  340. package/AppReview/index.js +0 -1
  341. package/AppsFlyer/index.js +0 -4
  342. package/BackgroundLocation/index.js +0 -4
  343. package/Beacon/index.js +0 -1
  344. package/Biometric/index.js +0 -1
  345. package/Bluetooth/index.js +0 -1
  346. package/BottomNavigation/index.js +0 -4
  347. package/Clipboard/index.js +0 -4
  348. package/Facebook/events.js +0 -4
  349. package/Facebook/index.js +0 -1
  350. package/Firebase/Analytics/index.js +0 -4
  351. package/Firebase/Messaging/index.js +0 -4
  352. package/Firebase/index.js +0 -1
  353. package/FirebaseAnalytics/index.js +0 -1
  354. package/Haptics/index.js +0 -1
  355. package/InAppPurchase/index.js +0 -1
  356. package/InAppUpdate/index.js +0 -1
  357. package/MediaPlayer/index.js +0 -7
  358. package/NativeContacts/index.js +0 -6
  359. package/Notification/index.js +0 -5
  360. package/OneSignal/index.js +0 -1
  361. package/Printing/index.js +0 -1
  362. package/Screen/index.js +0 -4
  363. package/Siri/index.js +0 -1
  364. package/SocialLogin/apple.js +0 -1
  365. package/SocialLogin/facebook.js +0 -9
  366. package/SocialLogin/google.js +0 -9
  367. package/SocialLogin/index.js +0 -1
  368. package/Stripe/index.js +0 -1
  369. package/VoiceSearch/index.js +0 -1
  370. package/barcode/barcode-scan.js +0 -1
  371. package/barcode/formats.js +0 -1
  372. package/barcode/index.js +0 -1
  373. package/barcode/types.js +0 -1
  374. package/index.js +0 -4
  375. package/utills.js +0 -1
  376. package/webtonative.min.js +0 -1
@@ -0,0 +1,92 @@
1
+ import { platform, registerCb, webToNative, webToNativeIos } from "../utills";
2
+ import {
3
+ InAppPurchaseOptions,
4
+ GetAllPurchasesOptions,
5
+ GetReceiptDataOptions,
6
+ InAppPurchaseResponse,
7
+ InAppPurchaseIosMessage,
8
+ InAppPurchaseAndroidParams
9
+ } from "./types";
10
+
11
+ /**
12
+ * This function handles native in app purchase
13
+ * @param options - Options for in-app purchase
14
+ * @example wtn.inAppPurchase({
15
+ * productId : 'productId'
16
+ * callback:(data)=>{
17
+ * console.log(data);
18
+ * }
19
+ * });
20
+ */
21
+ export const inAppPurchase = (options: InAppPurchaseOptions): void => {
22
+ if (["ANDROID_APP", "IOS_APP"].includes(platform)) {
23
+ const { callback, productId, productType, isConsumable = false } = options;
24
+
25
+ registerCb((response: InAppPurchaseResponse) => {
26
+ const { type } = response;
27
+ if (type === "inAppPurchase") {
28
+ callback && callback(response);
29
+ }
30
+ });
31
+
32
+ if (platform === "IOS_APP" && webToNativeIos) {
33
+ webToNativeIos.postMessage({
34
+ action: "inAppPurchase",
35
+ productId,
36
+ } as InAppPurchaseIosMessage);
37
+ }
38
+
39
+ platform === "ANDROID_APP" &&
40
+ webToNative.inAppPurchase(JSON.stringify({
41
+ action: "inAppPurchase",
42
+ productId,
43
+ productType,
44
+ isConsumable
45
+ } as InAppPurchaseAndroidParams));
46
+ }
47
+ };
48
+
49
+ /**
50
+ * Gets all purchases (Android only)
51
+ * @param options - Options for getting all purchases
52
+ */
53
+ export const getAllPurchases = (options: GetAllPurchasesOptions): void => {
54
+ if (["ANDROID_APP"].includes(platform)) {
55
+ const { callback } = options;
56
+
57
+ registerCb((response: InAppPurchaseResponse) => {
58
+ const { type } = response;
59
+ if (type === "purchaseList") {
60
+ callback && callback(response);
61
+ }
62
+ });
63
+
64
+ platform === "ANDROID_APP" &&
65
+ webToNative.getAllPurchases({
66
+ action: "purchaseList"
67
+ });
68
+ }
69
+ };
70
+
71
+ /**
72
+ * Gets receipt data (iOS only)
73
+ * @param options - Options for getting receipt data
74
+ */
75
+ export const getReceiptData = (options: GetReceiptDataOptions): void => {
76
+ if (["IOS_APP"].includes(platform)) {
77
+ const { callback } = options;
78
+
79
+ registerCb((response: InAppPurchaseResponse) => {
80
+ const { type } = response;
81
+ if (type === "getReceiptData") {
82
+ callback && callback(response);
83
+ }
84
+ });
85
+
86
+ if (platform === "IOS_APP" && webToNativeIos) {
87
+ webToNativeIos.postMessage({
88
+ action: "getReceiptData"
89
+ } as InAppPurchaseIosMessage);
90
+ }
91
+ }
92
+ };
@@ -0,0 +1,35 @@
1
+ export interface InAppPurchaseResponse {
2
+ type: string;
3
+ [key: string]: any;
4
+ }
5
+
6
+ export interface InAppPurchaseCallback {
7
+ (response: InAppPurchaseResponse): void;
8
+ }
9
+
10
+ export interface InAppPurchaseOptions {
11
+ productId: string;
12
+ callback?: InAppPurchaseCallback;
13
+ productType?: string;
14
+ isConsumable?: boolean;
15
+ }
16
+
17
+ export interface GetAllPurchasesOptions {
18
+ callback?: InAppPurchaseCallback;
19
+ }
20
+
21
+ export interface GetReceiptDataOptions {
22
+ callback?: InAppPurchaseCallback;
23
+ }
24
+
25
+ export interface InAppPurchaseIosMessage {
26
+ action: string;
27
+ productId?: string;
28
+ }
29
+
30
+ export interface InAppPurchaseAndroidParams {
31
+ action: string;
32
+ productId?: string;
33
+ productType?: string;
34
+ isConsumable?: boolean;
35
+ }
@@ -0,0 +1,40 @@
1
+ import { platform, registerCb, webToNative } from "../utills";
2
+ import { CheckUpdateOptions, UpdateApplicationOptions, InAppUpdateResponse } from "./types";
3
+
4
+ /**
5
+ * Checks if an app update is available (Android only)
6
+ * @param options - Options for checking app update
7
+ */
8
+ export const checkIfAppUpdateAvailable = (options: CheckUpdateOptions): void => {
9
+ if (["ANDROID_APP"].includes(platform)) {
10
+ const { callback } = options;
11
+
12
+ registerCb((response: InAppUpdateResponse) => {
13
+ const { type } = response;
14
+ if (type === "checkIfAppUpdateAvailable") {
15
+ callback && callback(response);
16
+ }
17
+ });
18
+
19
+ platform === "ANDROID_APP" && webToNative.checkIfAppUpdateAvailable();
20
+ }
21
+ };
22
+
23
+ /**
24
+ * Updates the application (Android only)
25
+ * @param options - Options for updating the application
26
+ */
27
+ export const updateApplication = (options: UpdateApplicationOptions): void => {
28
+ if (["ANDROID_APP"].includes(platform)) {
29
+ const { updateType = "immediate", callback } = options;
30
+
31
+ registerCb((response: InAppUpdateResponse) => {
32
+ const { type } = response;
33
+ if (type === "updateApplication") {
34
+ callback && callback(response);
35
+ }
36
+ });
37
+
38
+ platform === "ANDROID_APP" && webToNative.updateApplication(updateType);
39
+ }
40
+ };
@@ -0,0 +1,17 @@
1
+ export interface InAppUpdateResponse {
2
+ type: string;
3
+ [key: string]: any;
4
+ }
5
+
6
+ export interface InAppUpdateCallback {
7
+ (response: InAppUpdateResponse): void;
8
+ }
9
+
10
+ export interface CheckUpdateOptions {
11
+ callback?: InAppUpdateCallback;
12
+ }
13
+
14
+ export interface UpdateApplicationOptions {
15
+ updateType?: 'immediate' | 'flexible';
16
+ callback?: InAppUpdateCallback;
17
+ }
@@ -0,0 +1,56 @@
1
+ import { platform, webToNative, webToNativeIos } from "../utills";
2
+ import { MediaPlayerOptions, MediaPlayerIosMessage, MediaPlayerAndroidParams } from "./types";
3
+
4
+ /**
5
+ * Plays media content
6
+ * @param options - Options for playing media
7
+ */
8
+ export const playMedia = (options: MediaPlayerOptions = {}): void => {
9
+ const { url, imageUrl = "https://images.freeimages.com/images/large-previews/3b2/prague-conference-center-1056491.jpg" } = options;
10
+ if (["ANDROID_APP", "IOS_APP"].includes(platform)) {
11
+
12
+ platform === "ANDROID_APP" && webToNative.playMedia(JSON.stringify({url, imageUrl} as MediaPlayerAndroidParams));
13
+
14
+ if (platform === "IOS_APP" && webToNativeIos) {
15
+ webToNativeIos.postMessage({
16
+ "action": "playMedia",
17
+ url,
18
+ image: imageUrl
19
+ } as MediaPlayerIosMessage);
20
+ }
21
+ }
22
+ };
23
+
24
+ /**
25
+ * Pauses currently playing media
26
+ * @param options - Options for pausing media
27
+ */
28
+ export const pauseMedia = (options: MediaPlayerOptions = {}): void => {
29
+ if (["ANDROID_APP", "IOS_APP"].includes(platform)) {
30
+
31
+ platform === "ANDROID_APP" && webToNative.pausePlaying();
32
+
33
+ if (platform === "IOS_APP" && webToNativeIos) {
34
+ webToNativeIos.postMessage({
35
+ "action": "pauseMedia"
36
+ } as MediaPlayerIosMessage);
37
+ }
38
+ }
39
+ };
40
+
41
+ /**
42
+ * Stops currently playing media
43
+ * @param options - Options for stopping media
44
+ */
45
+ export const stopMedia = (options: MediaPlayerOptions = {}): void => {
46
+ if (["ANDROID_APP", "IOS_APP"].includes(platform)) {
47
+
48
+ platform === "ANDROID_APP" && webToNative.stopPlaying();
49
+
50
+ if (platform === "IOS_APP" && webToNativeIos) {
51
+ webToNativeIos.postMessage({
52
+ "action": "stopMedia"
53
+ } as MediaPlayerIosMessage);
54
+ }
55
+ }
56
+ };
@@ -0,0 +1,15 @@
1
+ export interface MediaPlayerOptions {
2
+ url?: string;
3
+ imageUrl?: string;
4
+ }
5
+
6
+ export interface MediaPlayerIosMessage {
7
+ action: string;
8
+ url?: string;
9
+ image?: string;
10
+ }
11
+
12
+ export interface MediaPlayerAndroidParams {
13
+ url?: string;
14
+ imageUrl?: string;
15
+ }
@@ -0,0 +1,50 @@
1
+ import { platform, registerCb, webToNative, webToNativeIos } from "../utills";
2
+ import { ContactsOptions, ContactsResponse, ContactsIosMessage } from "./types";
3
+
4
+ /**
5
+ * Gets the permission status for contacts access
6
+ * @param options - Options for getting permission status
7
+ */
8
+ export const getPermissionStatus = (options: ContactsOptions = {}): void => {
9
+ const { callback } = options;
10
+ if (["ANDROID_APP", "IOS_APP"].includes(platform)) {
11
+ registerCb((response: ContactsResponse) => {
12
+ const { type } = response;
13
+ if (type === "contactPermissionStatus") {
14
+ callback && callback(response);
15
+ }
16
+ });
17
+
18
+ platform === "ANDROID_APP" && webToNative.getPermissionStatus();
19
+
20
+ if (platform === "IOS_APP" && webToNativeIos) {
21
+ webToNativeIos.postMessage({
22
+ action: "askUserForContactPermission",
23
+ } as ContactsIosMessage);
24
+ }
25
+ }
26
+ };
27
+
28
+ /**
29
+ * Gets all contacts from the device
30
+ * @param options - Options for getting all contacts
31
+ */
32
+ export const getAll = (options: ContactsOptions = {}): void => {
33
+ const { callback } = options;
34
+ if (["ANDROID_APP", "IOS_APP"].includes(platform)) {
35
+ registerCb((response: ContactsResponse) => {
36
+ const { type } = response;
37
+ if (type === "contactDetails") {
38
+ callback && callback(response);
39
+ }
40
+ });
41
+
42
+ platform === "ANDROID_APP" && webToNative.getAll();
43
+
44
+ if (platform === "IOS_APP" && webToNativeIos) {
45
+ webToNativeIos.postMessage({
46
+ action: "getUserContactDetails",
47
+ } as ContactsIosMessage);
48
+ }
49
+ }
50
+ };
@@ -0,0 +1,16 @@
1
+ export interface ContactsResponse {
2
+ type: string;
3
+ [key: string]: any;
4
+ }
5
+
6
+ export interface ContactsCallback {
7
+ (response: ContactsResponse): void;
8
+ }
9
+
10
+ export interface ContactsOptions {
11
+ callback?: ContactsCallback;
12
+ }
13
+
14
+ export interface ContactsIosMessage {
15
+ action: string;
16
+ }
@@ -0,0 +1,41 @@
1
+ import { platform, registerCb, webToNative, webToNativeIos } from "../utills";
2
+ import { NotificationOptions, NotificationResponse, NotificationIosMessage } from "./types";
3
+
4
+ /**
5
+ * Checks notification permission status
6
+ * @param options - Options for checking notification permission
7
+ */
8
+ export const checkNotificationPermission = (options: NotificationOptions = {}): void => {
9
+ const { callback } = options;
10
+ if (["ANDROID_APP", "IOS_APP"].includes(platform)) {
11
+ registerCb((response: NotificationResponse) => {
12
+ const { type } = response;
13
+ if (type === "checkNotificationPermission") {
14
+ callback && callback(response);
15
+ }
16
+ });
17
+
18
+ platform === "ANDROID_APP" && webToNative.checkNotificationPermission();
19
+
20
+ if (platform === "IOS_APP" && webToNativeIos) {
21
+ webToNativeIos.postMessage({
22
+ action: "checkNotificationPermission",
23
+ } as NotificationIosMessage);
24
+ }
25
+ }
26
+ };
27
+
28
+ /**
29
+ * Opens the app notification settings page
30
+ */
31
+ export const openAppNotificationPage = (): void => {
32
+ if (["ANDROID_APP", "IOS_APP"].includes(platform)) {
33
+ platform === "ANDROID_APP" && webToNative.openAppNotificationPage();
34
+
35
+ if (platform === "IOS_APP" && webToNativeIos) {
36
+ webToNativeIos.postMessage({
37
+ action: "openAppNotificationPage",
38
+ } as NotificationIosMessage);
39
+ }
40
+ }
41
+ };
@@ -0,0 +1,16 @@
1
+ export interface NotificationResponse {
2
+ type: string;
3
+ [key: string]: any;
4
+ }
5
+
6
+ export interface NotificationCallback {
7
+ (response: NotificationResponse): void;
8
+ }
9
+
10
+ export interface NotificationOptions {
11
+ callback?: NotificationCallback;
12
+ }
13
+
14
+ export interface NotificationIosMessage {
15
+ action: string;
16
+ }
@@ -0,0 +1,54 @@
1
+ import { isNativeApp, platform, webToNative, registerCb, webToNativeIos } from "../utills";
2
+ import { Platform, RegisterCallbackOptions } from "../types";
3
+ import { PlayerIdResponse, OneSignalIosMessage } from "./types";
4
+
5
+ export const getPlayerId = (): Promise<string> => {
6
+ return new Promise<string>((resolve, reject) => {
7
+ registerCb(
8
+ (results: PlayerIdResponse) => {
9
+ if (results.isSuccess) {
10
+ resolve(results.playerId as string);
11
+ } else {
12
+ reject(results);
13
+ }
14
+ },
15
+ {
16
+ key: "getPlayerId",
17
+ } as RegisterCallbackOptions
18
+ );
19
+ if (platform === "ANDROID_APP") {
20
+ webToNative.getOneSignalId();
21
+ } else if (platform === "IOS_APP" && webToNativeIos) {
22
+ webToNativeIos.postMessage({
23
+ action: "getPlayerId",
24
+ } as OneSignalIosMessage);
25
+ } else {
26
+ reject("This function will work in Native App Powered By WebToNative");
27
+ }
28
+ });
29
+ };
30
+
31
+ export const setExternalUserId = (userId: string): boolean | void => {
32
+ if (userId) {
33
+ if (platform === "ANDROID_APP") {
34
+ return isNativeApp && webToNative.setExternalUserId(userId);
35
+ } else if (platform === "IOS_APP" && webToNativeIos) {
36
+ webToNativeIos.postMessage({
37
+ action: "setExternalUserId",
38
+ userId: userId,
39
+ } as OneSignalIosMessage);
40
+ }
41
+ } else {
42
+ throw "userId is required";
43
+ }
44
+ };
45
+
46
+ export const removeExternalUserId = (): boolean | void => {
47
+ if (platform === "ANDROID_APP") {
48
+ return isNativeApp && webToNative.removeExternalUserId();
49
+ } else if (platform === "IOS_APP" && webToNativeIos) {
50
+ webToNativeIos.postMessage({
51
+ action: "removeExternalUserId",
52
+ } as OneSignalIosMessage);
53
+ }
54
+ };
@@ -0,0 +1,15 @@
1
+ // Define types for OneSignal module
2
+
3
+ // Response from getPlayerId
4
+ export interface PlayerIdResponse {
5
+ isSuccess: boolean;
6
+ playerId?: string;
7
+ [key: string]: any;
8
+ }
9
+
10
+ // Message structure for iOS
11
+ export interface OneSignalIosMessage {
12
+ action: string;
13
+ userId?: string;
14
+ [key: string]: any;
15
+ }
@@ -0,0 +1,17 @@
1
+ import { platform, webToNative } from "../utills";
2
+ import { PrintingOptions, PrintingAndroidParams } from "./types";
3
+
4
+ /**
5
+ * Sets the print size for Android printing
6
+ * @param options - Options for setting print size
7
+ */
8
+ export const setPrintSize = (options: PrintingOptions): void => {
9
+ if (["ANDROID_APP"].includes(platform)) {
10
+ let { printSize = "ISO_A4", label = "" } = options;
11
+ platform === "ANDROID_APP" &&
12
+ webToNative.setPrintSize(JSON.stringify({
13
+ printSize,
14
+ label
15
+ } as PrintingAndroidParams));
16
+ }
17
+ };
@@ -0,0 +1,9 @@
1
+ export interface PrintingOptions {
2
+ printSize?: string;
3
+ label?: string;
4
+ }
5
+
6
+ export interface PrintingAndroidParams {
7
+ printSize: string;
8
+ label: string;
9
+ }
@@ -0,0 +1,34 @@
1
+ import { platform, webToNative, webToNativeIos } from "../utills";
2
+ import { ScreenIosMessage } from "./types";
3
+
4
+ /**
5
+ * Keeps the screen on (prevents screen from turning off)
6
+ */
7
+ export const keepScreenOn = (): void => {
8
+ if (["ANDROID_APP", "IOS_APP"].includes(platform)) {
9
+ if (platform === "IOS_APP" && webToNativeIos) {
10
+ webToNativeIos.postMessage({
11
+ action: "keepScreenOn",
12
+ flag: true,
13
+ } as ScreenIosMessage);
14
+ }
15
+
16
+ platform === "ANDROID_APP" && webToNative.keepScreenOn();
17
+ }
18
+ };
19
+
20
+ /**
21
+ * Returns screen to normal behavior (allows screen to turn off)
22
+ */
23
+ export const keepScreenNormal = (): void => {
24
+ if (["ANDROID_APP", "IOS_APP"].includes(platform)) {
25
+ if (platform === "IOS_APP" && webToNativeIos) {
26
+ webToNativeIos.postMessage({
27
+ action: "keepScreenOn",
28
+ flag: false,
29
+ } as ScreenIosMessage);
30
+ }
31
+
32
+ platform === "ANDROID_APP" && webToNative.keepScreenNormal();
33
+ }
34
+ };
@@ -0,0 +1,8 @@
1
+ // Define types for Screen module
2
+
3
+ // iOS message structure
4
+ export interface ScreenIosMessage {
5
+ action: string;
6
+ flag?: boolean;
7
+ [key: string]: any;
8
+ }
@@ -0,0 +1,23 @@
1
+ import { platform, webToNativeIos } from "../utills";
2
+ import { SiriOptions, SiriIosMessage } from "./types";
3
+
4
+ /**
5
+ * Adds an action to Siri (iOS only)
6
+ * @param options - Options for adding to Siri
7
+ */
8
+ export const addToSiri = (options: SiriOptions = {}): void => {
9
+ const { actionUrl, suggestedPhrase, title } = options;
10
+ if (["IOS_APP"].includes(platform)) {
11
+
12
+ if (platform === "IOS_APP" && webToNativeIos) {
13
+ webToNativeIos.postMessage({
14
+ "action": "addToSiri",
15
+ "data": {
16
+ actionUrl,
17
+ suggestedPhrase,
18
+ title
19
+ }
20
+ } as SiriIosMessage);
21
+ }
22
+ }
23
+ };
@@ -0,0 +1,14 @@
1
+ export interface SiriOptions {
2
+ actionUrl?: string;
3
+ suggestedPhrase?: string;
4
+ title?: string;
5
+ }
6
+
7
+ export interface SiriIosMessage {
8
+ action: string;
9
+ data?: {
10
+ actionUrl?: string;
11
+ suggestedPhrase?: string;
12
+ title?: string;
13
+ };
14
+ }
@@ -0,0 +1,31 @@
1
+ import { platform, registerCb, webToNativeIos } from "../utills";
2
+ import { SocialLoginOptions, AppleLoginResponse, AppleIosMessage } from "./types";
3
+
4
+ /**
5
+ * This function handles native Apple login
6
+ * @param options - Options for Apple login
7
+ * @example wtn.socialLogin.apple.login({
8
+ * callback:(data)=>{
9
+ * console.log(data);
10
+ * }
11
+ * });
12
+ */
13
+ export const login = (options: SocialLoginOptions): void => {
14
+ if (["ANDROID_APP", "IOS_APP"].includes(platform)) {
15
+ const { callback, scope } = options;
16
+
17
+ registerCb((response: AppleLoginResponse) => {
18
+ const { type } = response;
19
+ if (type === "appleLoginToken") {
20
+ callback && callback(response);
21
+ }
22
+ });
23
+
24
+ if (platform === "IOS_APP" && webToNativeIos) {
25
+ webToNativeIos.postMessage({
26
+ action: "appleSignIn",
27
+ scope,
28
+ } as AppleIosMessage);
29
+ }
30
+ }
31
+ };
@@ -0,0 +1,64 @@
1
+ import { platform, registerCb, webToNative, webToNativeIos } from "../utills";
2
+ import { SocialLoginOptions, FacebookLoginResponse, FacebookLogoutResponse, FacebookIosMessage } from "./types";
3
+
4
+ /**
5
+ * This function handles native facebook login
6
+ * @param options - Options for Facebook login
7
+ * @example wtn.socialLogin.facebook.login({
8
+ * callback:(data)=>{
9
+ * console.log(data);
10
+ * }
11
+ * });
12
+ */
13
+ export const login = (options: SocialLoginOptions): void => {
14
+ if (["ANDROID_APP", "IOS_APP"].includes(platform)) {
15
+ const { callback, scope } = options;
16
+
17
+ registerCb((response: FacebookLoginResponse) => {
18
+ const { type } = response;
19
+ if (type === "fbLoginToken") {
20
+ callback && callback(response);
21
+ }
22
+ });
23
+
24
+ platform === "ANDROID_APP" && webToNative.loginWithFacebook();
25
+
26
+ if (platform === "IOS_APP" && webToNativeIos) {
27
+ webToNativeIos.postMessage({
28
+ action: "fbSignIn",
29
+ scope,
30
+ } as FacebookIosMessage);
31
+ }
32
+ }
33
+ };
34
+
35
+ /**
36
+ * This function handles native facebook logout
37
+ * @param options - Options for Facebook logout
38
+ * @example wtn.socialLogin.facebook.logout({
39
+ * callback:(data)=>{
40
+ * console.log(data);
41
+ * }
42
+ * });
43
+ */
44
+ export const logout = (options: SocialLoginOptions): void => {
45
+ if (["ANDROID_APP", "IOS_APP"].includes(platform)) {
46
+ const { callback, scope } = options;
47
+
48
+ registerCb((response: FacebookLogoutResponse) => {
49
+ const { type } = response;
50
+ if (type === "fbLogOut") {
51
+ callback && callback(response);
52
+ }
53
+ });
54
+
55
+ platform === "ANDROID_APP" && webToNative.logoutWithFacebook();
56
+
57
+ if (platform === "IOS_APP" && webToNativeIos) {
58
+ webToNativeIos.postMessage({
59
+ action: "fbSignOut",
60
+ scope,
61
+ } as FacebookIosMessage);
62
+ }
63
+ }
64
+ };