react-native-moengage 9.0.0 → 10.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/CHANGELOG.md +32 -0
- package/ReactNativeMoEngage.podspec +7 -3
- package/android/build.gradle +23 -7
- package/android/src/main/java/com/moengage/react/{MoEReactBridge.kt → MoEReactBridgeHandler.kt} +29 -70
- package/android/src/main/java/com/moengage/react/MoEReactPackage.kt +38 -9
- package/android/src/newarch/com/moengage/react/MoEReactBridge.kt +143 -0
- package/android/src/oldarch/com/moengage/react/MoEReactBridge.kt +172 -0
- package/iOS/MoEReactBridge/MoEReactBridge.h +12 -1
- package/iOS/MoEReactBridge/MoEReactBridge.mm +245 -0
- package/iOS/MoEReactBridge/MoEReactNativeHandler.h +36 -0
- package/iOS/MoEReactBridge/MoEReactNativeHandler.m +138 -0
- package/iOS/MoEReactBridge/MoEngageInitializer.h +0 -28
- package/iOS/MoEReactBridge/MoEngageInitializer.m +3 -115
- package/iOS/MoEReactBridge/MoEngageReactPluginInfo.h +1 -1
- package/iOS/MoEReactBridge/MoEngageReactUtils.h +1 -0
- package/iOS/MoEReactBridge/MoEngageReactUtils.m +6 -0
- package/package.json +9 -1
- package/src/NativeMoEngage.ts +201 -0
- package/src/index.ts +195 -302
- package/src/moeParser/MoEngagePayloadParser.ts +1 -1
- package/src/utils/MoEJsonBuilder.ts +23 -22
- package/iOS/MoEReactBridge/MoEReactBridge.m +0 -197
- package/src/platform/MoERNAndroid.ts +0 -172
- package/src/platform/MoERNiOS.ts +0 -91
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2014-2024 MoEngage Inc.
|
|
3
|
+
*
|
|
4
|
+
* All rights reserved.
|
|
5
|
+
*
|
|
6
|
+
* Use of source code or binaries contained within MoEngage SDK is permitted only to enable use of the MoEngage platform by customers of MoEngage.
|
|
7
|
+
* Modification of source code and inclusion in mobile apps is explicitly allowed provided that all other conditions are met.
|
|
8
|
+
* Neither the name of MoEngage nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
|
|
9
|
+
* Redistribution of source code or binaries is disallowed except with specific prior written permission. Any such redistribution must retain the above copyright notice, this list of conditions and the following disclaimer.
|
|
10
|
+
*
|
|
11
|
+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
package com.moengage.react
|
|
15
|
+
|
|
16
|
+
import com.facebook.react.bridge.Promise
|
|
17
|
+
import com.facebook.react.bridge.ReactApplicationContext
|
|
18
|
+
import com.facebook.react.bridge.ReactContextBaseJavaModule
|
|
19
|
+
import com.facebook.react.bridge.ReactMethod
|
|
20
|
+
import com.moengage.core.internal.logger.Logger
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Bridge to communicate with js code in old arch
|
|
24
|
+
*
|
|
25
|
+
* @author Abhishek Kumar
|
|
26
|
+
* @since Todo: Add Version
|
|
27
|
+
*/
|
|
28
|
+
class MoEReactBridge(
|
|
29
|
+
private val reactContext: ReactApplicationContext
|
|
30
|
+
) : ReactContextBaseJavaModule(reactContext) {
|
|
31
|
+
|
|
32
|
+
private val tag = "${MODULE_TAG}MoEReactBridge"
|
|
33
|
+
private val bridgeHandler = MoEReactBridgeHandler(reactContext)
|
|
34
|
+
|
|
35
|
+
override fun getName() = bridgeHandler.getName()
|
|
36
|
+
|
|
37
|
+
@ReactMethod
|
|
38
|
+
fun addListener(eventName: String) {
|
|
39
|
+
// Keep: Required for RN built in Event Emitter Calls.
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
@ReactMethod
|
|
43
|
+
fun removeListeners(count: Int) {
|
|
44
|
+
// Keep: Required for RN built in Event Emitter Calls.
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
@ReactMethod
|
|
48
|
+
fun setAppStatus(payload: String) {
|
|
49
|
+
bridgeHandler.setAppStatus(payload)
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
@ReactMethod
|
|
53
|
+
fun trackEvent(payload: String) {
|
|
54
|
+
bridgeHandler.trackEvent(payload)
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
@ReactMethod
|
|
58
|
+
fun setUserAttribute(payload: String) {
|
|
59
|
+
bridgeHandler.setUserAttribute(payload)
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
@ReactMethod
|
|
63
|
+
fun logout(payload: String) {
|
|
64
|
+
bridgeHandler.logout(payload)
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
@ReactMethod
|
|
68
|
+
fun setAlias(payload: String) {
|
|
69
|
+
bridgeHandler.setAlias(payload)
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
@ReactMethod
|
|
73
|
+
fun setAppContext(payload: String) {
|
|
74
|
+
bridgeHandler.setAppContext(payload)
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
@ReactMethod
|
|
78
|
+
fun resetAppContext(payload: String) {
|
|
79
|
+
bridgeHandler.resetAppContext(payload)
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
@ReactMethod
|
|
83
|
+
fun showInApp(payload: String) {
|
|
84
|
+
bridgeHandler.showInApp(payload)
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
@ReactMethod
|
|
88
|
+
fun getSelfHandledInApp(payload: String) {
|
|
89
|
+
bridgeHandler.getSelfHandledInApp(payload)
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
@ReactMethod
|
|
93
|
+
fun passFcmPushToken(payload: String) {
|
|
94
|
+
bridgeHandler.passPushToken(payload)
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
@ReactMethod
|
|
98
|
+
fun passPushKitPushToken(payload: String) {
|
|
99
|
+
bridgeHandler.passPushToken(payload)
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
@ReactMethod
|
|
103
|
+
fun passFcmPushPayload(payload: String) {
|
|
104
|
+
bridgeHandler.passPushPayload(payload)
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
@ReactMethod
|
|
108
|
+
fun initialize(payload: String) {
|
|
109
|
+
Logger.print { "$tag initializing module in old arch" }
|
|
110
|
+
bridgeHandler.initialize(payload)
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
@ReactMethod
|
|
114
|
+
fun updateSelfHandledInAppStatus(payload: String) {
|
|
115
|
+
bridgeHandler.selfHandledCallback(payload)
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
@ReactMethod
|
|
119
|
+
fun optOutDataTracking(payload: String) {
|
|
120
|
+
bridgeHandler.optOutTracking(payload)
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
@ReactMethod
|
|
124
|
+
fun updateSdkState(payload: String) {
|
|
125
|
+
bridgeHandler.updateSdkState(payload)
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
@ReactMethod
|
|
129
|
+
fun onOrientationChanged() {
|
|
130
|
+
bridgeHandler.onOrientationChanged()
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
@ReactMethod
|
|
134
|
+
fun deviceIdentifierTrackingStatusUpdate(payload: String) {
|
|
135
|
+
bridgeHandler.deviceIdentifierTrackingStatusUpdate(payload)
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
@ReactMethod
|
|
139
|
+
fun setupNotificationChannels() {
|
|
140
|
+
bridgeHandler.setupNotificationChannels()
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
@ReactMethod
|
|
144
|
+
fun navigateToSettingsAndroid() {
|
|
145
|
+
bridgeHandler.navigateToSettings()
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
@ReactMethod
|
|
149
|
+
fun requestPushPermissionAndroid() {
|
|
150
|
+
bridgeHandler.requestPushPermission()
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
@ReactMethod
|
|
154
|
+
fun pushPermissionResponseAndroid(payload: String) {
|
|
155
|
+
bridgeHandler.permissionResponse(payload)
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
@ReactMethod
|
|
159
|
+
fun updatePushPermissionRequestCountAndroid(payload: String) {
|
|
160
|
+
bridgeHandler.updatePushPermissionRequestCount(payload)
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
@ReactMethod
|
|
164
|
+
fun deleteUser(payload: String, promise: Promise) {
|
|
165
|
+
bridgeHandler.deleteUser(payload, promise)
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
@ReactMethod
|
|
169
|
+
fun showNudge(payload: String) {
|
|
170
|
+
bridgeHandler.showNudge(payload)
|
|
171
|
+
}
|
|
172
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
//
|
|
2
|
-
//
|
|
2
|
+
// MoEReactBridges.h
|
|
3
3
|
// MoEngage
|
|
4
4
|
//
|
|
5
5
|
// Created by Chengappa C D on 11/11/16.
|
|
@@ -10,6 +10,17 @@
|
|
|
10
10
|
#import <React/RCTBridgeModule.h>
|
|
11
11
|
#import <React/RCTEventEmitter.h>
|
|
12
12
|
|
|
13
|
+
#ifdef RCT_NEW_ARCH_ENABLED
|
|
14
|
+
#import <NativeMoEngageSpec/NativeMoEngageSpec.h>
|
|
15
|
+
#endif
|
|
16
|
+
|
|
17
|
+
#ifdef RCT_NEW_ARCH_ENABLED
|
|
18
|
+
@interface MoEReactBridge : RCTEventEmitter <NativeMoEngageSpec>
|
|
19
|
+
-(void)sendEventWithName:(NSDictionary *)payloadDict;
|
|
20
|
+
@end
|
|
21
|
+
#else
|
|
13
22
|
@interface MoEReactBridge : RCTEventEmitter <RCTBridgeModule>
|
|
14
23
|
-(void)sendEventWithName:(NSDictionary *)payloadDict;
|
|
15
24
|
@end
|
|
25
|
+
#endif
|
|
26
|
+
|
|
@@ -0,0 +1,245 @@
|
|
|
1
|
+
//
|
|
2
|
+
// MoEReactBridge.m
|
|
3
|
+
// MoEngage
|
|
4
|
+
//
|
|
5
|
+
// Created by Chengappa C D on 11/11/16.
|
|
6
|
+
// Copyright © 2016 MoEngage. All rights reserved.
|
|
7
|
+
//
|
|
8
|
+
|
|
9
|
+
#import "MoEReactBridge.h"
|
|
10
|
+
#import <React/RCTLog.h>
|
|
11
|
+
#import <React/RCTConvert.h>
|
|
12
|
+
#import <React/RCTBundleURLProvider.h>
|
|
13
|
+
#import "MoEngageInitializer.h"
|
|
14
|
+
#import "MoEngageReactConstants.h"
|
|
15
|
+
#import <MoEngageSDK/MoEngageSDK.h>
|
|
16
|
+
#import "MoEReactNativeHandler.h"
|
|
17
|
+
|
|
18
|
+
@interface MoEReactBridge()
|
|
19
|
+
@end
|
|
20
|
+
|
|
21
|
+
@implementation MoEReactBridge
|
|
22
|
+
|
|
23
|
+
{
|
|
24
|
+
bool hasListeners;
|
|
25
|
+
NSMutableArray *delayedEvents;
|
|
26
|
+
}
|
|
27
|
+
RCT_EXPORT_MODULE(MoEReactBridge);
|
|
28
|
+
|
|
29
|
+
- (instancetype)init
|
|
30
|
+
{
|
|
31
|
+
if (self = [super init]) {
|
|
32
|
+
if (delayedEvents == nil)
|
|
33
|
+
delayedEvents = [NSMutableArray array];
|
|
34
|
+
}
|
|
35
|
+
return self;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
+ (BOOL)requiresMainQueueSetup {
|
|
39
|
+
return false;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
#pragma mark- Observers
|
|
43
|
+
// Will be called when this module's first listener is added.
|
|
44
|
+
-(void)startObserving {
|
|
45
|
+
hasListeners = YES;
|
|
46
|
+
[self flushDelayedEvents];
|
|
47
|
+
[MoEReactNativeHandler sharedInstance].reactBridge = self;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
// Will be called when this module's last listener is removed, or on dealloc.
|
|
51
|
+
-(void)stopObserving {
|
|
52
|
+
hasListeners = NO;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
-(void)flushDelayedEvents{
|
|
56
|
+
if (delayedEvents.count > 0){
|
|
57
|
+
for (NSDictionary* payloadDict in delayedEvents){
|
|
58
|
+
[self emitEvent:payloadDict];
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
[delayedEvents removeAllObjects];
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
-(void)sendEventWithName:(NSDictionary *)payloadDict{
|
|
66
|
+
if (hasListeners) {
|
|
67
|
+
[self emitEvent:payloadDict];
|
|
68
|
+
} else {
|
|
69
|
+
[delayedEvents addObject:payloadDict];
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
-(void)emitEvent:(NSDictionary*)payloadDict{
|
|
74
|
+
if (payloadDict){
|
|
75
|
+
NSString* name = payloadDict[kEventName];
|
|
76
|
+
NSDictionary* payload = payloadDict[kPayloadDict];
|
|
77
|
+
if (name != nil && payload != nil) {
|
|
78
|
+
[self sendEventWithName:name body:payload];
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
#pragma mark- Event Emitters
|
|
84
|
+
- (NSArray<NSString *> *)supportedEvents
|
|
85
|
+
{
|
|
86
|
+
return @[kPushClicked, kPushTokenGenerated, kInAppShown, kInAppClicked, kInAppDismissed, kInAppCustomAction, kInAppSelfHandled, kPermissionResult];
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
#pragma mark- Initialization Method
|
|
90
|
+
|
|
91
|
+
RCT_EXPORT_METHOD(initialize:(NSString *)payload) {
|
|
92
|
+
[[MoEReactNativeHandler sharedInstance] initialize:payload];
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
#pragma mark- Set AppStatus
|
|
96
|
+
|
|
97
|
+
RCT_EXPORT_METHOD(setAppStatus:(NSString *)payload) {
|
|
98
|
+
[[MoEReactNativeHandler sharedInstance] setAppStatus:payload];
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
#pragma mark - trackEvent
|
|
102
|
+
|
|
103
|
+
RCT_EXPORT_METHOD(trackEvent:(NSString *)payload) {
|
|
104
|
+
[[MoEReactNativeHandler sharedInstance] trackEvent:payload];
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
#pragma mark- User Attribute Methods
|
|
108
|
+
RCT_EXPORT_METHOD(setUserAttribute:(NSString *)payload) {
|
|
109
|
+
[[MoEReactNativeHandler sharedInstance] setUserAttribute:payload];
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
RCT_EXPORT_METHOD(setAlias:(NSString *)payload) {
|
|
113
|
+
[[MoEReactNativeHandler sharedInstance] setAlias:payload];
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
#pragma mark- Push Notifications
|
|
117
|
+
RCT_EXPORT_METHOD(registerForPush) {
|
|
118
|
+
[[MoEReactNativeHandler sharedInstance] registerForPush];
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
#pragma mark Show InApp
|
|
122
|
+
|
|
123
|
+
RCT_EXPORT_METHOD(showInApp:(NSString *)payload) {
|
|
124
|
+
[[MoEReactNativeHandler sharedInstance] showInApp:payload];
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
#pragma mark Self handled In App
|
|
128
|
+
|
|
129
|
+
RCT_EXPORT_METHOD(getSelfHandledInApp:(NSString *)payload) {
|
|
130
|
+
[[MoEReactNativeHandler sharedInstance] getSelfHandledInApp:payload];
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
RCT_EXPORT_METHOD(updateSelfHandledInAppStatus:(NSString *)payload) {
|
|
134
|
+
[[MoEReactNativeHandler sharedInstance] updateSelfHandledInAppStatus:payload];
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
#pragma mark InApp Contexts
|
|
138
|
+
|
|
139
|
+
RCT_EXPORT_METHOD(setAppContext:(NSString *)payload) {
|
|
140
|
+
[[MoEReactNativeHandler sharedInstance] setAppContext:payload];
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
RCT_EXPORT_METHOD(resetAppContext:(NSString *)payload) {
|
|
144
|
+
[[MoEReactNativeHandler sharedInstance] resetAppContext:payload];
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
#pragma mark- Reset User
|
|
148
|
+
|
|
149
|
+
RCT_EXPORT_METHOD(logout:(NSString *)payload) {
|
|
150
|
+
[[MoEReactNativeHandler sharedInstance] logout:payload];
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
RCT_EXPORT_METHOD(optOutDataTracking:(NSString *)payload) {
|
|
154
|
+
[[MoEReactNativeHandler sharedInstance] optOutDataTracking: payload];
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
RCT_EXPORT_METHOD(showNudge:(NSString *)payload) {
|
|
158
|
+
[[MoEReactNativeHandler sharedInstance] showNudge:payload];
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
RCT_EXPORT_METHOD(updateSdkState:(NSString *)payload) {
|
|
162
|
+
[[MoEReactNativeHandler sharedInstance] updateSdkState:payload];
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
// MARK: Unimplemented method
|
|
166
|
+
|
|
167
|
+
RCT_EXPORT_METHOD(deleteUser:(NSString *)payload) {
|
|
168
|
+
RCTLogInfo(@"Warning: This is an Android only feature.");
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
RCT_EXPORT_METHOD(disableAdIdTracking:(NSString *)payload) {
|
|
172
|
+
RCTLogInfo(@"Warning: This is an Android only feature.");
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
RCT_EXPORT_METHOD(disableAndroidIdTracking:(NSString *)payload) {
|
|
176
|
+
RCTLogInfo(@"Warning: This is an Android only feature.");
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
RCT_EXPORT_METHOD(disableDeviceIdTracking:(NSString *)payload) {
|
|
180
|
+
RCTLogInfo(@"Warning: This is an Android only feature.");
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
RCT_EXPORT_METHOD(disableInbox:(NSString *)payload) {
|
|
184
|
+
RCTLogInfo(@"Warning: This is an Android only feature.");
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
RCT_EXPORT_METHOD(enableAdIdTracking:(NSString *)payload) {
|
|
188
|
+
RCTLogInfo(@"Warning: This is an Android only feature.");
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
RCT_EXPORT_METHOD(enableAndroidIdTracking:(NSString *)payload) {
|
|
192
|
+
RCTLogInfo(@"Warning: This is an Android only feature.");
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
RCT_EXPORT_METHOD(enableDeviceIdTracking:(NSString *)payload) {
|
|
196
|
+
RCTLogInfo(@"Warning: This is an Android only feature.");
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
RCT_EXPORT_METHOD(navigateToSettingsAndroid) {
|
|
200
|
+
RCTLogInfo(@"Warning: This is an Android only feature.");
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
RCT_EXPORT_METHOD(onOrientationChanged) {
|
|
204
|
+
RCTLogInfo(@"Warning: This is an Android only feature.");
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
RCT_EXPORT_METHOD(passFcmPushPayload:(NSString *)payload) {
|
|
208
|
+
RCTLogInfo(@"Warning: This is an Android only feature.");
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
RCT_EXPORT_METHOD(passFcmPushToken:(NSString *)payload) {
|
|
212
|
+
RCTLogInfo(@"Warning: This is an Android only feature.");
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
RCT_EXPORT_METHOD(passPushKitPushToken:(NSString *)payload) {
|
|
216
|
+
RCTLogInfo(@"Warning: This is an Android only feature.");
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
RCT_EXPORT_METHOD(pushPermissionResponseAndroid:(NSString *)payload) {
|
|
220
|
+
RCTLogInfo(@"Warning: This is an Android only feature.");
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
RCT_EXPORT_METHOD(requestPushPermissionAndroid) {
|
|
224
|
+
RCTLogInfo(@"Warning: This is an Android only feature.");
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
RCT_EXPORT_METHOD(setupNotificationChannels) {
|
|
228
|
+
RCTLogInfo(@"Warning: This is an Android only feature.");
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
RCT_EXPORT_METHOD(updatePushPermissionRequestCountAndroid:(NSString *)payload) {
|
|
232
|
+
RCTLogInfo(@"Warning: This is an Android only feature.");
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
RCT_EXPORT_METHOD(deleteUser:(NSString *)payload resolve:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject) {
|
|
236
|
+
RCTLogInfo(@"Warning: This is an Android only feature.");
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
#ifdef RCT_NEW_ARCH_ENABLED
|
|
240
|
+
- (std::shared_ptr<facebook::react::TurboModule>)getTurboModule:(const facebook::react::ObjCTurboModule::InitParams &)params {
|
|
241
|
+
return std::make_shared<facebook::react::NativeMoEngageSpecJSI>(params);
|
|
242
|
+
}
|
|
243
|
+
#endif
|
|
244
|
+
|
|
245
|
+
@end
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
//
|
|
2
|
+
// MoEReactBridgeHandler.h
|
|
3
|
+
// Pods
|
|
4
|
+
//
|
|
5
|
+
// Created by Rakshitha on 04/03/24.
|
|
6
|
+
//
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
#import <Foundation/Foundation.h>
|
|
10
|
+
#import <UIKit/UIKit.h>
|
|
11
|
+
#import <React/RCTEventEmitter.h>
|
|
12
|
+
#import "MoEReactBridge.h"
|
|
13
|
+
|
|
14
|
+
@interface MoEReactNativeHandler : NSObject
|
|
15
|
+
+(instancetype)sharedInstance;
|
|
16
|
+
|
|
17
|
+
@property (nonatomic, weak) MoEReactBridge *reactBridge;
|
|
18
|
+
|
|
19
|
+
-(void)setDelegate:(NSString *)identifier;
|
|
20
|
+
|
|
21
|
+
-(void)initialize:(NSString *)payload;
|
|
22
|
+
-(void)setAppStatus:(NSString *)payload;
|
|
23
|
+
-(void)trackEvent:(NSString *)payload;
|
|
24
|
+
-(void)setUserAttribute:(NSString *)payload;
|
|
25
|
+
-(void)setAlias:(NSString *)payload;
|
|
26
|
+
-(void)registerForPush;
|
|
27
|
+
-(void)showInApp:(NSString *)payload;
|
|
28
|
+
-(void)showNudge:(NSString *)payload ;
|
|
29
|
+
-(void)getSelfHandledInApp:(NSString *)payload;
|
|
30
|
+
-(void)updateSelfHandledInAppStatus:(NSString *)payload;
|
|
31
|
+
-(void)setAppContext:(NSString *)payload;
|
|
32
|
+
-(void)resetAppContext:(NSString *)payload;
|
|
33
|
+
-(void)logout:(NSString *)payload;
|
|
34
|
+
-(void)optOutDataTracking:(NSString *)payload;
|
|
35
|
+
-(void)updateSdkState:(NSString *)payload;
|
|
36
|
+
@end
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
//
|
|
2
|
+
// MoEReactNativeHandler.m
|
|
3
|
+
// ReactNativeMoEngage
|
|
4
|
+
//
|
|
5
|
+
// Created by Rakshitha on 04/03/24.
|
|
6
|
+
//
|
|
7
|
+
|
|
8
|
+
#import <Foundation/Foundation.h>
|
|
9
|
+
#import "MoEReactNativeHandler.h"
|
|
10
|
+
#import "MoEngageReactUtils.h"
|
|
11
|
+
#import "MoEngageReactConstants.h"
|
|
12
|
+
|
|
13
|
+
@import MoEngagePluginBase;
|
|
14
|
+
|
|
15
|
+
@interface MoEReactNativeHandler() <MoEngagePluginBridgeDelegate>
|
|
16
|
+
@end
|
|
17
|
+
|
|
18
|
+
@implementation MoEReactNativeHandler : NSObject
|
|
19
|
+
|
|
20
|
+
+(instancetype)sharedInstance{
|
|
21
|
+
static dispatch_once_t onceToken;
|
|
22
|
+
static MoEReactNativeHandler *instance;
|
|
23
|
+
dispatch_once(&onceToken, ^{
|
|
24
|
+
instance = [[MoEReactNativeHandler alloc] init];
|
|
25
|
+
});
|
|
26
|
+
return instance;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
-(void)setDelegate:(NSString *)identifier {
|
|
30
|
+
[[MoEngagePluginBridge sharedInstance] setPluginBridgeDelegate:self identifier:identifier];
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
#pragma mark- Initialize methods
|
|
34
|
+
|
|
35
|
+
-(void)initialize:(NSString *)payload {
|
|
36
|
+
NSDictionary* jsonPayload = [MoEngageReactUtils getJSONRepresentation:payload];
|
|
37
|
+
[[MoEngagePluginBridge sharedInstance] pluginInitialized:jsonPayload];
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
#pragma mark- Set AppStatus
|
|
41
|
+
-(void)setAppStatus:(NSString *)payload {
|
|
42
|
+
NSDictionary* jsonPayload = [MoEngageReactUtils getJSONRepresentation:payload];
|
|
43
|
+
[[MoEngagePluginBridge sharedInstance] setAppStatus:jsonPayload];
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
#pragma mark - trackEvent
|
|
47
|
+
|
|
48
|
+
-(void)trackEvent:(NSString *)payload {
|
|
49
|
+
NSDictionary* jsonPayload = [MoEngageReactUtils getJSONRepresentation:payload];
|
|
50
|
+
[[MoEngagePluginBridge sharedInstance] trackEvent:jsonPayload];
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
#pragma mark- User Attribute Methods
|
|
54
|
+
-(void)setUserAttribute:(NSString *)payload {
|
|
55
|
+
NSDictionary* jsonPayload = [MoEngageReactUtils getJSONRepresentation:payload];
|
|
56
|
+
[[MoEngagePluginBridge sharedInstance] setUserAttribute:jsonPayload];
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
-(void)setAlias:(NSString *)payload {
|
|
60
|
+
NSDictionary* jsonPayload = [MoEngageReactUtils getJSONRepresentation:payload];
|
|
61
|
+
[[MoEngagePluginBridge sharedInstance] setAlias:jsonPayload];
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
#pragma mark- Push Notifications
|
|
65
|
+
-(void)registerForPush {
|
|
66
|
+
[[MoEngagePluginBridge sharedInstance] registerForPush];
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
#pragma mark Show InApp
|
|
70
|
+
-(void)showInApp:(NSString *)payload {
|
|
71
|
+
NSDictionary* jsonPayload = [MoEngageReactUtils getJSONRepresentation:payload];
|
|
72
|
+
[[MoEngagePluginBridge sharedInstance] showInApp:jsonPayload];
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
#pragma mark Self handled In App
|
|
76
|
+
-(void)getSelfHandledInApp:(NSString *)payload {
|
|
77
|
+
NSDictionary* jsonPayload = [MoEngageReactUtils getJSONRepresentation:payload];
|
|
78
|
+
[[MoEngagePluginBridge sharedInstance] getSelfHandledInApp:jsonPayload];
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
-(void)updateSelfHandledInAppStatus:(NSString *)payload {
|
|
82
|
+
NSDictionary* jsonPayload = [MoEngageReactUtils getJSONRepresentation:payload];
|
|
83
|
+
[[MoEngagePluginBridge sharedInstance] updateSelfHandledImpression:jsonPayload];
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
#pragma mark InApp Contexts
|
|
87
|
+
|
|
88
|
+
-(void)setAppContext:(NSString *)payload {
|
|
89
|
+
NSDictionary* jsonPayload = [MoEngageReactUtils getJSONRepresentation:payload];
|
|
90
|
+
[[MoEngagePluginBridge sharedInstance] setInAppContext:jsonPayload];
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
-(void)resetAppContext:(NSString *)payload {
|
|
94
|
+
NSDictionary* jsonPayload = [MoEngageReactUtils getJSONRepresentation:payload];
|
|
95
|
+
[[MoEngagePluginBridge sharedInstance] resetInAppContext:jsonPayload];
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
#pragma mark- Reset User
|
|
99
|
+
-(void)logout:(NSString *)payload {
|
|
100
|
+
NSDictionary* jsonPayload = [MoEngageReactUtils getJSONRepresentation:payload];
|
|
101
|
+
[[MoEngagePluginBridge sharedInstance] resetUser:jsonPayload];
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
-(void)optOutDataTracking:(NSString *)payload {
|
|
105
|
+
NSDictionary* jsonPayload = [MoEngageReactUtils getJSONRepresentation:payload];
|
|
106
|
+
[[MoEngagePluginBridge sharedInstance] optOutDataTracking:jsonPayload];
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
-(void)showNudge:(NSString *)payload {
|
|
110
|
+
NSDictionary* jsonPayload = [MoEngageReactUtils getJSONRepresentation:payload];
|
|
111
|
+
[[MoEngagePluginBridge sharedInstance] showNudge:jsonPayload];
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
-(void)updateSdkState:(NSString *)payload {
|
|
115
|
+
NSDictionary* jsonPayload = [MoEngageReactUtils getJSONRepresentation:payload];
|
|
116
|
+
[[MoEngagePluginBridge sharedInstance] updateSDKState:jsonPayload];
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
#pragma mark- Delegate Method
|
|
120
|
+
- (void)sendMessageWithEvent:(NSString *)event message:(NSDictionary<NSString *,id> *)message {
|
|
121
|
+
NSMutableDictionary* updatedDict = [NSMutableDictionary dictionary];
|
|
122
|
+
|
|
123
|
+
if (message) {
|
|
124
|
+
NSError *err;
|
|
125
|
+
NSData * jsonData = [NSJSONSerialization dataWithJSONObject:message options:0 error:&err];
|
|
126
|
+
if (jsonData) {
|
|
127
|
+
NSString* strPayload = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
|
|
128
|
+
updatedDict[kPayload] = strPayload;
|
|
129
|
+
} else {
|
|
130
|
+
NSLog(@"Error converting to dictionary to string %@", err.localizedDescription);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
NSDictionary* userInfo = @{kEventName:event,kPayloadDict:updatedDict};
|
|
135
|
+
[self.reactBridge sendEventWithName:userInfo];
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
@end
|
|
@@ -17,26 +17,6 @@ NS_ASSUME_NONNULL_BEGIN
|
|
|
17
17
|
|
|
18
18
|
+(instancetype)sharedInstance;
|
|
19
19
|
|
|
20
|
-
/// Initialization Methods to setup SDK with configuration parameters from Info.plist file
|
|
21
|
-
/// @param launchOptions Launch Options dictionary
|
|
22
|
-
/// @warning Make sure to call only one of the initialization methods available (either with plist OR with MoEngageSDKConfig instance)
|
|
23
|
-
/// @version 8.0.0 and above
|
|
24
|
-
- (void)initializeDefaultInstance:(NSDictionary*)launchOptions;
|
|
25
|
-
|
|
26
|
-
/// Initialization Methods to setup SDK with configuration parameters from Info.plist file
|
|
27
|
-
/// @param sdkState MoEngageSDKState enum indicating if SDK is Enabled/Disabled, refer (link)[https://docs.moengage.com/docs/gdpr-compliance-1#enabledisable-sdk] for more info
|
|
28
|
-
/// @param launchOptions Launch Options dictionary
|
|
29
|
-
/// @warning Make sure to call only one of the initialization methods available (either with plist OR with MoEngageSDKConfig instance)
|
|
30
|
-
/// @version 8.1.0 and above
|
|
31
|
-
- (void)initializeDefaultInstanceWithState:(MoEngageSDKState)sdkState andLaunchOptions:(NSDictionary*)launchOptions;
|
|
32
|
-
|
|
33
|
-
/// Initialization Methods to setup SDK with configuration parameters from Info.plist file
|
|
34
|
-
/// @param isSdkEnabled Bool indicating if SDK is Enabled/Disabled, refer (link)[https://docs.moengage.com/docs/gdpr-compliance-1#enabledisable-sdk] for more info
|
|
35
|
-
/// @param launchOptions Launch Options dictionary
|
|
36
|
-
/// @warning Make sure to call only one of the initialization methods available (either with plist OR with MOSDKConfig instance)
|
|
37
|
-
/// @version 8.0.0 and above
|
|
38
|
-
- (void)initializeDefaultInstance:(BOOL)isSdkEnabled andLaunchOptions:(NSDictionary*)launchOptions __deprecated_msg("Use initializeDefaultInstanceWithState:andLaunchOptions instead.");
|
|
39
|
-
|
|
40
20
|
/// Initialization Methods to setup SDK with MoEngageSDKConfig instance instead of from Info.plist file
|
|
41
21
|
/// @param sdkConfig MoEngageSDKConfig instance for SDK configuration
|
|
42
22
|
/// @param launchOptions Launch Options dictionary
|
|
@@ -51,14 +31,6 @@ NS_ASSUME_NONNULL_BEGIN
|
|
|
51
31
|
/// @warning Make sure to call only one of the initialization methods available (either with plist OR with MOSDKConfig instance)
|
|
52
32
|
/// @version 8.1.0 and above
|
|
53
33
|
- (void)initializeDefaultSDKConfigWithState:(MoEngageSDKConfig*)sdkConfig withSDKState:(MoEngageSDKState)sdkState andLaunchOptions:(NSDictionary*)launchOptions;
|
|
54
|
-
|
|
55
|
-
/// Initialization Methods to setup SDK with MoEngageSDKConfig instance instead of from Info.plist file
|
|
56
|
-
/// @param sdkConfig MoEngageSDKConfig instance for SDK configuration
|
|
57
|
-
/// @param isSdkEnabled Bool indicating if SDK is Enabled/Disabled, refer (link)[https://docs.moengage.com/docs/gdpr-compliance-1#enabledisable-sdk] for more info
|
|
58
|
-
/// @param launchOptions Launch Options dictionary
|
|
59
|
-
/// @warning Make sure to call only one of the initialization methods available (either with plist OR with MOSDKConfig instance)
|
|
60
|
-
/// @version 8.0.0 and above
|
|
61
|
-
- (void)initializeDefaultSDKConfig:(MoEngageSDKConfig*)sdkConfig withSDKState:(BOOL)isSdkEnabled andLaunchOptions:(NSDictionary*)launchOptions __deprecated_msg("Use initializeDefaultSDKConfigWithState:andLaunchOptions instead.");
|
|
62
34
|
@end
|
|
63
35
|
|
|
64
36
|
NS_ASSUME_NONNULL_END
|