mergn-react-native 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +44 -0
- package/README.md +131 -0
- package/android/build.gradle +66 -0
- package/android/src/main/java/com/mergn/reactnative/MergnModule.java +152 -0
- package/android/src/main/java/com/mergn/reactnative/MergnPackage.java +31 -0
- package/app.plugin.js +2 -0
- package/docs/ANDROID.md +147 -0
- package/docs/IOS.md +156 -0
- package/docs/MIGRATION.md +365 -0
- package/ios/MergnModule.swift +149 -0
- package/ios/MergnModuleBridge.m +14 -0
- package/ios/MergnNotificationHandler.swift +160 -0
- package/ios/NotificationService/Info.plist +31 -0
- package/ios/NotificationService/NotificationService.swift +82 -0
- package/mergn-react-native.podspec +32 -0
- package/package.json +49 -0
- package/plugin/index.js +219 -0
- package/react-native.config.js +19 -0
- package/scripts/release-ios.sh +79 -0
- package/scripts/verify-package.js +58 -0
- package/sdk/MergnSDK.podspec +28 -0
- package/sdk/mergn_ios.xcframework/Info.plist +44 -0
- package/sdk/mergn_ios.xcframework/ios-arm64/mergn_ios.framework/Info.plist +0 -0
- package/sdk/mergn_ios.xcframework/ios-arm64/mergn_ios.framework/Modules/mergn_ios.swiftmodule/arm64-apple-ios.abi.json +2517 -0
- package/sdk/mergn_ios.xcframework/ios-arm64/mergn_ios.framework/Modules/mergn_ios.swiftmodule/arm64-apple-ios.private.swiftinterface +82 -0
- package/sdk/mergn_ios.xcframework/ios-arm64/mergn_ios.framework/Modules/mergn_ios.swiftmodule/arm64-apple-ios.swiftdoc +0 -0
- package/sdk/mergn_ios.xcframework/ios-arm64/mergn_ios.framework/Modules/mergn_ios.swiftmodule/arm64-apple-ios.swiftinterface +82 -0
- package/sdk/mergn_ios.xcframework/ios-arm64/mergn_ios.framework/mergn_ios +0 -0
- package/sdk/mergn_ios.xcframework/ios-arm64_x86_64-simulator/mergn_ios.framework/Info.plist +0 -0
- package/sdk/mergn_ios.xcframework/ios-arm64_x86_64-simulator/mergn_ios.framework/Modules/mergn_ios.swiftmodule/arm64-apple-ios-simulator.abi.json +2517 -0
- package/sdk/mergn_ios.xcframework/ios-arm64_x86_64-simulator/mergn_ios.framework/Modules/mergn_ios.swiftmodule/arm64-apple-ios-simulator.private.swiftinterface +82 -0
- package/sdk/mergn_ios.xcframework/ios-arm64_x86_64-simulator/mergn_ios.framework/Modules/mergn_ios.swiftmodule/arm64-apple-ios-simulator.swiftdoc +0 -0
- package/sdk/mergn_ios.xcframework/ios-arm64_x86_64-simulator/mergn_ios.framework/Modules/mergn_ios.swiftmodule/arm64-apple-ios-simulator.swiftinterface +82 -0
- package/sdk/mergn_ios.xcframework/ios-arm64_x86_64-simulator/mergn_ios.framework/Modules/mergn_ios.swiftmodule/x86_64-apple-ios-simulator.abi.json +2517 -0
- package/sdk/mergn_ios.xcframework/ios-arm64_x86_64-simulator/mergn_ios.framework/Modules/mergn_ios.swiftmodule/x86_64-apple-ios-simulator.private.swiftinterface +82 -0
- package/sdk/mergn_ios.xcframework/ios-arm64_x86_64-simulator/mergn_ios.framework/Modules/mergn_ios.swiftmodule/x86_64-apple-ios-simulator.swiftdoc +0 -0
- package/sdk/mergn_ios.xcframework/ios-arm64_x86_64-simulator/mergn_ios.framework/Modules/mergn_ios.swiftmodule/x86_64-apple-ios-simulator.swiftinterface +82 -0
- package/sdk/mergn_ios.xcframework/ios-arm64_x86_64-simulator/mergn_ios.framework/_CodeSignature/CodeResources +101 -0
- package/sdk/mergn_ios.xcframework/ios-arm64_x86_64-simulator/mergn_ios.framework/mergn_ios +0 -0
- package/src/index.d.ts +37 -0
- package/src/index.js +34 -0
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
// swift-interface-format-version: 1.0
|
|
2
|
+
// swift-compiler-version: Apple Swift version 6.3.1 effective-5.10 (swiftlang-6.3.1.1.2 clang-2100.0.123.102)
|
|
3
|
+
// swift-module-flags: -target x86_64-apple-ios14.0-simulator -enable-objc-interop -enable-library-evolution -swift-version 5 -O -enable-experimental-feature DebugDescriptionMacro -module-name mergn_ios
|
|
4
|
+
// swift-module-flags-ignorable: -formal-cxx-interoperability-mode=off -interface-compiler-version 6.3.1
|
|
5
|
+
import Foundation
|
|
6
|
+
import Swift
|
|
7
|
+
import UIKit
|
|
8
|
+
import UserNotifications
|
|
9
|
+
import WebKit
|
|
10
|
+
import _Concurrency
|
|
11
|
+
import _StringProcessing
|
|
12
|
+
import _SwiftConcurrencyShims
|
|
13
|
+
@_hasMissingDesignatedInitializers public class EventManager {
|
|
14
|
+
final public let apiMergnKey: Swift.String
|
|
15
|
+
public static let shared: mergn_ios.EventManager
|
|
16
|
+
public func registerAPI(clientApiKey: Swift.String)
|
|
17
|
+
public func getUniqueIdentifier() -> Swift.String
|
|
18
|
+
public func saveCustomerId(customerId: Swift.String) -> Swift.String
|
|
19
|
+
public func saveFirebaseToken(token: Swift.String) -> Swift.String
|
|
20
|
+
public func getCustomerId() -> Swift.String
|
|
21
|
+
public func getFirebaseToken() -> Swift.String
|
|
22
|
+
public func getEventList()
|
|
23
|
+
public func getAttributeList()
|
|
24
|
+
public func getAttributeValue(attributeId: Swift.String) -> Swift.String
|
|
25
|
+
public func postIdentification(identity: Swift.String? = nil)
|
|
26
|
+
public func sendEvent(eventName: Swift.String, properties: [Swift.String : Any])
|
|
27
|
+
public func sendPopupEvent(eventName: Swift.String, popupActionProperty: Swift.String, popupAction: Swift.String, actionValue: Swift.String)
|
|
28
|
+
public func sendAttribute(attributeName: Swift.String, attributeValue: Swift.String)
|
|
29
|
+
public func openWebView(from parentViewController: UIKit.UIViewController, htmlString: Swift.String)
|
|
30
|
+
public func firebaseToken(token: Swift.String)
|
|
31
|
+
public func notificationViewed(notificationData: UserNotifications.UNNotificationRequest)
|
|
32
|
+
public func notificationTapped(notificationData: UserNotifications.UNNotificationRequest)
|
|
33
|
+
public var isAppInstallDateValid: Swift.Bool {
|
|
34
|
+
get
|
|
35
|
+
}
|
|
36
|
+
@objc deinit
|
|
37
|
+
}
|
|
38
|
+
@available(iOSApplicationExtension, unavailable)
|
|
39
|
+
extension UIKit.UIApplication {
|
|
40
|
+
@_Concurrency.MainActor @preconcurrency public static func topViewController(base: UIKit.UIViewController? = UIApplication.shared
|
|
41
|
+
.connectedScenes
|
|
42
|
+
.compactMap { ($0 as? UIWindowScene)?.windows.first(where: { $0.isKeyWindow })?.rootViewController }
|
|
43
|
+
.first) -> UIKit.UIViewController?
|
|
44
|
+
}
|
|
45
|
+
public protocol InAppMergnDelegate : AnyObject {
|
|
46
|
+
func DidReceiveInAppDeepLink(_ url: Swift.String)
|
|
47
|
+
}
|
|
48
|
+
@_hasMissingDesignatedInitializers public class SDKManager {
|
|
49
|
+
public static let shared: mergn_ios.SDKManager
|
|
50
|
+
public func setCurrentViewController(_ viewController: UIKit.UIViewController?)
|
|
51
|
+
public func getCurrentViewController() -> UIKit.UIViewController?
|
|
52
|
+
@objc deinit
|
|
53
|
+
}
|
|
54
|
+
public enum SDKManagerError : Swift.Error {
|
|
55
|
+
case invalidViewController
|
|
56
|
+
case viewControllerNotSet
|
|
57
|
+
public static func == (a: mergn_ios.SDKManagerError, b: mergn_ios.SDKManagerError) -> Swift.Bool
|
|
58
|
+
public func hash(into hasher: inout Swift.Hasher)
|
|
59
|
+
public var hashValue: Swift.Int {
|
|
60
|
+
get
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
@_hasMissingDesignatedInitializers public class MergnSDKManager {
|
|
64
|
+
public static let shared: mergn_ios.MergnSDKManager
|
|
65
|
+
weak public var inAppDelegateMergn: (any mergn_ios.InAppMergnDelegate)?
|
|
66
|
+
@objc deinit
|
|
67
|
+
}
|
|
68
|
+
@objc @_inheritsConvenienceInitializers @_Concurrency.MainActor @preconcurrency public class WebViewController : UIKit.UIViewController, WebKit.WKNavigationDelegate, WebKit.WKScriptMessageHandler {
|
|
69
|
+
@_Concurrency.MainActor @preconcurrency weak public var delegate: (any mergn_ios.InAppMergnDelegate)?
|
|
70
|
+
@_Concurrency.MainActor @preconcurrency @objc override dynamic public func viewDidLoad()
|
|
71
|
+
@_Concurrency.MainActor @preconcurrency @objc override dynamic public func viewDidAppear(_ animated: Swift.Bool)
|
|
72
|
+
@_Concurrency.MainActor @preconcurrency public func loadHTML(_ htmlString: Swift.String)
|
|
73
|
+
@_Concurrency.MainActor @preconcurrency @objc public func webView(_ webView: WebKit.WKWebView, didFinish navigation: WebKit.WKNavigation!)
|
|
74
|
+
@_Concurrency.MainActor @preconcurrency @objc public func webView(_ webView: WebKit.WKWebView, decidePolicyFor navigationAction: WebKit.WKNavigationAction, decisionHandler: @escaping (WebKit.WKNavigationActionPolicy) -> Swift.Void)
|
|
75
|
+
@_Concurrency.MainActor @preconcurrency @objc public func webView(_ webView: WebKit.WKWebView, didFail navigation: WebKit.WKNavigation!, withError error: any Swift.Error)
|
|
76
|
+
@_Concurrency.MainActor @preconcurrency @objc public func userContentController(_ userContentController: WebKit.WKUserContentController, didReceive message: WebKit.WKScriptMessage)
|
|
77
|
+
@_Concurrency.MainActor @preconcurrency @objc override dynamic public init(nibName nibNameOrNil: Swift.String?, bundle nibBundleOrNil: Foundation.Bundle?)
|
|
78
|
+
@_Concurrency.MainActor @preconcurrency @objc required dynamic public init?(coder: Foundation.NSCoder)
|
|
79
|
+
@objc deinit
|
|
80
|
+
}
|
|
81
|
+
extension mergn_ios.SDKManagerError : Swift.Equatable {}
|
|
82
|
+
extension mergn_ios.SDKManagerError : Swift.Hashable {}
|
|
Binary file
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
// swift-interface-format-version: 1.0
|
|
2
|
+
// swift-compiler-version: Apple Swift version 6.3.1 effective-5.10 (swiftlang-6.3.1.1.2 clang-2100.0.123.102)
|
|
3
|
+
// swift-module-flags: -target x86_64-apple-ios14.0-simulator -enable-objc-interop -enable-library-evolution -swift-version 5 -O -enable-experimental-feature DebugDescriptionMacro -module-name mergn_ios
|
|
4
|
+
// swift-module-flags-ignorable: -formal-cxx-interoperability-mode=off -interface-compiler-version 6.3.1
|
|
5
|
+
import Foundation
|
|
6
|
+
import Swift
|
|
7
|
+
import UIKit
|
|
8
|
+
import UserNotifications
|
|
9
|
+
import WebKit
|
|
10
|
+
import _Concurrency
|
|
11
|
+
import _StringProcessing
|
|
12
|
+
import _SwiftConcurrencyShims
|
|
13
|
+
@_hasMissingDesignatedInitializers public class EventManager {
|
|
14
|
+
final public let apiMergnKey: Swift.String
|
|
15
|
+
public static let shared: mergn_ios.EventManager
|
|
16
|
+
public func registerAPI(clientApiKey: Swift.String)
|
|
17
|
+
public func getUniqueIdentifier() -> Swift.String
|
|
18
|
+
public func saveCustomerId(customerId: Swift.String) -> Swift.String
|
|
19
|
+
public func saveFirebaseToken(token: Swift.String) -> Swift.String
|
|
20
|
+
public func getCustomerId() -> Swift.String
|
|
21
|
+
public func getFirebaseToken() -> Swift.String
|
|
22
|
+
public func getEventList()
|
|
23
|
+
public func getAttributeList()
|
|
24
|
+
public func getAttributeValue(attributeId: Swift.String) -> Swift.String
|
|
25
|
+
public func postIdentification(identity: Swift.String? = nil)
|
|
26
|
+
public func sendEvent(eventName: Swift.String, properties: [Swift.String : Any])
|
|
27
|
+
public func sendPopupEvent(eventName: Swift.String, popupActionProperty: Swift.String, popupAction: Swift.String, actionValue: Swift.String)
|
|
28
|
+
public func sendAttribute(attributeName: Swift.String, attributeValue: Swift.String)
|
|
29
|
+
public func openWebView(from parentViewController: UIKit.UIViewController, htmlString: Swift.String)
|
|
30
|
+
public func firebaseToken(token: Swift.String)
|
|
31
|
+
public func notificationViewed(notificationData: UserNotifications.UNNotificationRequest)
|
|
32
|
+
public func notificationTapped(notificationData: UserNotifications.UNNotificationRequest)
|
|
33
|
+
public var isAppInstallDateValid: Swift.Bool {
|
|
34
|
+
get
|
|
35
|
+
}
|
|
36
|
+
@objc deinit
|
|
37
|
+
}
|
|
38
|
+
@available(iOSApplicationExtension, unavailable)
|
|
39
|
+
extension UIKit.UIApplication {
|
|
40
|
+
@_Concurrency.MainActor @preconcurrency public static func topViewController(base: UIKit.UIViewController? = UIApplication.shared
|
|
41
|
+
.connectedScenes
|
|
42
|
+
.compactMap { ($0 as? UIWindowScene)?.windows.first(where: { $0.isKeyWindow })?.rootViewController }
|
|
43
|
+
.first) -> UIKit.UIViewController?
|
|
44
|
+
}
|
|
45
|
+
public protocol InAppMergnDelegate : AnyObject {
|
|
46
|
+
func DidReceiveInAppDeepLink(_ url: Swift.String)
|
|
47
|
+
}
|
|
48
|
+
@_hasMissingDesignatedInitializers public class SDKManager {
|
|
49
|
+
public static let shared: mergn_ios.SDKManager
|
|
50
|
+
public func setCurrentViewController(_ viewController: UIKit.UIViewController?)
|
|
51
|
+
public func getCurrentViewController() -> UIKit.UIViewController?
|
|
52
|
+
@objc deinit
|
|
53
|
+
}
|
|
54
|
+
public enum SDKManagerError : Swift.Error {
|
|
55
|
+
case invalidViewController
|
|
56
|
+
case viewControllerNotSet
|
|
57
|
+
public static func == (a: mergn_ios.SDKManagerError, b: mergn_ios.SDKManagerError) -> Swift.Bool
|
|
58
|
+
public func hash(into hasher: inout Swift.Hasher)
|
|
59
|
+
public var hashValue: Swift.Int {
|
|
60
|
+
get
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
@_hasMissingDesignatedInitializers public class MergnSDKManager {
|
|
64
|
+
public static let shared: mergn_ios.MergnSDKManager
|
|
65
|
+
weak public var inAppDelegateMergn: (any mergn_ios.InAppMergnDelegate)?
|
|
66
|
+
@objc deinit
|
|
67
|
+
}
|
|
68
|
+
@objc @_inheritsConvenienceInitializers @_Concurrency.MainActor @preconcurrency public class WebViewController : UIKit.UIViewController, WebKit.WKNavigationDelegate, WebKit.WKScriptMessageHandler {
|
|
69
|
+
@_Concurrency.MainActor @preconcurrency weak public var delegate: (any mergn_ios.InAppMergnDelegate)?
|
|
70
|
+
@_Concurrency.MainActor @preconcurrency @objc override dynamic public func viewDidLoad()
|
|
71
|
+
@_Concurrency.MainActor @preconcurrency @objc override dynamic public func viewDidAppear(_ animated: Swift.Bool)
|
|
72
|
+
@_Concurrency.MainActor @preconcurrency public func loadHTML(_ htmlString: Swift.String)
|
|
73
|
+
@_Concurrency.MainActor @preconcurrency @objc public func webView(_ webView: WebKit.WKWebView, didFinish navigation: WebKit.WKNavigation!)
|
|
74
|
+
@_Concurrency.MainActor @preconcurrency @objc public func webView(_ webView: WebKit.WKWebView, decidePolicyFor navigationAction: WebKit.WKNavigationAction, decisionHandler: @escaping (WebKit.WKNavigationActionPolicy) -> Swift.Void)
|
|
75
|
+
@_Concurrency.MainActor @preconcurrency @objc public func webView(_ webView: WebKit.WKWebView, didFail navigation: WebKit.WKNavigation!, withError error: any Swift.Error)
|
|
76
|
+
@_Concurrency.MainActor @preconcurrency @objc public func userContentController(_ userContentController: WebKit.WKUserContentController, didReceive message: WebKit.WKScriptMessage)
|
|
77
|
+
@_Concurrency.MainActor @preconcurrency @objc override dynamic public init(nibName nibNameOrNil: Swift.String?, bundle nibBundleOrNil: Foundation.Bundle?)
|
|
78
|
+
@_Concurrency.MainActor @preconcurrency @objc required dynamic public init?(coder: Foundation.NSCoder)
|
|
79
|
+
@objc deinit
|
|
80
|
+
}
|
|
81
|
+
extension mergn_ios.SDKManagerError : Swift.Equatable {}
|
|
82
|
+
extension mergn_ios.SDKManagerError : Swift.Hashable {}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
3
|
+
<plist version="1.0">
|
|
4
|
+
<dict>
|
|
5
|
+
<key>files</key>
|
|
6
|
+
<dict>
|
|
7
|
+
<key>Info.plist</key>
|
|
8
|
+
<data>
|
|
9
|
+
AgEEVxV+qV3RJH0oavxR4ZDyuOU=
|
|
10
|
+
</data>
|
|
11
|
+
</dict>
|
|
12
|
+
<key>files2</key>
|
|
13
|
+
<dict/>
|
|
14
|
+
<key>rules</key>
|
|
15
|
+
<dict>
|
|
16
|
+
<key>^.*</key>
|
|
17
|
+
<true/>
|
|
18
|
+
<key>^.*\.lproj/</key>
|
|
19
|
+
<dict>
|
|
20
|
+
<key>optional</key>
|
|
21
|
+
<true/>
|
|
22
|
+
<key>weight</key>
|
|
23
|
+
<real>1000</real>
|
|
24
|
+
</dict>
|
|
25
|
+
<key>^.*\.lproj/locversion.plist$</key>
|
|
26
|
+
<dict>
|
|
27
|
+
<key>omit</key>
|
|
28
|
+
<true/>
|
|
29
|
+
<key>weight</key>
|
|
30
|
+
<real>1100</real>
|
|
31
|
+
</dict>
|
|
32
|
+
<key>^Base\.lproj/</key>
|
|
33
|
+
<dict>
|
|
34
|
+
<key>weight</key>
|
|
35
|
+
<real>1010</real>
|
|
36
|
+
</dict>
|
|
37
|
+
<key>^version.plist$</key>
|
|
38
|
+
<true/>
|
|
39
|
+
</dict>
|
|
40
|
+
<key>rules2</key>
|
|
41
|
+
<dict>
|
|
42
|
+
<key>.*\.dSYM($|/)</key>
|
|
43
|
+
<dict>
|
|
44
|
+
<key>weight</key>
|
|
45
|
+
<real>11</real>
|
|
46
|
+
</dict>
|
|
47
|
+
<key>^(.*/)?\.DS_Store$</key>
|
|
48
|
+
<dict>
|
|
49
|
+
<key>omit</key>
|
|
50
|
+
<true/>
|
|
51
|
+
<key>weight</key>
|
|
52
|
+
<real>2000</real>
|
|
53
|
+
</dict>
|
|
54
|
+
<key>^.*</key>
|
|
55
|
+
<true/>
|
|
56
|
+
<key>^.*\.lproj/</key>
|
|
57
|
+
<dict>
|
|
58
|
+
<key>optional</key>
|
|
59
|
+
<true/>
|
|
60
|
+
<key>weight</key>
|
|
61
|
+
<real>1000</real>
|
|
62
|
+
</dict>
|
|
63
|
+
<key>^.*\.lproj/locversion.plist$</key>
|
|
64
|
+
<dict>
|
|
65
|
+
<key>omit</key>
|
|
66
|
+
<true/>
|
|
67
|
+
<key>weight</key>
|
|
68
|
+
<real>1100</real>
|
|
69
|
+
</dict>
|
|
70
|
+
<key>^Base\.lproj/</key>
|
|
71
|
+
<dict>
|
|
72
|
+
<key>weight</key>
|
|
73
|
+
<real>1010</real>
|
|
74
|
+
</dict>
|
|
75
|
+
<key>^Info\.plist$</key>
|
|
76
|
+
<dict>
|
|
77
|
+
<key>omit</key>
|
|
78
|
+
<true/>
|
|
79
|
+
<key>weight</key>
|
|
80
|
+
<real>20</real>
|
|
81
|
+
</dict>
|
|
82
|
+
<key>^PkgInfo$</key>
|
|
83
|
+
<dict>
|
|
84
|
+
<key>omit</key>
|
|
85
|
+
<true/>
|
|
86
|
+
<key>weight</key>
|
|
87
|
+
<real>20</real>
|
|
88
|
+
</dict>
|
|
89
|
+
<key>^embedded\.provisionprofile$</key>
|
|
90
|
+
<dict>
|
|
91
|
+
<key>weight</key>
|
|
92
|
+
<real>20</real>
|
|
93
|
+
</dict>
|
|
94
|
+
<key>^version\.plist$</key>
|
|
95
|
+
<dict>
|
|
96
|
+
<key>weight</key>
|
|
97
|
+
<real>20</real>
|
|
98
|
+
</dict>
|
|
99
|
+
</dict>
|
|
100
|
+
</dict>
|
|
101
|
+
</plist>
|
|
Binary file
|
package/src/index.d.ts
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MERGN SDK for React Native.
|
|
3
|
+
*
|
|
4
|
+
* The same API on Android and iOS: each method resolves with a status string
|
|
5
|
+
* from the native SDK, or rejects with an Error. Requires a native rebuild
|
|
6
|
+
* after install — Expo Go cannot load native modules.
|
|
7
|
+
*/
|
|
8
|
+
declare const Mergn: {
|
|
9
|
+
/** Register your MERGN API key. Call this once, as early as app start. */
|
|
10
|
+
registerApi(apiKey: string): Promise<string>;
|
|
11
|
+
|
|
12
|
+
/** Record an event with optional properties. */
|
|
13
|
+
performEvent(
|
|
14
|
+
eventName: string,
|
|
15
|
+
eventPropertiesMap?: Record<string, unknown>
|
|
16
|
+
): Promise<string>;
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Set a user attribute. Note the SDK de-duplicates: sending the same value
|
|
20
|
+
* again for the same name is intentionally a no-op.
|
|
21
|
+
*/
|
|
22
|
+
setAttribute(attributeName: string, attributeValue: string): Promise<string>;
|
|
23
|
+
|
|
24
|
+
/** Identify the current user, linking their anonymous activity to this id. */
|
|
25
|
+
login(uniqueIdentifier: string): Promise<string>;
|
|
26
|
+
|
|
27
|
+
/** Hand the FCM/APNs registration token to MERGN so it can send pushes. */
|
|
28
|
+
setFirebaseToken(fcmTokenMergn: string): Promise<string>;
|
|
29
|
+
|
|
30
|
+
/** Currently routes to the same native path as setFirebaseToken. */
|
|
31
|
+
setAppContext(fcmTokenMergn: string): Promise<string>;
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
export default Mergn;
|
|
35
|
+
|
|
36
|
+
/** The raw native module. Undefined when the native build is missing. */
|
|
37
|
+
export const MergnModule: unknown;
|
package/src/index.js
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { NativeModules, Platform } from "react-native";
|
|
2
|
+
|
|
3
|
+
export const MergnModule = NativeModules.MergnModule;
|
|
4
|
+
|
|
5
|
+
const call = (method, action, payload) =>
|
|
6
|
+
MergnModule
|
|
7
|
+
? MergnModule.performAction(action, JSON.stringify(payload))
|
|
8
|
+
: Promise.reject(
|
|
9
|
+
new Error(
|
|
10
|
+
`MergnModule.${method} is unavailable: the native module did not load on ${Platform.OS}. ` +
|
|
11
|
+
`Rebuild the app after installing (npx expo prebuild && npx expo run:${Platform.OS}) — ` +
|
|
12
|
+
`Expo Go cannot load native modules.`
|
|
13
|
+
)
|
|
14
|
+
);
|
|
15
|
+
|
|
16
|
+
export default {
|
|
17
|
+
registerApi: (apiKey) => call("registerApi", "register_api", { apiKey }),
|
|
18
|
+
|
|
19
|
+
performEvent: (eventName, eventPropertiesMap = {}) =>
|
|
20
|
+
call("performEvent", "perform_event", { eventName, eventPropertiesMap }),
|
|
21
|
+
|
|
22
|
+
setAttribute: (attributeName, attributeValue) =>
|
|
23
|
+
call("setAttribute", "add_attribute", { attributeName, attributeValue }),
|
|
24
|
+
|
|
25
|
+
login: (uniqueIdentifier) =>
|
|
26
|
+
call("login", "login_mergn", { uniqueIdentifier }),
|
|
27
|
+
|
|
28
|
+
setFirebaseToken: (fcmTokenMergn) =>
|
|
29
|
+
call("setFirebaseToken", "firebase_token_mergn", { fcmTokenMergn }),
|
|
30
|
+
|
|
31
|
+
// Currently routes to the same native path as setFirebaseToken.
|
|
32
|
+
setAppContext: (fcmTokenMergn) =>
|
|
33
|
+
call("setAppContext", "mergn_app_context", { fcmTokenMergn }),
|
|
34
|
+
};
|