@juspay-tech/react-native-hyperswitch 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/HyperswitchSdkReactNative.podspec +31 -0
- package/android/build.gradle +119 -0
- package/android/gradle.properties +5 -0
- package/android/hyperswitch_autolinking.gradle +378 -0
- package/android/proguard-rules.pro +72 -0
- package/android/src/main/AndroidManifest.xml +25 -0
- package/android/src/main/assets/hyperswitch.bundle +1677 -0
- package/android/src/main/java/com/hyperswitchsdkreactnative/HyperswitchSdkReactNativePackage.kt +36 -0
- package/android/src/main/java/com/hyperswitchsdkreactnative/activity/RedirectActivity.kt +39 -0
- package/android/src/main/java/com/hyperswitchsdkreactnative/internal/DefaultReactHost.kt +314 -0
- package/android/src/main/java/com/hyperswitchsdkreactnative/internal/DefaultReactNativeHost.kt +131 -0
- package/android/src/main/java/com/hyperswitchsdkreactnative/internal/ReactDelegate.kt +423 -0
- package/android/src/main/java/com/hyperswitchsdkreactnative/internal/ReactFragment.kt +335 -0
- package/android/src/main/java/com/hyperswitchsdkreactnative/modules/HyperswitchSdkNativeModule.kt +143 -0
- package/android/src/main/java/com/hyperswitchsdkreactnative/modules/HyperswitchSdkReactNativeModule.kt +92 -0
- package/android/src/main/java/com/hyperswitchsdkreactnative/provider/HyperProvider.kt +269 -0
- package/android/src/main/java/com/hyperswitchsdkreactnative/views/GooglePayButtonView.kt +60 -0
- package/android/src/main/java/com/hyperswitchsdkreactnative/views/GooglePayButtonViewManager.kt +76 -0
- package/android/src/main/java/io/hyperswitch/hyperota/HyperOtaLogger.kt +122 -0
- package/android/src/main/java/io/hyperswitch/logs/CrashHandler.kt +29 -0
- package/android/src/main/java/io/hyperswitch/logs/Debouncer.kt +20 -0
- package/android/src/main/java/io/hyperswitch/logs/HyperLogManager.kt +113 -0
- package/android/src/main/java/io/hyperswitch/logs/LogData.kt +159 -0
- package/android/src/main/java/io/hyperswitch/logs/LogFileManager.kt +60 -0
- package/android/src/main/java/io/hyperswitch/networking/HyperNetworking.kt +73 -0
- package/android/src/main/java/io/hyperswitch/react/Utils.kt +23 -0
- package/android/src/main/res/values/attrs.xml +6 -0
- package/android/src/main/res/values/strings.xml +5 -0
- package/android/src/main/res/values/theme.xml +16 -0
- package/ios/Modules/HyperswitchModule.swift +61 -0
- package/ios/Modules/HyperswitchNativeModule.swift +113 -0
- package/ios/Modules/HyperswitchSdkNative.h +5 -0
- package/ios/Modules/HyperswitchSdkNative.mm +98 -0
- package/ios/Modules/HyperswitchSdkReactNative.h +5 -0
- package/ios/Modules/HyperswitchSdkReactNative.mm +53 -0
- package/ios/Views/ApplePayView.h +14 -0
- package/ios/Views/ApplePayView.mm +89 -0
- package/ios/hyperswitchSDK/Core/ApplePay/ApplePayHandler.swift +249 -0
- package/ios/hyperswitchSDK/Core/ApplePay/ApplePayViewManager.m +18 -0
- package/ios/hyperswitchSDK/Core/ApplePay/ApplePayViewManager.swift +123 -0
- package/ios/hyperswitchSDK/Core/HyperPaymentSheet/PaymentSheetView+SwiftUI.swift +49 -0
- package/ios/hyperswitchSDK/Core/HyperPaymentSheet/PaymentSheetView+UIKit.swift +49 -0
- package/ios/hyperswitchSDK/Core/HyperPaymentSheet/PaymentSheetView.swift +80 -0
- package/ios/hyperswitchSDK/Core/HyperSession/PaymentSession+UIKit.swift +176 -0
- package/ios/hyperswitchSDK/Core/HyperSession/PaymentSessionTypes.swift +121 -0
- package/ios/hyperswitchSDK/Core/Models/LogPayload.swift +53 -0
- package/ios/hyperswitchSDK/Core/NativeLogger/Debouncer.swift +37 -0
- package/ios/hyperswitchSDK/Core/NativeLogger/LogBuilder.swift +91 -0
- package/ios/hyperswitchSDK/Core/NativeLogger/LogFileManager.swift +75 -0
- package/ios/hyperswitchSDK/Core/NativeLogger/LogManager.swift +113 -0
- package/ios/hyperswitchSDK/Core/NativeModule/HyperHeadless.m +16 -0
- package/ios/hyperswitchSDK/Core/NativeModule/HyperHeadless.swift +74 -0
- package/ios/hyperswitchSDK/Core/NativeModule/HyperModule.m +28 -0
- package/ios/hyperswitchSDK/Core/NativeModule/HyperModule.swift +168 -0
- package/ios/hyperswitchSDK/Core/NativeModule/OTAServices.swift +113 -0
- package/ios/hyperswitchSDK/Core/NativeModule/RNHeadlessManager.swift +45 -0
- package/ios/hyperswitchSDK/Core/NativeModule/RNResponseHandler.swift +12 -0
- package/ios/hyperswitchSDK/Core/NativeModule/RNViewManager.swift +90 -0
- package/ios/hyperswitchSDK/Core/NativeModule/hyper-Bridging-Header.h +9 -0
- package/ios/hyperswitchSDK/Core/Resources/HyperOTA.plist +20 -0
- package/ios/hyperswitchSDK/Core/Resources/hyperswitch.bundle +1673 -0
- package/ios/hyperswitchSDK/Shared/APIClient.swift +21 -0
- package/ios/hyperswitchSDK/Shared/DictionaryConverter.swift +104 -0
- package/ios/hyperswitchSDK/Shared/Environment.swift +24 -0
- package/ios/hyperswitchSDK/Shared/Extensions.swift +31 -0
- package/ios/hyperswitchSDK/Shared/Helper.swift +16 -0
- package/ios/hyperswitchSDK/Shared/HyperNetworking.swift +137 -0
- package/ios/hyperswitchSDK/Shared/HyperParams.swift +44 -0
- package/ios/hyperswitchSDK/Shared/HyperUIViewController.swift +25 -0
- package/ios/hyperswitchSDK/Shared/PaymentSession.swift +43 -0
- package/ios/hyperswitchSDK/Shared/PaymentSheet.swift +30 -0
- package/ios/hyperswitchSDK/Shared/PaymentSheetAppearance.swift +264 -0
- package/ios/hyperswitchSDK/Shared/PaymentSheetConfiguration.swift +494 -0
- package/ios/hyperswitchSDK/Shared/SwiftUIManager.swift +28 -0
- package/ios/hyperswitchSDK/Shared/Version.swift +12 -0
- package/lib/bs/JuspayTechReactNativeHyperswitch.cmi +0 -0
- package/lib/bs/JuspayTechReactNativeHyperswitch.cmj +0 -0
- package/lib/bs/JuspayTechReactNativeHyperswitch.cmt +0 -0
- package/lib/bs/JuspayTechReactNativeHyperswitch.mlmap +5 -0
- package/lib/bs/build.ninja +29 -0
- package/lib/bs/install.ninja +25 -0
- package/lib/bs/src/context/HyperProvider-JuspayTechReactNativeHyperswitch.cmi +0 -0
- package/lib/bs/src/context/HyperProvider-JuspayTechReactNativeHyperswitch.cmj +0 -0
- package/lib/bs/src/context/HyperProvider-JuspayTechReactNativeHyperswitch.cmt +0 -0
- package/lib/bs/src/context/HyperProvider.ast +0 -0
- package/lib/bs/src/context/HyperProvider.d +1 -0
- package/lib/bs/src/hooks/useHyper-JuspayTechReactNativeHyperswitch.cmi +0 -0
- package/lib/bs/src/hooks/useHyper-JuspayTechReactNativeHyperswitch.cmj +0 -0
- package/lib/bs/src/hooks/useHyper-JuspayTechReactNativeHyperswitch.cmt +0 -0
- package/lib/bs/src/hooks/useHyper.ast +0 -0
- package/lib/bs/src/hooks/useHyper.d +1 -0
- package/lib/bs/src/modules/NativeHyperswitchSdk-JuspayTechReactNativeHyperswitch.cmi +0 -0
- package/lib/bs/src/modules/NativeHyperswitchSdk-JuspayTechReactNativeHyperswitch.cmj +0 -0
- package/lib/bs/src/modules/NativeHyperswitchSdk-JuspayTechReactNativeHyperswitch.cmt +0 -0
- package/lib/bs/src/modules/NativeHyperswitchSdk.ast +0 -0
- package/lib/bs/src/modules/NativeHyperswitchSdk.d +1 -0
- package/lib/bs/src/types/PaymentSheetConfiguration-JuspayTechReactNativeHyperswitch.cmi +0 -0
- package/lib/bs/src/types/PaymentSheetConfiguration-JuspayTechReactNativeHyperswitch.cmj +0 -0
- package/lib/bs/src/types/PaymentSheetConfiguration-JuspayTechReactNativeHyperswitch.cmt +0 -0
- package/lib/bs/src/types/PaymentSheetConfiguration.ast +0 -0
- package/lib/bs/src/types/PaymentSheetConfiguration.d +1 -0
- package/lib/commonjs/context/HyperProvider.gen.js +16 -0
- package/lib/commonjs/context/HyperProvider.gen.js.map +1 -0
- package/lib/commonjs/context/HyperProvider.res +78 -0
- package/lib/commonjs/context/HyperProvider.res.js +98 -0
- package/lib/commonjs/context/HyperProvider.res.js.map +1 -0
- package/lib/commonjs/hooks/useHyper.gen.js +15 -0
- package/lib/commonjs/hooks/useHyper.gen.js.map +1 -0
- package/lib/commonjs/hooks/useHyper.res +142 -0
- package/lib/commonjs/hooks/useHyper.res.js +152 -0
- package/lib/commonjs/hooks/useHyper.res.js.map +1 -0
- package/lib/commonjs/index.js +26 -0
- package/lib/commonjs/index.js.map +1 -0
- package/lib/commonjs/modules/NativeHyperswitchSdk.gen.js +6 -0
- package/lib/commonjs/modules/NativeHyperswitchSdk.gen.js.map +1 -0
- package/lib/commonjs/modules/NativeHyperswitchSdk.res +55 -0
- package/lib/commonjs/modules/NativeHyperswitchSdk.res.js +14 -0
- package/lib/commonjs/modules/NativeHyperswitchSdk.res.js.map +1 -0
- package/lib/commonjs/package.json +1 -0
- package/lib/commonjs/shims/Js.shim.js +2 -0
- package/lib/commonjs/shims/Js.shim.js.map +1 -0
- package/lib/commonjs/specs/ApplePayButtonNativeComponent.ts +11 -0
- package/lib/commonjs/specs/GooglePayButtonNativeComponent.android.js +10 -0
- package/lib/commonjs/specs/GooglePayButtonNativeComponent.android.js.map +1 -0
- package/lib/commonjs/specs/HyperswitchSdkReactNativeViewNativeComponent.ts +10 -0
- package/lib/commonjs/specs/NativeHyperswitchSdkNative.js +9 -0
- package/lib/commonjs/specs/NativeHyperswitchSdkNative.js.map +1 -0
- package/lib/commonjs/specs/NativeHyperswitchSdkReactNative.js +9 -0
- package/lib/commonjs/specs/NativeHyperswitchSdkReactNative.js.map +1 -0
- package/lib/commonjs/types/PaymentSheetConfiguration.gen.js +2 -0
- package/lib/commonjs/types/PaymentSheetConfiguration.gen.js.map +1 -0
- package/lib/commonjs/types/PaymentSheetConfiguration.res +215 -0
- package/lib/commonjs/types/PaymentSheetConfiguration.res.js +4 -0
- package/lib/commonjs/types/PaymentSheetConfiguration.res.js.map +1 -0
- package/lib/module/context/HyperProvider.gen.js +11 -0
- package/lib/module/context/HyperProvider.gen.js.map +1 -0
- package/lib/module/context/HyperProvider.res +78 -0
- package/lib/module/context/HyperProvider.res.js +91 -0
- package/lib/module/context/HyperProvider.res.js.map +1 -0
- package/lib/module/hooks/useHyper.gen.js +10 -0
- package/lib/module/hooks/useHyper.gen.js.map +1 -0
- package/lib/module/hooks/useHyper.res +142 -0
- package/lib/module/hooks/useHyper.res.js +142 -0
- package/lib/module/hooks/useHyper.res.js.map +1 -0
- package/lib/module/index.js +5 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/modules/NativeHyperswitchSdk.gen.js +4 -0
- package/lib/module/modules/NativeHyperswitchSdk.gen.js.map +1 -0
- package/lib/module/modules/NativeHyperswitchSdk.res +55 -0
- package/lib/module/modules/NativeHyperswitchSdk.res.js +9 -0
- package/lib/module/modules/NativeHyperswitchSdk.res.js.map +1 -0
- package/lib/module/package.json +1 -0
- package/lib/module/shims/Js.shim.js +2 -0
- package/lib/module/shims/Js.shim.js.map +1 -0
- package/lib/module/specs/ApplePayButtonNativeComponent.ts +11 -0
- package/lib/module/specs/GooglePayButtonNativeComponent.android.js +5 -0
- package/lib/module/specs/GooglePayButtonNativeComponent.android.js.map +1 -0
- package/lib/module/specs/HyperswitchSdkReactNativeViewNativeComponent.ts +10 -0
- package/lib/module/specs/NativeHyperswitchSdkNative.js +5 -0
- package/lib/module/specs/NativeHyperswitchSdkNative.js.map +1 -0
- package/lib/module/specs/NativeHyperswitchSdkReactNative.js +5 -0
- package/lib/module/specs/NativeHyperswitchSdkReactNative.js.map +1 -0
- package/lib/module/types/PaymentSheetConfiguration.gen.js +2 -0
- package/lib/module/types/PaymentSheetConfiguration.gen.js.map +1 -0
- package/lib/module/types/PaymentSheetConfiguration.res +215 -0
- package/lib/module/types/PaymentSheetConfiguration.res.js +4 -0
- package/lib/module/types/PaymentSheetConfiguration.res.js.map +1 -0
- package/lib/typescript/commonjs/babel.config.d.ts +10 -0
- package/lib/typescript/commonjs/babel.config.d.ts.map +1 -0
- package/lib/typescript/commonjs/eslint.config.d.mts +3 -0
- package/lib/typescript/commonjs/eslint.config.d.mts.map +1 -0
- package/lib/typescript/commonjs/package.json +1 -0
- package/lib/typescript/commonjs/scripts/bootstrap.d.ts +2 -0
- package/lib/typescript/commonjs/scripts/bootstrap.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/context/HyperProvider.gen.d.ts +17 -0
- package/lib/typescript/commonjs/src/context/HyperProvider.gen.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/context/HyperProvider.res.d.ts +20 -0
- package/lib/typescript/commonjs/src/context/HyperProvider.res.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/hooks/useHyper.gen.d.ts +10 -0
- package/lib/typescript/commonjs/src/hooks/useHyper.gen.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/hooks/useHyper.res.d.ts +95 -0
- package/lib/typescript/commonjs/src/hooks/useHyper.res.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/index.d.ts +4 -0
- package/lib/typescript/commonjs/src/index.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/modules/NativeHyperswitchSdk.gen.d.ts +24 -0
- package/lib/typescript/commonjs/src/modules/NativeHyperswitchSdk.gen.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/modules/NativeHyperswitchSdk.res.d.ts +2 -0
- package/lib/typescript/commonjs/src/modules/NativeHyperswitchSdk.res.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/shims/Js.shim.d.ts +4 -0
- package/lib/typescript/commonjs/src/shims/Js.shim.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/specs/ApplePayButtonNativeComponent.d.ts +10 -0
- package/lib/typescript/commonjs/src/specs/ApplePayButtonNativeComponent.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/specs/GooglePayButtonNativeComponent.android.d.ts +11 -0
- package/lib/typescript/commonjs/src/specs/GooglePayButtonNativeComponent.android.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/specs/HyperswitchSdkReactNativeViewNativeComponent.d.ts +1 -0
- package/lib/typescript/commonjs/src/specs/HyperswitchSdkReactNativeViewNativeComponent.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/specs/NativeHyperswitchSdkNative.d.ts +17 -0
- package/lib/typescript/commonjs/src/specs/NativeHyperswitchSdkNative.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/specs/NativeHyperswitchSdkReactNative.d.ts +9 -0
- package/lib/typescript/commonjs/src/specs/NativeHyperswitchSdkReactNative.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/types/PaymentSheetConfiguration.gen.d.ts +149 -0
- package/lib/typescript/commonjs/src/types/PaymentSheetConfiguration.gen.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/types/PaymentSheetConfiguration.res.d.ts +1 -0
- package/lib/typescript/commonjs/src/types/PaymentSheetConfiguration.res.d.ts.map +1 -0
- package/lib/typescript/module/babel.config.d.ts +10 -0
- package/lib/typescript/module/babel.config.d.ts.map +1 -0
- package/lib/typescript/module/eslint.config.d.mts +3 -0
- package/lib/typescript/module/eslint.config.d.mts.map +1 -0
- package/lib/typescript/module/package.json +1 -0
- package/lib/typescript/module/scripts/bootstrap.d.ts +2 -0
- package/lib/typescript/module/scripts/bootstrap.d.ts.map +1 -0
- package/lib/typescript/module/src/context/HyperProvider.gen.d.ts +17 -0
- package/lib/typescript/module/src/context/HyperProvider.gen.d.ts.map +1 -0
- package/lib/typescript/module/src/context/HyperProvider.res.d.ts +20 -0
- package/lib/typescript/module/src/context/HyperProvider.res.d.ts.map +1 -0
- package/lib/typescript/module/src/hooks/useHyper.gen.d.ts +10 -0
- package/lib/typescript/module/src/hooks/useHyper.gen.d.ts.map +1 -0
- package/lib/typescript/module/src/hooks/useHyper.res.d.ts +95 -0
- package/lib/typescript/module/src/hooks/useHyper.res.d.ts.map +1 -0
- package/lib/typescript/module/src/index.d.ts +4 -0
- package/lib/typescript/module/src/index.d.ts.map +1 -0
- package/lib/typescript/module/src/modules/NativeHyperswitchSdk.gen.d.ts +24 -0
- package/lib/typescript/module/src/modules/NativeHyperswitchSdk.gen.d.ts.map +1 -0
- package/lib/typescript/module/src/modules/NativeHyperswitchSdk.res.d.ts +2 -0
- package/lib/typescript/module/src/modules/NativeHyperswitchSdk.res.d.ts.map +1 -0
- package/lib/typescript/module/src/shims/Js.shim.d.ts +4 -0
- package/lib/typescript/module/src/shims/Js.shim.d.ts.map +1 -0
- package/lib/typescript/module/src/specs/ApplePayButtonNativeComponent.d.ts +10 -0
- package/lib/typescript/module/src/specs/ApplePayButtonNativeComponent.d.ts.map +1 -0
- package/lib/typescript/module/src/specs/GooglePayButtonNativeComponent.android.d.ts +11 -0
- package/lib/typescript/module/src/specs/GooglePayButtonNativeComponent.android.d.ts.map +1 -0
- package/lib/typescript/module/src/specs/HyperswitchSdkReactNativeViewNativeComponent.d.ts +1 -0
- package/lib/typescript/module/src/specs/HyperswitchSdkReactNativeViewNativeComponent.d.ts.map +1 -0
- package/lib/typescript/module/src/specs/NativeHyperswitchSdkNative.d.ts +17 -0
- package/lib/typescript/module/src/specs/NativeHyperswitchSdkNative.d.ts.map +1 -0
- package/lib/typescript/module/src/specs/NativeHyperswitchSdkReactNative.d.ts +9 -0
- package/lib/typescript/module/src/specs/NativeHyperswitchSdkReactNative.d.ts.map +1 -0
- package/lib/typescript/module/src/types/PaymentSheetConfiguration.gen.d.ts +149 -0
- package/lib/typescript/module/src/types/PaymentSheetConfiguration.gen.d.ts.map +1 -0
- package/lib/typescript/module/src/types/PaymentSheetConfiguration.res.d.ts +1 -0
- package/lib/typescript/module/src/types/PaymentSheetConfiguration.res.d.ts.map +1 -0
- package/package.json +196 -0
- package/src/context/HyperProvider.gen.tsx +26 -0
- package/src/context/HyperProvider.res +78 -0
- package/src/context/HyperProvider.res.js +112 -0
- package/src/hooks/useHyper.gen.tsx +18 -0
- package/src/hooks/useHyper.res +142 -0
- package/src/hooks/useHyper.res.js +157 -0
- package/src/index.tsx +13 -0
- package/src/modules/NativeHyperswitchSdk.gen.tsx +25 -0
- package/src/modules/NativeHyperswitchSdk.res +55 -0
- package/src/modules/NativeHyperswitchSdk.res.js +10 -0
- package/src/shims/Js.shim.ts +5 -0
- package/src/specs/ApplePayButtonNativeComponent.ts +11 -0
- package/src/specs/GooglePayButtonNativeComponent.android.ts +12 -0
- package/src/specs/HyperswitchSdkReactNativeViewNativeComponent.ts +10 -0
- package/src/specs/NativeHyperswitchSdkNative.ts +33 -0
- package/src/specs/NativeHyperswitchSdkReactNative.ts +17 -0
- package/src/types/PaymentSheetConfiguration.gen.tsx +202 -0
- package/src/types/PaymentSheetConfiguration.res +215 -0
- package/src/types/PaymentSheetConfiguration.res.js +2 -0
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
//
|
|
2
|
+
// HyperLogManager.swift
|
|
3
|
+
// hyperswitch
|
|
4
|
+
//
|
|
5
|
+
// Created by Kuntimaddi Manideep on 24/01/25.
|
|
6
|
+
//
|
|
7
|
+
|
|
8
|
+
import Foundation
|
|
9
|
+
|
|
10
|
+
final class LogManager {
|
|
11
|
+
private static var logsBatch: [LogPayload] = []
|
|
12
|
+
private static var publishableKey: String = ""
|
|
13
|
+
private static var loggingEndPoint: String?
|
|
14
|
+
private static let fileManager = LogFileManager()
|
|
15
|
+
private static let queue = DispatchQueue(label: "hyperlog.queue")
|
|
16
|
+
private static let debouncer = Debouncer(delayInMillis: 2000.0)
|
|
17
|
+
|
|
18
|
+
private static func formatPayload(logs: [String]) -> String {
|
|
19
|
+
return "[" + logs.joined(separator: ",")
|
|
20
|
+
.replacingOccurrences(of: " ", with: "")
|
|
21
|
+
.replacingOccurrences(of: "\n", with: "") + "]"
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
private static func getStringifiedLogs(_ logBatch: [LogPayload]) -> [String] {
|
|
25
|
+
return logBatch.compactMap { $0.toJson() }
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
static func initialize(publishableKey: String) {
|
|
29
|
+
queue.async {
|
|
30
|
+
self.publishableKey = publishableKey
|
|
31
|
+
self.loggingEndPoint = SDKEnvironment.loggingURL(for: publishableKey)
|
|
32
|
+
}
|
|
33
|
+
if !publishableKey.isEmpty {
|
|
34
|
+
sendLogsFromFile()
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
static func sendLogsFromFile() {
|
|
39
|
+
queue.async {
|
|
40
|
+
guard let endpoint = loggingEndPoint else { return }
|
|
41
|
+
let logs = fileManager.getStoredLogsInArray()
|
|
42
|
+
let payload = formatPayload(logs: logs)
|
|
43
|
+
|
|
44
|
+
let data = payload.data(using: .utf8)
|
|
45
|
+
|
|
46
|
+
let logRequest = HTTPRequestService(host: endpoint, path: "", endpoint: "", method: .post)
|
|
47
|
+
logRequest.headers = ["Content-Type": "application/json"]
|
|
48
|
+
logRequest.bodyData = data
|
|
49
|
+
|
|
50
|
+
logRequest.request(type: Data.self) { (result, statusCode) in
|
|
51
|
+
switch (result, statusCode) {
|
|
52
|
+
case (.success(_), 200..<300):
|
|
53
|
+
fileManager.clearFile()
|
|
54
|
+
default:
|
|
55
|
+
break;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
static func saveLogsToFile() {
|
|
62
|
+
queue.async {
|
|
63
|
+
let logs = getStringifiedLogs(logsBatch)
|
|
64
|
+
fileManager.addLogs(logs: logs)
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
static func saveLogsToFile(_ logsBatch: [LogPayload]) {
|
|
69
|
+
queue.async {
|
|
70
|
+
let logs = getStringifiedLogs(logsBatch)
|
|
71
|
+
fileManager.addLogs(logs: logs)
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
static func addLog(_ log: LogPayload) {
|
|
76
|
+
queue.async {
|
|
77
|
+
logsBatch.append(log)
|
|
78
|
+
debouncer.debounce {
|
|
79
|
+
sendLogsOverNetwork()
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
private static func sendLogsOverNetwork() {
|
|
85
|
+
queue.async {
|
|
86
|
+
guard !logsBatch.isEmpty, let endpoint = loggingEndPoint else { return }
|
|
87
|
+
var copiedLogs = logsBatch
|
|
88
|
+
logsBatch.removeAll()
|
|
89
|
+
|
|
90
|
+
for index in copiedLogs.indices {
|
|
91
|
+
copiedLogs[index].merchant_id = LogManager.publishableKey
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
let logsToSend = getStringifiedLogs(copiedLogs)
|
|
95
|
+
guard !logsToSend.isEmpty else { return }
|
|
96
|
+
|
|
97
|
+
let payload = formatPayload(logs: logsToSend)
|
|
98
|
+
let data = payload.data(using: .utf8)
|
|
99
|
+
let logRequest = HTTPRequestService(host: endpoint, path: "", endpoint: "", method: .post)
|
|
100
|
+
|
|
101
|
+
logRequest.headers = ["Content-Type": "application/json"]
|
|
102
|
+
logRequest.bodyData = data
|
|
103
|
+
logRequest.request(type: Data.self) { (result, statusCode) in
|
|
104
|
+
switch (result, statusCode) {
|
|
105
|
+
case (.success(_), 200..<300):
|
|
106
|
+
break;
|
|
107
|
+
default:
|
|
108
|
+
saveLogsToFile(copiedLogs)
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
//
|
|
2
|
+
// HyperHeadless.m
|
|
3
|
+
// Hyperswitch
|
|
4
|
+
//
|
|
5
|
+
// Created by Shivam Shashank on 06/03/24.
|
|
6
|
+
//
|
|
7
|
+
|
|
8
|
+
#import <React/RCTEventEmitter.h>
|
|
9
|
+
|
|
10
|
+
@interface RCT_EXTERN_MODULE(HyperHeadless, RCTEventEmitter)
|
|
11
|
+
|
|
12
|
+
RCT_EXTERN_METHOD(initialisePaymentSession: (RCTResponseSenderBlock)rnCallback)
|
|
13
|
+
RCT_EXTERN_METHOD(getPaymentSession: (NSDictionary)rnMessage :(NSDictionary)rnMessage2 :(NSArray)rnMessage3 :(RCTResponseSenderBlock)rnCallback)
|
|
14
|
+
RCT_EXTERN_METHOD(exitHeadless: (NSString)rnMessage)
|
|
15
|
+
|
|
16
|
+
@end
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
//
|
|
2
|
+
// HyperHeadless.swift
|
|
3
|
+
// Hyperswitch
|
|
4
|
+
//
|
|
5
|
+
// Created by Shivam Shashank on 06/03/24.
|
|
6
|
+
//
|
|
7
|
+
|
|
8
|
+
import Foundation
|
|
9
|
+
import React
|
|
10
|
+
import WebKit
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
@objc(HyperHeadless)
|
|
14
|
+
internal class HyperHeadless: RCTEventEmitter {
|
|
15
|
+
|
|
16
|
+
internal static var shared:HyperHeadless?
|
|
17
|
+
|
|
18
|
+
private var setNativeProps: RCTResponseSenderBlock?
|
|
19
|
+
private var confirmWithDefault: RCTResponseSenderBlock?
|
|
20
|
+
private var defaultPMData: ((NSDictionary?) -> Void)?
|
|
21
|
+
|
|
22
|
+
internal override init() {
|
|
23
|
+
super.init()
|
|
24
|
+
HyperHeadless.shared = self
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
@objc
|
|
28
|
+
internal override static func requiresMainQueueSetup() -> Bool {
|
|
29
|
+
return true
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
@objc
|
|
33
|
+
internal override func supportedEvents() -> [String] {
|
|
34
|
+
return ["test"]
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
@objc
|
|
38
|
+
private func confirm(data: [String: Any]) {
|
|
39
|
+
self.sendEvent(withName: "test", body: data)
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
@objc
|
|
43
|
+
private func sendMessageToNative(_ rnMessage: String) {}
|
|
44
|
+
|
|
45
|
+
@objc
|
|
46
|
+
private func initialisePaymentSession (_ rnCallback: @escaping RCTResponseSenderBlock) {
|
|
47
|
+
DispatchQueue.main.async {
|
|
48
|
+
if PaymentSession.headlessCompletion != nil, !PaymentSession.isPresented {
|
|
49
|
+
let hyperParams = HyperParams.getHyperParams()
|
|
50
|
+
|
|
51
|
+
let props: [String: Any] = [
|
|
52
|
+
"clientSecret": PaymentSession.paymentIntentClientSecret as Any,
|
|
53
|
+
"publishableKey": APIClient.shared.publishableKey as Any,
|
|
54
|
+
"hyperParams": hyperParams,
|
|
55
|
+
"customBackendUrl": APIClient.shared.customBackendUrl as Any,
|
|
56
|
+
"customLogUrl": APIClient.shared.customLogUrl as Any,
|
|
57
|
+
"customParams": APIClient.shared.customParams as Any
|
|
58
|
+
]
|
|
59
|
+
rnCallback([props])
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
@objc
|
|
65
|
+
private func getPaymentSession(_ rnMessage: NSDictionary, _ rnMessage2: NSDictionary, _ rnMessage3: NSArray, _ rnCallback: @escaping RCTResponseSenderBlock) {
|
|
66
|
+
PaymentSession.getPaymentSession(getPaymentMethodData: rnMessage, getPaymentMethodData2: rnMessage2, getPaymentMethodDataArray: rnMessage3, callback: rnCallback)
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
@objc
|
|
70
|
+
private func exitHeadless(_ rnMessage: String) {
|
|
71
|
+
PaymentSession.exitHeadless(rnMessage: rnMessage)
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
#import <React/RCTEventEmitter.h>
|
|
2
|
+
|
|
3
|
+
@interface RCT_EXTERN_MODULE(HyperModule, RCTEventEmitter)
|
|
4
|
+
|
|
5
|
+
RCT_EXTERN_METHOD(sendMessageToNative: (NSString)rnMessage)
|
|
6
|
+
RCT_EXTERN_METHOD(presentPaymentSheet: (NSDictionary) rnMessage :(RCTResponseSenderBlock)rnCallback)
|
|
7
|
+
RCT_EXTERN_METHOD(exitPaymentsheet: (nonnull NSNumber *)reactTag :(NSString)rnMessage :(BOOL)reset)
|
|
8
|
+
RCT_EXTERN_METHOD(exitPaymentMethodManagement: (nonnull NSNumber *)reactTag :(NSString)rnMessage :(BOOL)reset)
|
|
9
|
+
RCT_EXTERN_METHOD(exitCardForm: (NSString)rnMessage)
|
|
10
|
+
RCT_EXTERN_METHOD(launchWidgetPaymentSheet: (NSDictionary) rnMessage :(RCTResponseSenderBlock)rnCallback)
|
|
11
|
+
RCT_EXTERN_METHOD(onAddPaymentMethod: (NSString)rnMessage)
|
|
12
|
+
RCT_EXTERN_METHOD(exitWidgetPaymentsheet: (nonnull NSNumber *)reactTag :(NSString)rnMessage :(BOOL)reset)
|
|
13
|
+
RCT_EXTERN_METHOD(launchApplePay: (NSString)rnMessage :(RCTResponseSenderBlock)rnCallback)
|
|
14
|
+
RCT_EXTERN_METHOD(startApplePay: (NSString)rnMessage :(RCTResponseSenderBlock)startCallback)
|
|
15
|
+
RCT_EXTERN_METHOD(presentApplePay: (NSString)rnMessage :(RCTResponseSenderBlock)presentCallback)
|
|
16
|
+
|
|
17
|
+
+ (BOOL)requiresMainQueueSetup
|
|
18
|
+
{
|
|
19
|
+
return YES;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
- (dispatch_queue_t)methodQueue
|
|
23
|
+
{
|
|
24
|
+
return dispatch_get_main_queue();
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
@end
|
|
28
|
+
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
//
|
|
2
|
+
// HyperModule.swift
|
|
3
|
+
// Hyperswitch
|
|
4
|
+
//
|
|
5
|
+
// Created by Harshit Srivastava on 07/03/24.
|
|
6
|
+
//
|
|
7
|
+
|
|
8
|
+
import Foundation
|
|
9
|
+
import React
|
|
10
|
+
|
|
11
|
+
@objc(HyperModule)
|
|
12
|
+
internal class HyperModule: RCTEventEmitter {
|
|
13
|
+
|
|
14
|
+
private let applePayPaymentHandler = ApplePayHandler()
|
|
15
|
+
// private let expressCheckoutHandler = ExpressCheckoutLauncher()
|
|
16
|
+
private var presentCallback: RCTResponseSenderBlock? = nil
|
|
17
|
+
internal static var shared:HyperModule?
|
|
18
|
+
|
|
19
|
+
override init() {
|
|
20
|
+
super.init()
|
|
21
|
+
HyperModule.shared = self
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
@objc
|
|
25
|
+
internal override static func requiresMainQueueSetup() -> Bool {
|
|
26
|
+
return true
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
@objc
|
|
30
|
+
internal override func supportedEvents() -> [String] {
|
|
31
|
+
return ["confirm", "confirmEC"]
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
@objc
|
|
35
|
+
internal func confirm(data: [String: Any]) {
|
|
36
|
+
self.sendEvent(withName: "confirm", body: data)
|
|
37
|
+
}
|
|
38
|
+
// MARK: WIP
|
|
39
|
+
// @objc func confirmEC(data: [String: Any]) {
|
|
40
|
+
// self.sendEvent(withName: "confirmEC", body: data)
|
|
41
|
+
// }
|
|
42
|
+
|
|
43
|
+
@objc
|
|
44
|
+
private func sendMessageToNative(_ rnMessage: String) {}
|
|
45
|
+
|
|
46
|
+
//React Native Wrapper Function
|
|
47
|
+
@objc
|
|
48
|
+
private func presentPaymentSheet(_ request: NSMutableDictionary, _ callBack: @escaping RCTResponseSenderBlock) -> Void {
|
|
49
|
+
DispatchQueue.main.async {
|
|
50
|
+
let paymentSheet = PaymentSheet(paymentIntentClientSecret: "", configuration: PaymentSheet.Configuration())
|
|
51
|
+
paymentSheet.presentWithParams(
|
|
52
|
+
from: (UIApplication.shared.delegate?.window??.rootViewController)!,
|
|
53
|
+
props: request as! [String : Any],
|
|
54
|
+
completion: { result2 in
|
|
55
|
+
switch result2 {
|
|
56
|
+
case .completed(let data):
|
|
57
|
+
callBack([["status": "completed", "message": data]])
|
|
58
|
+
case .failed(let error as NSError):
|
|
59
|
+
callBack([["status": "failed", "code": error.domain, "message": "Payment failed: \(error.userInfo["message"] ?? "Failed")"]])
|
|
60
|
+
case .canceled(let data):
|
|
61
|
+
callBack([["status": "cancelled", "message": data]])
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
)
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
// @objc
|
|
69
|
+
// private func launchWidgetPaymentSheet(_ request: NSMutableDictionary, _ callback: @escaping RCTResponseSenderBlock) -> Void {
|
|
70
|
+
// expressCheckoutHandler.launchPaymentSheet(paymentResult: request,callBack: callback)
|
|
71
|
+
// }
|
|
72
|
+
|
|
73
|
+
// @objc
|
|
74
|
+
// private func onAddPaymentMethod(_ rnMessage: String) -> Void {
|
|
75
|
+
// PaymentMethodManagementWidget.onAddPaymentMethod?()
|
|
76
|
+
// }
|
|
77
|
+
|
|
78
|
+
@objc
|
|
79
|
+
private func launchApplePay (_ rnMessage: String, _ rnCallback: @escaping RCTResponseSenderBlock) {
|
|
80
|
+
applePayPaymentHandler.startPayment(rnMessage: rnMessage, rnCallback: rnCallback, presentCallback: self.presentCallback)
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
@objc
|
|
84
|
+
private func startApplePay (_ rnMessage: String, _ rnCallback: @escaping RCTResponseSenderBlock) {
|
|
85
|
+
rnCallback([])
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
@objc
|
|
89
|
+
private func presentApplePay (_ rnMessage: String, _ rnCallback: @escaping RCTResponseSenderBlock) {
|
|
90
|
+
self.presentCallback = rnCallback
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
// @objc
|
|
94
|
+
// private func exitPaymentsheet(_ reactTag: NSNumber, _ rnMessage: String, _ reset: Bool) {
|
|
95
|
+
// exitSheet(rnMessage)
|
|
96
|
+
// }
|
|
97
|
+
//
|
|
98
|
+
// @objc
|
|
99
|
+
// private func exitWidgetPaymentsheet(_ reactTag: NSNumber, _ rnMessage: String, _ reset: Bool) {
|
|
100
|
+
// exitSheet(rnMessage)
|
|
101
|
+
// }
|
|
102
|
+
//
|
|
103
|
+
// @objc
|
|
104
|
+
// private func exitPaymentMethodManagement(_ reactTag: NSNumber, _ rnMessage: String, _ reset: Bool) {
|
|
105
|
+
// exitSheet(rnMessage)
|
|
106
|
+
// }
|
|
107
|
+
//
|
|
108
|
+
// @objc
|
|
109
|
+
// private func exitCardForm(_ rnMessage: String) {
|
|
110
|
+
// var response: String?
|
|
111
|
+
// var error: NSError?
|
|
112
|
+
//
|
|
113
|
+
// if let data = rnMessage.data(using: .utf8) {
|
|
114
|
+
// do {
|
|
115
|
+
// if let jsonDictionary = try JSONSerialization.jsonObject(with: data, options: []) as? [String: String] {
|
|
116
|
+
// let status = jsonDictionary["status"]
|
|
117
|
+
//
|
|
118
|
+
// if (status == "failed" || status == "requires_payment_method") {
|
|
119
|
+
// error = NSError(domain: (jsonDictionary["code"] ?? "") != "" ? jsonDictionary["code"]! : "UNKNOWN_ERROR", code: 0, userInfo: ["message" : jsonDictionary["message"] ?? "An error has occurred."])
|
|
120
|
+
// } else {
|
|
121
|
+
// response = status
|
|
122
|
+
// }
|
|
123
|
+
// RNViewManager.sharedInstance.responseHandler?.didReceiveResponse(response: response, error: error)
|
|
124
|
+
// } else {
|
|
125
|
+
// RNViewManager.sharedInstance.responseHandler?.didReceiveResponse(response: "failed", error: NSError(domain: "UNKNOWN_ERROR", code: 0, userInfo: ["message" : "An error has occurred."]))
|
|
126
|
+
// }
|
|
127
|
+
// } catch {
|
|
128
|
+
// RNViewManager.sharedInstance.responseHandler?.didReceiveResponse(response: "failed", error: NSError(domain: "UNKNOWN_ERROR", code: 0, userInfo: ["message" : "An error has occurred."]))
|
|
129
|
+
// }
|
|
130
|
+
// } else {
|
|
131
|
+
// RNViewManager.sharedInstance.responseHandler?.didReceiveResponse(response: "failed", error: NSError(domain: "UNKNOWN_ERROR", code: 0, userInfo: ["message" : "An error has occurred."]))
|
|
132
|
+
// }
|
|
133
|
+
// }
|
|
134
|
+
//
|
|
135
|
+
// @objc
|
|
136
|
+
// private func exitSheet(_ rnMessage: String) {
|
|
137
|
+
// var response: String?
|
|
138
|
+
// var error: NSError?
|
|
139
|
+
//
|
|
140
|
+
// if let data = rnMessage.data(using: .utf8) {
|
|
141
|
+
// do {
|
|
142
|
+
// if let jsonDictionary = try JSONSerialization.jsonObject(with: data, options: []) as? [String: String] {
|
|
143
|
+
// let status = jsonDictionary["status"]
|
|
144
|
+
//
|
|
145
|
+
// if (status == "failed" || status == "requires_payment_method") {
|
|
146
|
+
// error = NSError(domain: (jsonDictionary["code"] ?? "") != "" ? jsonDictionary["code"]! : "UNKNOWN_ERROR", code: 0, userInfo: ["message" : jsonDictionary["message"] ?? "An error has occurred."])
|
|
147
|
+
// } else {
|
|
148
|
+
// response = status
|
|
149
|
+
// }
|
|
150
|
+
// RNViewManager.sharedInstance.responseHandler?.didReceiveResponse(response: response, error: error)
|
|
151
|
+
// } else {
|
|
152
|
+
// RNViewManager.sharedInstance.responseHandler?.didReceiveResponse(response: "failed", error: NSError(domain: "UNKNOWN_ERROR", code: 0, userInfo: ["message" : "An error has occurred."]))
|
|
153
|
+
// }
|
|
154
|
+
// } catch {
|
|
155
|
+
// RNViewManager.sharedInstance.responseHandler?.didReceiveResponse(response: "failed", error: NSError(domain: "UNKNOWN_ERROR", code: 0, userInfo: ["message" : "An error has occurred."]))
|
|
156
|
+
// }
|
|
157
|
+
// } else {
|
|
158
|
+
// RNViewManager.sharedInstance.responseHandler?.didReceiveResponse(response: "failed", error: NSError(domain: "UNKNOWN_ERROR", code: 0, userInfo: ["message" : "An error has occurred."]))
|
|
159
|
+
// }
|
|
160
|
+
// DispatchQueue.main.async {
|
|
161
|
+
// if let view = RNViewManager.sharedInstance.rootView {
|
|
162
|
+
// let reactNativeVC: UIViewController? = view.reactViewController()
|
|
163
|
+
// reactNativeVC?.dismiss(animated: false, completion: nil)
|
|
164
|
+
// }
|
|
165
|
+
// }
|
|
166
|
+
// }
|
|
167
|
+
}
|
|
168
|
+
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
//
|
|
2
|
+
// OTAServices.swift
|
|
3
|
+
// hyperswitch
|
|
4
|
+
//
|
|
5
|
+
// Created by Kuntimaddi Manideep on 24/01/25.
|
|
6
|
+
//
|
|
7
|
+
|
|
8
|
+
import Foundation
|
|
9
|
+
import HyperOTA
|
|
10
|
+
|
|
11
|
+
private func getHyperOTAPlist(_ key: String) -> String? {
|
|
12
|
+
guard let path = Bundle(for: RNFabricManager.self).path(forResource: "HyperOTA", ofType: "plist"),
|
|
13
|
+
let dict = NSDictionary(contentsOfFile: path),
|
|
14
|
+
let value = dict[key] as? String, !value.isEmpty else {
|
|
15
|
+
return nil
|
|
16
|
+
}
|
|
17
|
+
return value
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
internal class EventLogger: NSObject, HPJPLoggerDelegate {
|
|
21
|
+
private func isJSONSerializable(_ value: Any) -> Bool {
|
|
22
|
+
return JSONSerialization.isValidJSONObject(["key": value])
|
|
23
|
+
}
|
|
24
|
+
internal func addLog(eventData: [String: Any], logLevel : String, key: String?){
|
|
25
|
+
do {
|
|
26
|
+
let jsonData = try JSONSerialization.data(withJSONObject: eventData, options: [])
|
|
27
|
+
guard let jsonString = String(data: jsonData, encoding: .utf8) else {
|
|
28
|
+
print("Error: JSON data encoding failed.")
|
|
29
|
+
return
|
|
30
|
+
}
|
|
31
|
+
var log = LogBuilder()
|
|
32
|
+
.setLogType(logLevel)
|
|
33
|
+
.setValue(jsonString)
|
|
34
|
+
|
|
35
|
+
switch key {
|
|
36
|
+
case "init_with_local_config_versions":
|
|
37
|
+
log = log.setEventName(.HYPER_OTA_INIT)
|
|
38
|
+
break
|
|
39
|
+
case "init":
|
|
40
|
+
log = log.setEventName(.HYPER_OTA_INIT)
|
|
41
|
+
break
|
|
42
|
+
case "update_end":
|
|
43
|
+
log = log.setEventName(.HYPER_OTA_FINISH)
|
|
44
|
+
case "end":
|
|
45
|
+
log = log.setEventName(.HYPER_OTA_FINISH)
|
|
46
|
+
break
|
|
47
|
+
default:
|
|
48
|
+
log = log.setEventName(.HYPER_OTA_EVENT)
|
|
49
|
+
}
|
|
50
|
+
LogManager.addLog(log.build())
|
|
51
|
+
|
|
52
|
+
} catch {
|
|
53
|
+
print("Error serializing event data: \(error.localizedDescription)")
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
func trackEvent(
|
|
57
|
+
withLevel logLevel: String,
|
|
58
|
+
label eventLabel: String,
|
|
59
|
+
key eventKey: String? = nil,
|
|
60
|
+
value eventValue: Any,
|
|
61
|
+
category eventCategory: String,
|
|
62
|
+
subcategory eventSubcategory: String
|
|
63
|
+
) {
|
|
64
|
+
let eventData: [String: Any] = [
|
|
65
|
+
"label": eventLabel,
|
|
66
|
+
"value": isJSONSerializable(eventValue) ? eventValue : String(describing: eventValue),
|
|
67
|
+
"key" : eventKey ?? "",
|
|
68
|
+
"category": eventCategory,
|
|
69
|
+
"subcategory": eventSubcategory
|
|
70
|
+
]
|
|
71
|
+
addLog(eventData: eventData, logLevel: logLevel, key : eventKey)
|
|
72
|
+
}
|
|
73
|
+
func trackEvent(
|
|
74
|
+
withLevel logLevel: String,
|
|
75
|
+
label eventLabel: String,
|
|
76
|
+
value eventValue: Any,
|
|
77
|
+
category eventCategory: String,
|
|
78
|
+
subcategory eventSubcategory: String
|
|
79
|
+
) {
|
|
80
|
+
let eventData: [String: Any] = [
|
|
81
|
+
"label": eventLabel,
|
|
82
|
+
"value": isJSONSerializable(eventValue) ? eventValue : String(describing: eventValue),
|
|
83
|
+
"category": eventCategory,
|
|
84
|
+
"subcategory": eventSubcategory
|
|
85
|
+
]
|
|
86
|
+
addLog(eventData: eventData, logLevel: logLevel, key : eventLabel)
|
|
87
|
+
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
public final class OTAServices {
|
|
92
|
+
public static var shared = OTAServices()
|
|
93
|
+
public var otaServices : HyperOTAServices? = nil
|
|
94
|
+
let logger = EventLogger()
|
|
95
|
+
public func initialize(publishableKey : String) {
|
|
96
|
+
if(self.otaServices == nil) {
|
|
97
|
+
let environment = SDKEnvironment.getEnvironment(publishableKey)
|
|
98
|
+
let configKey = (environment == .SANDBOX) ? "sandBoxReleaseConfigURL" : "releaseConfigURL"
|
|
99
|
+
let payload = [
|
|
100
|
+
"clientId": getHyperOTAPlist("clientId") ?? "" ,
|
|
101
|
+
"namespace": getHyperOTAPlist("namespace") ?? "",
|
|
102
|
+
"forceUpdate": true,
|
|
103
|
+
"localAssets": (getHyperOTAPlist(configKey) ?? "releaseConfigURL") == "releaseConfigURL",
|
|
104
|
+
"fileName": getHyperOTAPlist("fileName") ?? "" ,
|
|
105
|
+
"releaseConfigURL": (getHyperOTAPlist(configKey) ?? "") + "/mobile-ota/ios/" + SDKVersion.current + "/config.json",
|
|
106
|
+
] as [String: Any]
|
|
107
|
+
self.otaServices = HyperOTAServices(payload: payload, loggerDelegate: logger, baseBundle: Bundle(for: OTAServices.self))
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
public func getBundleURL() -> URL? {
|
|
111
|
+
return otaServices?.bundleURL() ?? Bundle(for: OTAServices.self).url(forResource: "hyperswitch", withExtension: "bundle")
|
|
112
|
+
}
|
|
113
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
//
|
|
2
|
+
// RNHeadlessManager.swift
|
|
3
|
+
// Hyperswitch
|
|
4
|
+
//
|
|
5
|
+
// Created by Shivam Shashank on 09/11/22.
|
|
6
|
+
//
|
|
7
|
+
|
|
8
|
+
import Foundation
|
|
9
|
+
import React
|
|
10
|
+
|
|
11
|
+
//internal class RNHeadlessManager: NSObject {
|
|
12
|
+
// internal var responseHandler: RNResponseHandler?
|
|
13
|
+
// internal var rootView: RCTRootView?
|
|
14
|
+
//
|
|
15
|
+
// internal lazy var bridgeHeadless: RCTBridge = {
|
|
16
|
+
// RCTBridge.init(delegate: self, launchOptions: nil)
|
|
17
|
+
// }()
|
|
18
|
+
//
|
|
19
|
+
// internal static let sharedInstance = RNHeadlessManager()
|
|
20
|
+
//
|
|
21
|
+
// internal func viewForModule(_ moduleName: String, initialProperties: [String : Any]?) -> RCTRootView {
|
|
22
|
+
// let rootView: RCTRootView = RCTRootView(
|
|
23
|
+
// bridge: self.bridgeHeadless,
|
|
24
|
+
// moduleName: moduleName,
|
|
25
|
+
// initialProperties: initialProperties)
|
|
26
|
+
// self.rootView = rootView
|
|
27
|
+
// return rootView
|
|
28
|
+
// }
|
|
29
|
+
//
|
|
30
|
+
// internal func reinvalidateBridge(){
|
|
31
|
+
// self.bridgeHeadless.invalidate()
|
|
32
|
+
// self.bridgeHeadless = RCTBridge.init(delegate: self, launchOptions: nil)
|
|
33
|
+
// }
|
|
34
|
+
//}
|
|
35
|
+
//
|
|
36
|
+
//extension RNHeadlessManager: RCTBridgeDelegate {
|
|
37
|
+
// func sourceURL(for bridge: RCTBridge) -> URL? {
|
|
38
|
+
// switch getInfoPlist("HyperswitchSource") {
|
|
39
|
+
// case "LocalHosted":
|
|
40
|
+
// return RCTBundleURLProvider.sharedSettings().jsBundleURL(forBundleRoot: "index")
|
|
41
|
+
// default:
|
|
42
|
+
// return Bundle(for: RNHeadlessManager.self).url(forResource: "hyperswitch", withExtension: "bundle")
|
|
43
|
+
// }
|
|
44
|
+
// }
|
|
45
|
+
//}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
//
|
|
2
|
+
// RNViewManager.swift
|
|
3
|
+
// Hyperswitch
|
|
4
|
+
//
|
|
5
|
+
// Created by Shivam Shashank on 09/11/22.
|
|
6
|
+
//
|
|
7
|
+
|
|
8
|
+
//import Foundation
|
|
9
|
+
//import React
|
|
10
|
+
//
|
|
11
|
+
//internal class RNViewManager: NSObject {
|
|
12
|
+
//
|
|
13
|
+
// internal var responseHandler: RNResponseHandler?
|
|
14
|
+
// internal var rootView: RCTRootView?
|
|
15
|
+
//
|
|
16
|
+
// internal lazy var bridge: RCTBridge = {
|
|
17
|
+
// RCTBridge.init(delegate: self, launchOptions: nil)
|
|
18
|
+
// }()
|
|
19
|
+
//
|
|
20
|
+
//
|
|
21
|
+
// internal static let sharedInstance = RNViewManager()
|
|
22
|
+
//
|
|
23
|
+
// internal func viewForModule(_ moduleName: String, initialProperties: [String : Any]?) -> RCTRootView {
|
|
24
|
+
// let rootView: RCTRootView = RCTRootView(
|
|
25
|
+
// bridge: self.bridge,
|
|
26
|
+
// moduleName: moduleName,
|
|
27
|
+
// initialProperties: initialProperties)
|
|
28
|
+
// self.rootView = rootView
|
|
29
|
+
// return rootView
|
|
30
|
+
// }
|
|
31
|
+
//}
|
|
32
|
+
//
|
|
33
|
+
//extension RNViewManager: RCTBridgeDelegate {
|
|
34
|
+
// func sourceURL(for bridge: RCTBridge) -> URL? {
|
|
35
|
+
// switch getInfoPlist("HyperswitchSource") {
|
|
36
|
+
// case "LocalHosted":
|
|
37
|
+
// return RCTBundleURLProvider.sharedSettings().jsBundleURL(forBundleRoot: "index")
|
|
38
|
+
// case "LocalBundle":
|
|
39
|
+
// return Bundle.main.url(forResource: "hyperswitch", withExtension: "bundle")
|
|
40
|
+
// default:
|
|
41
|
+
// return OTAServices.shared.getBundleURL()
|
|
42
|
+
// }
|
|
43
|
+
// }
|
|
44
|
+
//}
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
// TODO: #if RCT_NEW_ARCH_ENABLED
|
|
48
|
+
import Foundation
|
|
49
|
+
import React
|
|
50
|
+
import React_RCTAppDelegate
|
|
51
|
+
import ReactAppDependencyProvider
|
|
52
|
+
|
|
53
|
+
internal class RNFabricManager: RCTDefaultReactNativeFactoryDelegate {
|
|
54
|
+
|
|
55
|
+
internal var responseHandler: RNResponseHandler?
|
|
56
|
+
internal var rootView: UIView?
|
|
57
|
+
|
|
58
|
+
private var reactNativeFactory: RCTReactNativeFactory? = nil
|
|
59
|
+
|
|
60
|
+
internal static let sharedInstance = RNFabricManager()
|
|
61
|
+
|
|
62
|
+
internal func startReactNative() {
|
|
63
|
+
self.dependencyProvider = RCTAppDependencyProvider()
|
|
64
|
+
self.reactNativeFactory = RCTReactNativeFactory(delegate: self)
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
internal func viewForModule(_ moduleName: String, initialProperties: [String : Any]?) -> UIView? {
|
|
68
|
+
let rootView = reactNativeFactory?.rootViewFactory.view(
|
|
69
|
+
withModuleName: moduleName,
|
|
70
|
+
initialProperties: initialProperties
|
|
71
|
+
)
|
|
72
|
+
self.rootView = rootView
|
|
73
|
+
return rootView
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
override func sourceURL(for bridge: RCTBridge) -> URL? {
|
|
77
|
+
return bundleURL()
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
public override func bundleURL() -> URL? {
|
|
81
|
+
switch getInfoPlist("HyperswitchSource") {
|
|
82
|
+
case "LocalHosted":
|
|
83
|
+
return RCTBundleURLProvider.sharedSettings().jsBundleURL(forBundleRoot: "index")
|
|
84
|
+
case "LocalBundle":
|
|
85
|
+
return Bundle.main.url(forResource: "hyperswitch", withExtension: "bundle")
|
|
86
|
+
default:
|
|
87
|
+
return OTAServices.shared.getBundleURL()
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
#import <React/RCTBridgeModule.h>
|
|
2
|
+
#import <React/RCTBridge.h>
|
|
3
|
+
#import <React/RCTEventDispatcher.h>
|
|
4
|
+
#import <React/RCTRootView.h>
|
|
5
|
+
#import <React/RCTUtils.h>
|
|
6
|
+
#import <React/RCTConvert.h>
|
|
7
|
+
#import <React/RCTBundleURLProvider.h>
|
|
8
|
+
#import <React/RCTViewManager.h>
|
|
9
|
+
#import <React/RCTUIManager.h>
|