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.
- package/.editorconfig +10 -0
- package/.prettierrc.json +7 -0
- package/README.md +31 -2
- package/build/ATTConsent/index.d.ts +17 -0
- package/build/ATTConsent/index.d.ts.map +1 -0
- package/build/ATTConsent/index.js +54 -0
- package/build/ATTConsent/index.js.map +1 -0
- package/build/ATTConsent/types.d.ts +15 -0
- package/build/ATTConsent/types.d.ts.map +1 -0
- package/build/ATTConsent/types.js +3 -0
- package/build/ATTConsent/types.js.map +1 -0
- package/build/AdMob/index.d.ts +31 -0
- package/build/AdMob/index.d.ts.map +1 -0
- package/build/AdMob/index.js +102 -0
- package/build/AdMob/index.js.map +1 -0
- package/build/AdMob/types.d.ts +25 -0
- package/build/AdMob/types.d.ts.map +1 -0
- package/build/AdMob/types.js +4 -0
- package/build/AdMob/types.js.map +1 -0
- package/build/AppReview/index.d.ts +7 -0
- package/build/AppReview/index.d.ts.map +1 -0
- package/build/AppReview/index.js +22 -0
- package/build/AppReview/index.js.map +1 -0
- package/build/AppReview/types.d.ts +8 -0
- package/build/AppReview/types.d.ts.map +1 -0
- package/build/AppReview/types.js +4 -0
- package/build/AppReview/types.js.map +1 -0
- package/build/AppsFlyer/index.d.ts +15 -0
- package/build/AppsFlyer/index.d.ts.map +1 -0
- package/build/AppsFlyer/index.js +43 -0
- package/build/AppsFlyer/index.js.map +1 -0
- package/build/AppsFlyer/types.d.ts +10 -0
- package/build/AppsFlyer/types.d.ts.map +1 -0
- package/build/AppsFlyer/types.js +3 -0
- package/build/AppsFlyer/types.js.map +1 -0
- package/build/BackgroundLocation/index.d.ts +12 -0
- package/build/BackgroundLocation/index.d.ts.map +1 -0
- package/build/BackgroundLocation/index.js +65 -0
- package/build/BackgroundLocation/index.js.map +1 -0
- package/build/BackgroundLocation/types.d.ts +32 -0
- package/build/BackgroundLocation/types.d.ts.map +1 -0
- package/build/BackgroundLocation/types.js +3 -0
- package/build/BackgroundLocation/types.js.map +1 -0
- package/build/Beacon/index.d.ts +7 -0
- package/build/Beacon/index.d.ts.map +1 -0
- package/build/Beacon/index.js +30 -0
- package/build/Beacon/index.js.map +1 -0
- package/build/Beacon/types.d.ts +19 -0
- package/build/Beacon/types.d.ts.map +1 -0
- package/build/Beacon/types.js +3 -0
- package/build/Beacon/types.js.map +1 -0
- package/build/Biometric/index.d.ts +27 -0
- package/build/Biometric/index.d.ts.map +1 -0
- package/build/Biometric/index.js +125 -0
- package/build/Biometric/index.js.map +1 -0
- package/build/Biometric/types.d.ts +24 -0
- package/build/Biometric/types.d.ts.map +1 -0
- package/build/Biometric/types.js +3 -0
- package/build/Biometric/types.js.map +1 -0
- package/build/Bluetooth/index.d.ts +17 -0
- package/build/Bluetooth/index.d.ts.map +1 -0
- package/build/Bluetooth/index.js +67 -0
- package/build/Bluetooth/index.js.map +1 -0
- package/build/Bluetooth/types.d.ts +34 -0
- package/build/Bluetooth/types.d.ts.map +1 -0
- package/build/Bluetooth/types.js +3 -0
- package/build/Bluetooth/types.js.map +1 -0
- package/build/BottomNavigation/index.d.ts +11 -0
- package/build/BottomNavigation/index.d.ts.map +1 -0
- package/build/BottomNavigation/index.js +41 -0
- package/build/BottomNavigation/index.js.map +1 -0
- package/build/BottomNavigation/types.d.ts +9 -0
- package/build/BottomNavigation/types.d.ts.map +1 -0
- package/build/BottomNavigation/types.js +3 -0
- package/build/BottomNavigation/types.js.map +1 -0
- package/build/Clipboard/index.d.ts +12 -0
- package/build/Clipboard/index.d.ts.map +1 -0
- package/build/Clipboard/index.js +45 -0
- package/build/Clipboard/index.js.map +1 -0
- package/build/Clipboard/types.d.ts +20 -0
- package/build/Clipboard/types.d.ts.map +1 -0
- package/build/Clipboard/types.js +4 -0
- package/build/Clipboard/types.js.map +1 -0
- package/build/Facebook/events.d.ts +13 -0
- package/build/Facebook/events.d.ts.map +1 -0
- package/build/Facebook/events.js +44 -0
- package/build/Facebook/events.js.map +1 -0
- package/build/Facebook/index.d.ts +3 -0
- package/build/Facebook/index.d.ts.map +1 -0
- package/build/Facebook/index.js +29 -0
- package/build/Facebook/index.js.map +1 -0
- package/build/Facebook/types.d.ts +22 -0
- package/build/Facebook/types.d.ts.map +1 -0
- package/build/Facebook/types.js +3 -0
- package/build/Facebook/types.js.map +1 -0
- package/build/Firebase/Analytics/index.d.ts +32 -0
- package/build/Firebase/Analytics/index.d.ts.map +1 -0
- package/build/Firebase/Analytics/index.js +110 -0
- package/build/Firebase/Analytics/index.js.map +1 -0
- package/build/Firebase/Messaging/index.d.ts +17 -0
- package/build/Firebase/Messaging/index.d.ts.map +1 -0
- package/build/Firebase/Messaging/index.js +64 -0
- package/build/Firebase/Messaging/index.js.map +1 -0
- package/build/Firebase/index.d.ts +4 -0
- package/build/Firebase/index.d.ts.map +1 -0
- package/build/Firebase/index.js +31 -0
- package/build/Firebase/index.js.map +1 -0
- package/build/Firebase/types.d.ts +58 -0
- package/build/Firebase/types.d.ts.map +1 -0
- package/build/Firebase/types.js +4 -0
- package/build/Firebase/types.js.map +1 -0
- package/build/FirebaseAnalytics/index.d.ts +3 -0
- package/build/FirebaseAnalytics/index.d.ts.map +1 -0
- package/build/FirebaseAnalytics/index.js +29 -0
- package/build/FirebaseAnalytics/index.js.map +1 -0
- package/build/Haptics/index.d.ts +7 -0
- package/build/Haptics/index.d.ts.map +1 -0
- package/build/Haptics/index.js +21 -0
- package/build/Haptics/index.js.map +1 -0
- package/build/Haptics/types.d.ts +8 -0
- package/build/Haptics/types.d.ts.map +1 -0
- package/build/Haptics/types.js +3 -0
- package/build/Haptics/types.js.map +1 -0
- package/build/InAppPurchase/index.d.ts +23 -0
- package/build/InAppPurchase/index.d.ts.map +1 -0
- package/build/InAppPurchase/index.js +81 -0
- package/build/InAppPurchase/index.js.map +1 -0
- package/build/InAppPurchase/types.d.ts +30 -0
- package/build/InAppPurchase/types.d.ts.map +1 -0
- package/build/InAppPurchase/types.js +3 -0
- package/build/InAppPurchase/types.js.map +1 -0
- package/build/InAppUpdate/index.d.ts +12 -0
- package/build/InAppUpdate/index.d.ts.map +1 -0
- package/build/InAppUpdate/index.js +39 -0
- package/build/InAppUpdate/index.js.map +1 -0
- package/build/InAppUpdate/types.d.ts +15 -0
- package/build/InAppUpdate/types.d.ts.map +1 -0
- package/build/InAppUpdate/types.js +3 -0
- package/build/InAppUpdate/types.js.map +1 -0
- package/build/MediaPlayer/index.d.ts +17 -0
- package/build/MediaPlayer/index.d.ts.map +1 -0
- package/build/MediaPlayer/index.js +56 -0
- package/build/MediaPlayer/index.js.map +1 -0
- package/build/MediaPlayer/types.d.ts +14 -0
- package/build/MediaPlayer/types.d.ts.map +1 -0
- package/build/MediaPlayer/types.js +3 -0
- package/build/MediaPlayer/types.js.map +1 -0
- package/build/NativeContacts/index.d.ts +12 -0
- package/build/NativeContacts/index.d.ts.map +1 -0
- package/build/NativeContacts/index.js +51 -0
- package/build/NativeContacts/index.js.map +1 -0
- package/build/NativeContacts/types.d.ts +14 -0
- package/build/NativeContacts/types.d.ts.map +1 -0
- package/build/NativeContacts/types.js +3 -0
- package/build/NativeContacts/types.js.map +1 -0
- package/build/Notification/index.d.ts +11 -0
- package/build/Notification/index.d.ts.map +1 -0
- package/build/Notification/index.js +42 -0
- package/build/Notification/index.js.map +1 -0
- package/build/Notification/types.d.ts +14 -0
- package/build/Notification/types.d.ts.map +1 -0
- package/build/Notification/types.js +3 -0
- package/build/Notification/types.js.map +1 -0
- package/build/OneSignal/index.d.ts +4 -0
- package/build/OneSignal/index.d.ts.map +1 -0
- package/build/OneSignal/index.js +59 -0
- package/build/OneSignal/index.js.map +1 -0
- package/build/OneSignal/types.d.ts +11 -0
- package/build/OneSignal/types.d.ts.map +1 -0
- package/build/OneSignal/types.js +4 -0
- package/build/OneSignal/types.js.map +1 -0
- package/build/Printing/index.d.ts +7 -0
- package/build/Printing/index.d.ts.map +1 -0
- package/build/Printing/index.js +20 -0
- package/build/Printing/index.js.map +1 -0
- package/build/Printing/types.d.ts +9 -0
- package/build/Printing/types.d.ts.map +1 -0
- package/build/Printing/types.js +3 -0
- package/build/Printing/types.js.map +1 -0
- package/build/README.md +33 -0
- package/build/Screen/index.d.ts +9 -0
- package/build/Screen/index.d.ts.map +1 -0
- package/build/Screen/index.js +35 -0
- package/build/Screen/index.js.map +1 -0
- package/build/Screen/types.d.ts +6 -0
- package/build/Screen/types.d.ts.map +1 -0
- package/build/Screen/types.js +4 -0
- package/build/Screen/types.js.map +1 -0
- package/build/Siri/index.d.ts +7 -0
- package/build/Siri/index.d.ts.map +1 -0
- package/build/Siri/index.js +26 -0
- package/build/Siri/index.js.map +1 -0
- package/build/Siri/types.d.ts +14 -0
- package/build/Siri/types.d.ts.map +1 -0
- package/build/Siri/types.js +3 -0
- package/build/Siri/types.js.map +1 -0
- package/build/SocialLogin/apple.d.ts +12 -0
- package/build/SocialLogin/apple.d.ts.map +1 -0
- package/build/SocialLogin/apple.js +32 -0
- package/build/SocialLogin/apple.js.map +1 -0
- package/build/SocialLogin/facebook.d.ts +22 -0
- package/build/SocialLogin/facebook.d.ts.map +1 -0
- package/build/SocialLogin/facebook.js +61 -0
- package/build/SocialLogin/facebook.js.map +1 -0
- package/build/SocialLogin/google.d.ts +22 -0
- package/build/SocialLogin/google.d.ts.map +1 -0
- package/build/SocialLogin/google.js +61 -0
- package/build/SocialLogin/google.js.map +1 -0
- package/build/SocialLogin/index.d.ts +17 -0
- package/build/SocialLogin/index.d.ts.map +1 -0
- package/build/SocialLogin/index.js +23 -0
- package/build/SocialLogin/index.js.map +1 -0
- package/build/SocialLogin/types.d.ts +39 -0
- package/build/SocialLogin/types.d.ts.map +1 -0
- package/build/SocialLogin/types.js +3 -0
- package/build/SocialLogin/types.js.map +1 -0
- package/build/Stripe/index.d.ts +3 -0
- package/build/Stripe/index.d.ts.map +1 -0
- package/build/Stripe/index.js +49 -0
- package/build/Stripe/index.js.map +1 -0
- package/build/Stripe/types.d.ts +32 -0
- package/build/Stripe/types.d.ts.map +1 -0
- package/build/Stripe/types.js +3 -0
- package/build/Stripe/types.js.map +1 -0
- package/build/VoiceSearch/index.d.ts +13 -0
- package/build/VoiceSearch/index.d.ts.map +1 -0
- package/build/VoiceSearch/index.js +34 -0
- package/build/VoiceSearch/index.js.map +1 -0
- package/build/VoiceSearch/types.d.ts +10 -0
- package/build/VoiceSearch/types.d.ts.map +1 -0
- package/build/VoiceSearch/types.js +3 -0
- package/build/VoiceSearch/types.js.map +1 -0
- package/build/barcode/barcode-scan.d.ts +16 -0
- package/build/barcode/barcode-scan.d.ts.map +1 -0
- package/build/barcode/barcode-scan.js +40 -0
- package/build/barcode/barcode-scan.js.map +1 -0
- package/build/barcode/barcode-types.d.ts +18 -0
- package/build/barcode/barcode-types.d.ts.map +1 -0
- package/build/barcode/barcode-types.js +3 -0
- package/build/barcode/barcode-types.js.map +1 -0
- package/build/barcode/formats.d.ts +18 -0
- package/build/barcode/formats.d.ts.map +1 -0
- package/build/barcode/formats.js +23 -0
- package/build/barcode/formats.js.map +1 -0
- package/build/barcode/index.d.ts +5 -0
- package/build/barcode/index.d.ts.map +1 -0
- package/build/barcode/index.js +13 -0
- package/build/barcode/index.js.map +1 -0
- package/build/barcode/types.d.ts +17 -0
- package/build/barcode/types.d.ts.map +1 -0
- package/build/barcode/types.js +22 -0
- package/build/barcode/types.js.map +1 -0
- package/build/index.d.ts +15 -0
- package/build/index.d.ts.map +1 -0
- package/build/index.js +110 -0
- package/build/index.js.map +1 -0
- package/build/package.json +155 -0
- package/build/types/index.d.ts +49 -0
- package/build/types/index.d.ts.map +1 -0
- package/build/types/index.js +4 -0
- package/build/types/index.js.map +1 -0
- package/build/utills.d.ts +12 -0
- package/build/utills.d.ts.map +1 -0
- package/build/utills.js +111 -0
- package/build/utills.js.map +1 -0
- package/build/webtonative.min.js +1 -0
- package/buildScript.ts +35 -0
- package/client.ts +106 -0
- package/index.d.ts +65 -0
- package/package.json +36 -31
- package/src/ATTConsent/index.ts +51 -0
- package/src/ATTConsent/types.ts +17 -0
- package/src/AdMob/index.ts +113 -0
- package/src/AdMob/types.ts +37 -0
- package/src/AppReview/index.ts +19 -0
- package/src/AppReview/types.ts +12 -0
- package/src/AppsFlyer/index.ts +46 -0
- package/src/AppsFlyer/types.ts +10 -0
- package/src/BackgroundLocation/index.ts +78 -0
- package/src/BackgroundLocation/types.ts +34 -0
- package/src/Beacon/index.ts +28 -0
- package/src/Beacon/types.ts +22 -0
- package/src/Biometric/index.ts +126 -0
- package/src/Biometric/types.ts +27 -0
- package/src/Bluetooth/index.ts +71 -0
- package/src/Bluetooth/types.ts +40 -0
- package/src/BottomNavigation/index.ts +39 -0
- package/src/BottomNavigation/types.ts +9 -0
- package/src/Clipboard/index.ts +48 -0
- package/src/Clipboard/types.ts +30 -0
- package/src/Facebook/events.ts +45 -0
- package/src/Facebook/index.ts +3 -0
- package/src/Facebook/types.ts +24 -0
- package/src/Firebase/Analytics/index.ts +127 -0
- package/src/Firebase/Messaging/index.ts +73 -0
- package/src/Firebase/index.ts +4 -0
- package/src/Firebase/types.ts +74 -0
- package/src/FirebaseAnalytics/index.ts +3 -0
- package/src/Haptics/index.ts +17 -0
- package/src/Haptics/types.ts +8 -0
- package/src/InAppPurchase/index.ts +92 -0
- package/src/InAppPurchase/types.ts +35 -0
- package/src/InAppUpdate/index.ts +40 -0
- package/src/InAppUpdate/types.ts +17 -0
- package/src/MediaPlayer/index.ts +56 -0
- package/src/MediaPlayer/types.ts +15 -0
- package/src/NativeContacts/index.ts +50 -0
- package/src/NativeContacts/types.ts +16 -0
- package/src/Notification/index.ts +41 -0
- package/src/Notification/types.ts +16 -0
- package/src/OneSignal/index.ts +54 -0
- package/src/OneSignal/types.ts +15 -0
- package/src/Printing/index.ts +17 -0
- package/src/Printing/types.ts +9 -0
- package/src/Screen/index.ts +34 -0
- package/src/Screen/types.ts +8 -0
- package/src/Siri/index.ts +23 -0
- package/src/Siri/types.ts +14 -0
- package/src/SocialLogin/apple.ts +31 -0
- package/src/SocialLogin/facebook.ts +64 -0
- package/src/SocialLogin/google.ts +64 -0
- package/src/SocialLogin/index.ts +20 -0
- package/src/SocialLogin/types.ts +52 -0
- package/src/Stripe/index.ts +54 -0
- package/src/Stripe/types.ts +37 -0
- package/src/VoiceSearch/index.ts +37 -0
- package/src/VoiceSearch/types.ts +12 -0
- package/src/barcode/barcode-scan.ts +59 -0
- package/src/barcode/barcode-types.ts +22 -0
- package/src/barcode/formats.ts +19 -0
- package/src/barcode/index.ts +5 -0
- package/src/barcode/types.ts +18 -0
- package/src/index.ts +105 -0
- package/src/types/index.ts +71 -0
- package/src/utills.ts +110 -0
- package/tsconfig.json +27 -0
- package/webpack.config.js +57 -0
- package/ATTConsent/index.js +0 -1
- package/AdMob/index.js +0 -1
- package/AppReview/index.js +0 -1
- package/AppsFlyer/index.js +0 -4
- package/BackgroundLocation/index.js +0 -4
- package/Beacon/index.js +0 -1
- package/Biometric/index.js +0 -1
- package/Bluetooth/index.js +0 -1
- package/BottomNavigation/index.js +0 -4
- package/Clipboard/index.js +0 -4
- package/Facebook/events.js +0 -4
- package/Facebook/index.js +0 -1
- package/Firebase/Analytics/index.js +0 -4
- package/Firebase/Messaging/index.js +0 -4
- package/Firebase/index.js +0 -1
- package/FirebaseAnalytics/index.js +0 -1
- package/Haptics/index.js +0 -1
- package/InAppPurchase/index.js +0 -1
- package/InAppUpdate/index.js +0 -1
- package/MediaPlayer/index.js +0 -7
- package/NativeContacts/index.js +0 -6
- package/Notification/index.js +0 -5
- package/OneSignal/index.js +0 -1
- package/Printing/index.js +0 -1
- package/Screen/index.js +0 -4
- package/Siri/index.js +0 -1
- package/SocialLogin/apple.js +0 -1
- package/SocialLogin/facebook.js +0 -9
- package/SocialLogin/google.js +0 -9
- package/SocialLogin/index.js +0 -1
- package/Stripe/index.js +0 -1
- package/VoiceSearch/index.js +0 -1
- package/barcode/barcode-scan.js +0 -1
- package/barcode/formats.js +0 -1
- package/barcode/index.js +0 -1
- package/barcode/types.js +0 -1
- package/index.js +0 -4
- package/utills.js +0 -1
- 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,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,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,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
|
+
};
|