react-native-moengage 7.4.1 → 8.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 +53 -1
- package/ReactNativeMoEngage.podspec +3 -3
- package/android/build.gradle +11 -12
- package/android/gradle/wrapper/gradle-wrapper.properties +3 -3
- package/android/gradle.properties +0 -1
- package/android/src/main/java/com/moengage/react/EventEmitterImpl.kt +46 -21
- package/android/src/main/java/com/moengage/react/MoEInitializer.kt +44 -13
- package/android/src/main/java/com/moengage/react/MoEReactBridge.kt +82 -85
- package/android/src/main/java/com/moengage/react/MoEReactHelper.kt +2 -2
- package/android/src/main/java/com/moengage/react/PayloadGenerator.kt +32 -17
- package/iOS/MoEReactBridge/MoEReactBridge.h +1 -1
- package/iOS/MoEReactBridge/MoEReactBridge.m +34 -60
- package/iOS/MoEReactBridge/{MOReactInitializer.h → MoEngageInitializer.h} +11 -11
- package/iOS/MoEReactBridge/MoEngageInitializer.m +153 -0
- package/iOS/MoEReactBridge/{MoEReactConstants.h → MoEngageReactConstants.h} +12 -3
- package/iOS/MoEReactBridge/{MoEReactConstants.m → MoEngageReactConstants.m} +13 -7
- package/iOS/MoEReactBridge/MoEngageReactPluginInfo.h +2 -0
- package/iOS/MoEReactBridge.xcodeproj/project.pbxproj +6 -6
- package/package.json +8 -3
- package/src/index.ts +134 -203
- package/src/models/MoEAccountMeta.ts +8 -0
- package/src/models/MoEAction.ts +4 -0
- package/src/models/MoEActionType.ts +4 -0
- package/src/models/MoECampaignContext.ts +10 -0
- package/src/models/MoECampaignData.ts +14 -0
- package/src/models/MoEClickData.ts +18 -0
- package/src/models/MoEGeoLocation.ts +2 -10
- package/src/models/MoEInAppCustomAction.ts +8 -13
- package/src/models/MoEInAppData.ts +16 -0
- package/src/models/MoEInAppNavigation.ts +14 -24
- package/src/models/MoENavigationType.ts +4 -0
- package/src/models/MoEPlatform.ts +4 -0
- package/src/models/MoEProperties.ts +19 -15
- package/src/models/MoEPushCampaign.ts +6 -22
- package/src/models/MoEPushPayload.ts +14 -0
- package/src/models/MoEPushService.ts +4 -4
- package/src/models/MoEPushToken.ts +6 -15
- package/src/models/MoESelfHandledCampaign.ts +10 -0
- package/src/models/MoESelfHandledCampaignData.ts +18 -0
- package/src/moeParser/MoEInAppParser.ts +192 -0
- package/src/moeParser/MoEPushNotificationParser.ts +78 -0
- package/src/platform/MoERNAndroid.ts +36 -92
- package/src/platform/MoERNiOS.ts +27 -60
- package/src/utils/MoEConstants.ts +59 -0
- package/src/utils/MoEEventHandlerHelper.ts +38 -25
- package/src/utils/MoEJsonBuilder.ts +220 -0
- package/src/utils/MoEObjectToJson.ts +44 -0
- package/iOS/MoEReactBridge/MOReactInitializer.m +0 -172
- package/iOS/MoEReactBridge/MOReactPluginInfo.h +0 -2
- package/src/models/MoEInAppCampaign.ts +0 -46
- package/src/models/MoEInAppSelfHandledCampaign.ts +0 -34
|
@@ -3,43 +3,58 @@ package com.moengage.react
|
|
|
3
3
|
import com.facebook.react.bridge.Arguments
|
|
4
4
|
import com.facebook.react.bridge.WritableMap
|
|
5
5
|
import com.moengage.core.internal.logger.Logger
|
|
6
|
-
import com.moengage.inapp.model.
|
|
7
|
-
import com.moengage.
|
|
8
|
-
import com.moengage.
|
|
9
|
-
import com.moengage.plugin.base.
|
|
10
|
-
import com.moengage.plugin.base.model.
|
|
11
|
-
import com.moengage.plugin.base.
|
|
12
|
-
import com.moengage.plugin.base.pushTokenToJson
|
|
6
|
+
import com.moengage.inapp.model.ClickData
|
|
7
|
+
import com.moengage.inapp.model.InAppData
|
|
8
|
+
import com.moengage.inapp.model.SelfHandledCampaignData
|
|
9
|
+
import com.moengage.plugin.base.internal.*
|
|
10
|
+
import com.moengage.plugin.base.internal.model.PushPayload
|
|
11
|
+
import com.moengage.plugin.base.internal.model.events.push.TokenEvent
|
|
13
12
|
|
|
14
13
|
/**
|
|
15
14
|
* @author Umang Chamaria
|
|
16
15
|
* Date: 2020/07/29
|
|
17
16
|
*/
|
|
18
|
-
class PayloadGenerator {
|
|
17
|
+
internal class PayloadGenerator {
|
|
19
18
|
|
|
20
19
|
private val tag = "${MODULE_TAG}PayloadGenerator"
|
|
21
20
|
|
|
22
21
|
fun pushPayloadToWriteableMap(payload: PushPayload): WritableMap {
|
|
23
22
|
val map = Arguments.createMap()
|
|
24
23
|
val pushJson = pushPayloadToJson(payload)
|
|
25
|
-
Logger.
|
|
24
|
+
Logger.print { "$tag pushPayloadToWriteableMap() : $pushJson" }
|
|
26
25
|
map.putString(ARGUMENT_PAYLOAD, pushJson.toString())
|
|
27
26
|
return map
|
|
28
27
|
}
|
|
29
28
|
|
|
30
|
-
fun
|
|
29
|
+
fun tokenToWriteableMap(pushToken: TokenEvent) : WritableMap{
|
|
31
30
|
val map = Arguments.createMap()
|
|
32
|
-
val
|
|
33
|
-
Logger.
|
|
34
|
-
map.putString(ARGUMENT_PAYLOAD,
|
|
31
|
+
val tokenJson = tokenEventToJson(pushToken)
|
|
32
|
+
Logger.print { "$tag tokenToWriteableMap() : $tokenJson" }
|
|
33
|
+
map.putString(ARGUMENT_PAYLOAD, tokenJson.toString())
|
|
35
34
|
return map
|
|
36
35
|
}
|
|
37
36
|
|
|
38
|
-
fun
|
|
37
|
+
fun inAppNavigationToWriteableMap(clickData: ClickData): WritableMap {
|
|
39
38
|
val map = Arguments.createMap()
|
|
40
|
-
val
|
|
41
|
-
Logger.
|
|
42
|
-
map.putString(ARGUMENT_PAYLOAD,
|
|
39
|
+
val json = clickDataToJson(clickData)
|
|
40
|
+
Logger.print { "$tag inAppNavigationToWriteableMap() : $json" }
|
|
41
|
+
map.putString(ARGUMENT_PAYLOAD, json.toString())
|
|
42
|
+
return map
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
fun inAppDataToWriteableMap(inAppData: InAppData): WritableMap {
|
|
46
|
+
val map = Arguments.createMap()
|
|
47
|
+
val json = inAppDataToJson(inAppData)
|
|
48
|
+
Logger.print { "$tag inAppDataToWriteableMap() : $json" }
|
|
49
|
+
map.putString(ARGUMENT_PAYLOAD, json.toString())
|
|
50
|
+
return map
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
fun selfHandledDataToWriteableMap(data: SelfHandledCampaignData): WritableMap {
|
|
54
|
+
val map = Arguments.createMap()
|
|
55
|
+
val json = selfHandledDataToJson(data)
|
|
56
|
+
Logger.print { "$tag selfHandledDataToWriteableMap() : $data" }
|
|
57
|
+
map.putString(ARGUMENT_PAYLOAD, json.toString())
|
|
43
58
|
return map
|
|
44
59
|
}
|
|
45
60
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
//
|
|
2
|
-
//
|
|
2
|
+
// MoEReactBridge.m
|
|
3
3
|
// MoEngage
|
|
4
4
|
//
|
|
5
5
|
// Created by Chengappa C D on 11/11/16.
|
|
@@ -10,10 +10,10 @@
|
|
|
10
10
|
#import <React/RCTLog.h>
|
|
11
11
|
#import <React/RCTConvert.h>
|
|
12
12
|
#import <React/RCTBundleURLProvider.h>
|
|
13
|
-
#import
|
|
14
|
-
#import
|
|
15
|
-
|
|
16
|
-
|
|
13
|
+
#import "MoEngageInitializer.h"
|
|
14
|
+
#import "MoEngageReactConstants.h"
|
|
15
|
+
@import MoEngagePluginBase;
|
|
16
|
+
@import MoEngageSDK;
|
|
17
17
|
|
|
18
18
|
@interface MoEReactBridge()
|
|
19
19
|
@end
|
|
@@ -91,129 +91,103 @@
|
|
|
91
91
|
#pragma mark- Event Emitters
|
|
92
92
|
- (NSArray<NSString *> *)supportedEvents
|
|
93
93
|
{
|
|
94
|
-
return @[
|
|
94
|
+
return @[kPushClicked, kPushTokenGenerated, kInAppShown, kInAppClicked, kInAppDismissed, kInAppCustomAction, kInAppSelfHandled];
|
|
95
95
|
}
|
|
96
96
|
|
|
97
97
|
RCT_EXPORT_MODULE();
|
|
98
98
|
|
|
99
99
|
#pragma mark- Initialization Method
|
|
100
100
|
|
|
101
|
-
RCT_EXPORT_METHOD(initialize)
|
|
101
|
+
RCT_EXPORT_METHOD(initialize:(NSDictionary *)payload)
|
|
102
102
|
{
|
|
103
|
-
[[
|
|
103
|
+
[[MoEngagePluginBridge sharedInstance] pluginInitialized:payload];
|
|
104
104
|
}
|
|
105
105
|
|
|
106
106
|
#pragma mark- Set AppStatus
|
|
107
107
|
|
|
108
|
-
RCT_EXPORT_METHOD(setAppStatus:(NSDictionary *)
|
|
108
|
+
RCT_EXPORT_METHOD(setAppStatus:(NSDictionary *)payload)
|
|
109
109
|
{
|
|
110
|
-
[[
|
|
110
|
+
[[MoEngagePluginBridge sharedInstance] setAppStatus:payload];
|
|
111
111
|
}
|
|
112
112
|
|
|
113
113
|
#pragma mark - trackEvent
|
|
114
114
|
|
|
115
|
-
RCT_EXPORT_METHOD(trackEventWithProperties:(NSDictionary *)
|
|
115
|
+
RCT_EXPORT_METHOD(trackEventWithProperties:(NSDictionary *)payload)
|
|
116
116
|
{
|
|
117
|
-
[[
|
|
117
|
+
[[MoEngagePluginBridge sharedInstance] trackEvent:payload];
|
|
118
118
|
}
|
|
119
119
|
|
|
120
120
|
#pragma mark- User Attribute Methods
|
|
121
|
-
|
|
122
|
-
RCT_EXPORT_METHOD(setUserAttribute:(NSDictionary *)userAttributeDict)
|
|
121
|
+
RCT_EXPORT_METHOD(setUserAttribute:(NSDictionary *)payload)
|
|
123
122
|
{
|
|
124
|
-
[[
|
|
123
|
+
[[MoEngagePluginBridge sharedInstance] setUserAttribute:payload];
|
|
125
124
|
}
|
|
126
125
|
|
|
127
|
-
RCT_EXPORT_METHOD(setAlias:(NSDictionary *)
|
|
126
|
+
RCT_EXPORT_METHOD(setAlias:(NSDictionary *)payload)
|
|
128
127
|
{
|
|
129
|
-
[[
|
|
128
|
+
[[MoEngagePluginBridge sharedInstance] setAlias:payload];
|
|
130
129
|
}
|
|
131
130
|
|
|
132
131
|
#pragma mark- Push Notifications
|
|
133
|
-
|
|
134
132
|
RCT_EXPORT_METHOD(registerForPushNotification)
|
|
135
133
|
{
|
|
136
|
-
[[
|
|
134
|
+
[[MoEngagePluginBridge sharedInstance] registerForPush];
|
|
137
135
|
}
|
|
138
136
|
|
|
139
|
-
#pragma mark Disable Inbox
|
|
140
|
-
|
|
141
|
-
RCT_EXPORT_METHOD(disableInbox)
|
|
142
|
-
{
|
|
143
|
-
[MOMessaging sharedInstance].disableInbox = YES;
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
#pragma mark- inApp Methods
|
|
147
137
|
#pragma mark Show InApp
|
|
148
138
|
|
|
149
|
-
RCT_EXPORT_METHOD(showInApp)
|
|
139
|
+
RCT_EXPORT_METHOD(showInApp:(NSDictionary *)payload)
|
|
150
140
|
{
|
|
151
|
-
[[
|
|
141
|
+
[[MoEngagePluginBridge sharedInstance] showInApp:payload];
|
|
152
142
|
}
|
|
153
143
|
|
|
154
144
|
#pragma mark Self handled In App
|
|
155
145
|
|
|
156
|
-
RCT_EXPORT_METHOD(getSelfHandledInApp)
|
|
146
|
+
RCT_EXPORT_METHOD(getSelfHandledInApp:(NSDictionary *)payload)
|
|
157
147
|
{
|
|
158
|
-
[[
|
|
148
|
+
[[MoEngagePluginBridge sharedInstance] getSelfHandledInApp:payload];
|
|
159
149
|
}
|
|
160
150
|
|
|
161
|
-
RCT_EXPORT_METHOD(updateSelfHandledInAppStatusWithPayload:(NSDictionary *)
|
|
162
|
-
[[
|
|
151
|
+
RCT_EXPORT_METHOD(updateSelfHandledInAppStatusWithPayload:(NSDictionary *)payload) {
|
|
152
|
+
[[MoEngagePluginBridge sharedInstance] updateSelfHandledImpression:payload];
|
|
163
153
|
}
|
|
164
154
|
|
|
165
155
|
#pragma mark InApp Contexts
|
|
166
156
|
|
|
167
|
-
RCT_EXPORT_METHOD(setAppContext:(nonnull NSDictionary *)
|
|
157
|
+
RCT_EXPORT_METHOD(setAppContext:(nonnull NSDictionary *)payload)
|
|
168
158
|
{
|
|
169
|
-
[[
|
|
159
|
+
[[MoEngagePluginBridge sharedInstance] setInAppContext:payload];
|
|
170
160
|
}
|
|
171
161
|
|
|
172
|
-
RCT_EXPORT_METHOD(resetAppContext)
|
|
162
|
+
RCT_EXPORT_METHOD(resetAppContext:(NSDictionary *)payload)
|
|
173
163
|
{
|
|
174
|
-
[[
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
#pragma mark- Enable SDK Logs
|
|
179
|
-
|
|
180
|
-
RCT_EXPORT_METHOD(enableSDKLogs)
|
|
181
|
-
{
|
|
182
|
-
[[MoEPluginBridge sharedInstance] enableLogs];
|
|
164
|
+
[[MoEngagePluginBridge sharedInstance] resetInAppContext:payload];
|
|
183
165
|
}
|
|
184
166
|
|
|
185
167
|
#pragma mark- Reset User
|
|
186
168
|
|
|
187
|
-
RCT_EXPORT_METHOD(logout)
|
|
169
|
+
RCT_EXPORT_METHOD(logout:(NSDictionary *)payload)
|
|
188
170
|
{
|
|
189
|
-
[[
|
|
171
|
+
[[MoEngagePluginBridge sharedInstance] resetUser:payload];
|
|
190
172
|
}
|
|
191
173
|
|
|
192
|
-
#pragma mark- Validate App version
|
|
193
|
-
|
|
194
174
|
RCT_EXPORT_METHOD(validateSDKVersion:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject)
|
|
195
175
|
{
|
|
196
|
-
if ([[
|
|
176
|
+
if ([[MoEngagePluginBridge sharedInstance] validateSDKVersion]) {
|
|
197
177
|
resolve([NSNumber numberWithBool:YES]);
|
|
198
178
|
} else {
|
|
199
179
|
reject(NULL, @"MoEngage: Unsupported SDK version", NULL);
|
|
200
180
|
}
|
|
201
181
|
}
|
|
202
182
|
|
|
203
|
-
#pragma mark- GeoFence Monitoring
|
|
204
|
-
RCT_EXPORT_METHOD(startGeofenceMonitoring) {
|
|
205
|
-
// Init Geofence if included
|
|
206
|
-
[[MoEPluginBridge sharedInstance] startGeofenceMonitoring];
|
|
207
|
-
}
|
|
208
|
-
|
|
209
183
|
#pragma mark- Opt out Tracking
|
|
210
|
-
RCT_EXPORT_METHOD(optOutTracking:(nonnull NSDictionary *)
|
|
211
|
-
[[
|
|
184
|
+
RCT_EXPORT_METHOD(optOutTracking:(nonnull NSDictionary *)payload) {
|
|
185
|
+
[[MoEngagePluginBridge sharedInstance] optOutDataTracking:payload];
|
|
212
186
|
}
|
|
213
187
|
|
|
214
188
|
#pragma mark- Update SDK State
|
|
215
|
-
RCT_EXPORT_METHOD(updateSDKState:(nonnull NSDictionary *)
|
|
216
|
-
[[
|
|
189
|
+
RCT_EXPORT_METHOD(updateSDKState:(nonnull NSDictionary *)payload) {
|
|
190
|
+
[[MoEngagePluginBridge sharedInstance] updateSDKState:payload];
|
|
217
191
|
}
|
|
218
192
|
|
|
219
193
|
@end
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
//
|
|
2
|
-
//
|
|
2
|
+
// MoEngageInitializer.h
|
|
3
3
|
// ReactNativeMoEngage
|
|
4
4
|
//
|
|
5
5
|
// Created by Chengappa C D on 14/02/20.
|
|
@@ -7,40 +7,40 @@
|
|
|
7
7
|
|
|
8
8
|
#import <Foundation/Foundation.h>
|
|
9
9
|
#import <UIKit/UIKit.h>
|
|
10
|
-
|
|
10
|
+
@import MoEngageSDK;
|
|
11
11
|
NS_ASSUME_NONNULL_BEGIN
|
|
12
12
|
|
|
13
|
-
@interface
|
|
13
|
+
@interface MoEngageInitializer : NSObject
|
|
14
14
|
|
|
15
15
|
+(instancetype)sharedInstance;
|
|
16
16
|
|
|
17
17
|
/// Initialization Methods to setup SDK with configuration parameters from Info.plist file
|
|
18
18
|
/// @param launchOptions Launch Options dictionary
|
|
19
19
|
/// @warning Make sure to call only one of the initialization methods available (either with plist OR with MOSDKConfig instance)
|
|
20
|
-
/// @version
|
|
21
|
-
- (void)
|
|
20
|
+
/// @version 8.0.0 and above
|
|
21
|
+
- (void)initializeDefaultInstance:(NSDictionary*)launchOptions;
|
|
22
22
|
|
|
23
23
|
/// Initialization Methods to setup SDK with configuration parameters from Info.plist file
|
|
24
24
|
/// @param isSdkEnabled Bool indicating if SDK is Enabled/Disabled, refer (link)[https://docs.moengage.com/docs/gdpr-compliance-1#enabledisable-sdk] for more info
|
|
25
25
|
/// @param launchOptions Launch Options dictionary
|
|
26
26
|
/// @warning Make sure to call only one of the initialization methods available (either with plist OR with MOSDKConfig instance)
|
|
27
|
-
/// @version
|
|
28
|
-
- (void)
|
|
27
|
+
/// @version 8.0.0 and above
|
|
28
|
+
- (void)initializeDefaultInstance:(BOOL)isSdkEnabled andLaunchOptions:(NSDictionary*)launchOptions;
|
|
29
29
|
|
|
30
30
|
/// Initialization Methods to setup SDK with MOSDKConfig instance instead of from Info.plist file
|
|
31
31
|
/// @param sdkConfig MOSDKConfig instance for SDK configuration
|
|
32
32
|
/// @param launchOptions Launch Options dictionary
|
|
33
33
|
/// @warning Make sure to call only one of the initialization methods available (either with plist OR with MOSDKConfig instance)
|
|
34
|
-
/// @version
|
|
35
|
-
- (void)
|
|
34
|
+
/// @version 8.0.0 and above
|
|
35
|
+
- (void)initializeDefaultSDKConfig:(MOSDKConfig*)sdkConfig andLaunchOptions:(NSDictionary*)launchOptions;
|
|
36
36
|
|
|
37
37
|
/// Initialization Methods to setup SDK with MOSDKConfig instance instead of from Info.plist file
|
|
38
38
|
/// @param sdkConfig MOSDKConfig instance for SDK configuration
|
|
39
39
|
/// @param isSdkEnabled Bool indicating if SDK is Enabled/Disabled, refer (link)[https://docs.moengage.com/docs/gdpr-compliance-1#enabledisable-sdk] for more info
|
|
40
40
|
/// @param launchOptions Launch Options dictionary
|
|
41
41
|
/// @warning Make sure to call only one of the initialization methods available (either with plist OR with MOSDKConfig instance)
|
|
42
|
-
/// @version
|
|
43
|
-
- (void)
|
|
42
|
+
/// @version 8.0.0 and above
|
|
43
|
+
- (void)initializeDefaultSDKConfig:(MOSDKConfig*)sdkConfig withSDKState:(BOOL)isSdkEnabled andLaunchOptions:(NSDictionary*)launchOptions;
|
|
44
44
|
@end
|
|
45
45
|
|
|
46
46
|
NS_ASSUME_NONNULL_END
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
//
|
|
2
|
+
// MoEngageReact.m
|
|
3
|
+
// ReactNativeMoEngage
|
|
4
|
+
//
|
|
5
|
+
// Created by Chengappa C D on 14/02/20.
|
|
6
|
+
//
|
|
7
|
+
|
|
8
|
+
#import "MoEngageInitializer.h"
|
|
9
|
+
#import "MoEngageReactPluginInfo.h"
|
|
10
|
+
#import "MoEngageReactConstants.h"
|
|
11
|
+
#import "MoEReactBridge.h"
|
|
12
|
+
@import MoEngageSDK;
|
|
13
|
+
@import MoEngagePluginBase;
|
|
14
|
+
@import MoEngageObjCUtils;
|
|
15
|
+
|
|
16
|
+
@interface MoEngageInitializer() <MoEngagePluginBridgeDelegate>
|
|
17
|
+
|
|
18
|
+
@end
|
|
19
|
+
|
|
20
|
+
@implementation MoEngageInitializer
|
|
21
|
+
|
|
22
|
+
#pragma mark- Initialization
|
|
23
|
+
|
|
24
|
+
+(instancetype)sharedInstance{
|
|
25
|
+
static dispatch_once_t onceToken;
|
|
26
|
+
static MoEngageInitializer *instance;
|
|
27
|
+
dispatch_once(&onceToken, ^{
|
|
28
|
+
instance = [[MoEngageInitializer alloc] init];
|
|
29
|
+
});
|
|
30
|
+
return instance;
|
|
31
|
+
}
|
|
32
|
+
#pragma mark- Initialization methods
|
|
33
|
+
|
|
34
|
+
- (void)initializeDefaultInstance:(NSDictionary*)launchOptions{
|
|
35
|
+
[self initializeDefaultSDKConfig:[self fetchSDKConfig] andLaunchOptions:launchOptions];
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
- (void)initializeDefaultSDKConfig:(MOSDKConfig*)sdkConfig andLaunchOptions:(NSDictionary*)launchOptions{
|
|
39
|
+
MoEngagePlugin *plugin = [[MoEngagePlugin alloc] init];
|
|
40
|
+
[plugin initializeDefaultInstanceWithSdkConfig:sdkConfig launchOptions:launchOptions];
|
|
41
|
+
[self commonSetUp:plugin identifier:sdkConfig.identifier];
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
- (void)initializeDefaultInstance:(BOOL)isSdkEnabled andLaunchOptions:(NSDictionary*)launchOptions{
|
|
45
|
+
MOSDKConfig *sdkConfig = [self fetchSDKConfig];
|
|
46
|
+
[self initializeDefaultSDKConfig:sdkConfig withSDKState:isSdkEnabled andLaunchOptions:launchOptions];
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
- (void)initializeDefaultSDKConfig:(MOSDKConfig*)sdkConfig withSDKState:(BOOL)isSdkEnabled andLaunchOptions:(NSDictionary*)launchOptions{
|
|
50
|
+
|
|
51
|
+
MoEngagePlugin *plugin = [[MoEngagePlugin alloc] init];
|
|
52
|
+
[plugin initializeDefaultInstanceWithSdkConfig:sdkConfig sdkState:isSdkEnabled launchOptions:launchOptions];
|
|
53
|
+
[self commonSetUp: plugin identifier:sdkConfig.identifier];
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
#pragma mark- Utils
|
|
57
|
+
|
|
58
|
+
- (void)commonSetUp:(MoEngagePlugin *)plugin identifier:(NSString*)identifier {
|
|
59
|
+
[plugin trackPluginInfo: kReactNative version:MOE_REACT_PLUGIN_VERSION];
|
|
60
|
+
[self setPluginBridgeDelegate:identifier];
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
- (void)setPluginBridgeDelegate: (NSString*)identifier {
|
|
64
|
+
[[MoEngagePluginBridge sharedInstance] setPluginBridgeDelegate:self identifier:identifier];
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
-(MOSDKConfig*)fetchSDKConfig {
|
|
68
|
+
NSDictionary *infoDict = [[NSBundle mainBundle] infoDictionary];
|
|
69
|
+
MOSDKConfig *sdkConfig;
|
|
70
|
+
|
|
71
|
+
if ( [infoDict objectForKey: kMoEngage] != nil && [infoDict objectForKey: kMoEngage] != [NSNull null]) {
|
|
72
|
+
NSDictionary* moeDict = [infoDict objectForKey: kMoEngage];
|
|
73
|
+
if ([moeDict objectForKey: kAppId] != nil && [moeDict objectForKey:kAppId] != [NSNull null]) {
|
|
74
|
+
|
|
75
|
+
NSString *appId = [moeDict objectForKey: kAppId];
|
|
76
|
+
if (appId.length > 0) {
|
|
77
|
+
sdkConfig = [[MOSDKConfig alloc] initWithAppID:appId];
|
|
78
|
+
}
|
|
79
|
+
} else {
|
|
80
|
+
NSAssert(NO, @"MoEngage - Configure the APP ID for your MoEngage App.To get the AppID login to your MoEngage account, after that go to Settings -> App Settings. You will find the App ID in this screen. And refer to docs.moengage.com for more info");
|
|
81
|
+
return nil;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
if ([moeDict objectForKey: kDataCenter] != nil && [moeDict objectForKey:kDataCenter] != [NSNull null]) {
|
|
85
|
+
sdkConfig.moeDataCenter = [self getDataCenterFromString: [moeDict objectForKey: kDataCenter]];
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
if ([moeDict objectForKey:kAppGroupId] != nil && [moeDict objectForKey:kAppGroupId] != [NSNull null]) {
|
|
89
|
+
sdkConfig.appGroupID = [moeDict objectForKey:kAppGroupId];
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
if ([moeDict objectForKey:kDisablePeriodicFlush] != nil && [moeDict objectForKey:kDisablePeriodicFlush] != [NSNull null]) {
|
|
93
|
+
sdkConfig.analyticsDisablePeriodicFlush = [moeDict getBooleanForKey:kDisablePeriodicFlush];
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
if ([moeDict objectForKey:kPeriodicFlushDuration] != nil && [moeDict objectForKey:kPeriodicFlushDuration] != [NSNull null]) {
|
|
97
|
+
sdkConfig.analyticsPeriodicFlushDuration = [moeDict getIntegerForKey:kPeriodicFlushDuration];
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
if ([moeDict objectForKey:kEncryptNetworkRequests] != nil && [moeDict objectForKey:kEncryptNetworkRequests] != [NSNull null]) {
|
|
101
|
+
sdkConfig.encryptNetworkRequests = [moeDict getBooleanForKey:kDisablePeriodicFlush];
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
if ([moeDict objectForKey:kEnableLogs] != nil && [moeDict objectForKey:kEnableLogs] != [NSNull null]) {
|
|
105
|
+
sdkConfig.enableLogs = [moeDict getBooleanForKey:kEnableLogs];
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
return sdkConfig;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
- (MODataCenter)getDataCenterFromString:(NSString*)stringVal {
|
|
113
|
+
MODataCenter dataCenter = MODataCenterData_center_01;
|
|
114
|
+
|
|
115
|
+
if ([stringVal isEqual:kDataCenter1])
|
|
116
|
+
{
|
|
117
|
+
dataCenter = MODataCenterData_center_01;
|
|
118
|
+
}
|
|
119
|
+
else if ([stringVal isEqual:kDataCenter2])
|
|
120
|
+
{
|
|
121
|
+
dataCenter = MODataCenterData_center_02;
|
|
122
|
+
}
|
|
123
|
+
else if ([stringVal isEqual:kDataCenter3])
|
|
124
|
+
{
|
|
125
|
+
dataCenter = MODataCenterData_center_03;
|
|
126
|
+
}
|
|
127
|
+
else
|
|
128
|
+
{
|
|
129
|
+
NSLog(@"%@", kInvalidDataCenterAlert);
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
return dataCenter;
|
|
133
|
+
}
|
|
134
|
+
#pragma mark- MoEPluginBridgeDelegate
|
|
135
|
+
- (void)sendMessageWithEvent:(NSString *)event message:(NSDictionary<NSString *,id> *)message {
|
|
136
|
+
NSMutableDictionary* updatedDict = [NSMutableDictionary dictionary];
|
|
137
|
+
|
|
138
|
+
if (message) {
|
|
139
|
+
NSError *err;
|
|
140
|
+
NSData * jsonData = [NSJSONSerialization dataWithJSONObject:message options:0 error:&err];
|
|
141
|
+
if (jsonData) {
|
|
142
|
+
NSString* strPayload = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
|
|
143
|
+
updatedDict[kPayload] = strPayload;
|
|
144
|
+
} else {
|
|
145
|
+
NSLog(@"Error converting to dictionary to string %@", err.localizedDescription);
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
NSDictionary* userInfo = @{kEventName:event,kPayloadDict:updatedDict};
|
|
150
|
+
MoEReactBridge *reactBridge = [MoEReactBridge allocWithZone: nil];
|
|
151
|
+
[reactBridge sendEventWithName:userInfo];
|
|
152
|
+
}
|
|
153
|
+
@end
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
//
|
|
2
|
-
//
|
|
2
|
+
// MoEngageReactConstants.h
|
|
3
3
|
// ReactNativeMoEngage
|
|
4
4
|
//
|
|
5
5
|
// Created by Rakshitha C D on 10/02/21.
|
|
@@ -8,6 +8,8 @@
|
|
|
8
8
|
|
|
9
9
|
#import <Foundation/Foundation.h>
|
|
10
10
|
|
|
11
|
+
extern NSString* const kReactNative;
|
|
12
|
+
|
|
11
13
|
//Info.plist keys
|
|
12
14
|
extern NSString* const kMoEngage;
|
|
13
15
|
extern NSString* const kAppId;
|
|
@@ -17,10 +19,9 @@ extern NSString* const kDisablePeriodicFlush;
|
|
|
17
19
|
extern NSString* const kPeriodicFlushDuration;
|
|
18
20
|
extern NSString* const kEncryptNetworkRequests;
|
|
19
21
|
extern NSString* const kOptOutDataTracking;
|
|
20
|
-
extern NSString* const kOptOutPushNotifications;
|
|
21
|
-
extern NSString* const kOptOutInApp;
|
|
22
22
|
extern NSString* const kOptOutIDFATracking;
|
|
23
23
|
extern NSString* const kOptOutIDFVTracking;
|
|
24
|
+
extern NSString* const kEnableLogs;
|
|
24
25
|
|
|
25
26
|
//DataCenter Constants
|
|
26
27
|
extern NSString* const kDataCenter1;
|
|
@@ -35,3 +36,11 @@ extern NSString* const kEventEmitted;
|
|
|
35
36
|
|
|
36
37
|
extern NSString* const kInvalidAppIdAlert;
|
|
37
38
|
extern NSString* const kInvalidDataCenterAlert;
|
|
39
|
+
|
|
40
|
+
extern NSString* const kInAppShown;
|
|
41
|
+
extern NSString* const kInAppDismissed;
|
|
42
|
+
extern NSString* const kInAppClicked;
|
|
43
|
+
extern NSString* const kInAppCustomAction;
|
|
44
|
+
extern NSString* const kInAppSelfHandled;
|
|
45
|
+
extern NSString* const kPushTokenGenerated;
|
|
46
|
+
extern NSString* const kPushClicked;
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
//
|
|
2
|
-
//
|
|
2
|
+
// MoEngageReactConstants.m
|
|
3
3
|
// ReactNativeMoEngage
|
|
4
4
|
//
|
|
5
5
|
// Created by Rakshitha C D on 10/02/21.
|
|
6
6
|
// Copyright © 2020 MoEngage. All rights reserved.
|
|
7
7
|
//
|
|
8
8
|
|
|
9
|
-
#import "
|
|
9
|
+
#import "MoEngageReactConstants.h"
|
|
10
|
+
|
|
11
|
+
NSString* const kReactNative = @"react_native";
|
|
10
12
|
|
|
11
13
|
// Info.plist Keys
|
|
12
14
|
NSString* const kMoEngage = @"MoEngage";
|
|
@@ -16,11 +18,7 @@ NSString* const kAppGroupId = @"APP_GROUP_ID";
|
|
|
16
18
|
NSString* const kDisablePeriodicFlush = @"DISABLE_PERIODIC_FLUSH";
|
|
17
19
|
NSString* const kPeriodicFlushDuration = @"PERIODIC_FLUSH_DURATION";
|
|
18
20
|
NSString* const kEncryptNetworkRequests = @"ENCRYPT_NETWORK_REQUESTS";
|
|
19
|
-
NSString* const
|
|
20
|
-
NSString* const kOptOutPushNotifications = @"OPT_OUT_PUSH_NOTIFICATIONS";
|
|
21
|
-
NSString* const kOptOutInApp = @"OPT_OUT_INAPP";
|
|
22
|
-
NSString* const kOptOutIDFATracking = @"OPT_OUT_IDFA_TRACKING";
|
|
23
|
-
NSString* const kOptOutIDFVTracking = @"OPT_OUT_IDFV_TRACKING";
|
|
21
|
+
NSString* const kEnableLogs = @"ENABLE_LOGS";
|
|
24
22
|
|
|
25
23
|
//DataCenter Constants
|
|
26
24
|
NSString* const kDataCenter1 = @"DATA_CENTER_01";
|
|
@@ -35,3 +33,11 @@ NSString* const kEventEmitted = @"event-emitted";
|
|
|
35
33
|
|
|
36
34
|
NSString* const kInvalidAppIdAlert = @"MoEngage - Provide the APP ID for your MoEngage App in Info.plist for key MoEngage_APP_ID to proceed. To get the AppID login to your MoEngage account, after that go to Settings -> App Settings. You will find the App ID in this screen.";
|
|
37
35
|
NSString* const kInvalidDataCenterAlert = @"MoEngage - Invalid DataCenter";
|
|
36
|
+
|
|
37
|
+
NSString* const kInAppShown = @"MoEInAppCampaignShown";
|
|
38
|
+
NSString* const kInAppDismissed = @"MoEInAppCampaignDismissed";
|
|
39
|
+
NSString* const kInAppClicked = @"MoEInAppCampaignClicked";
|
|
40
|
+
NSString* const kInAppCustomAction = @"MoEInAppCampaignCustomAction";
|
|
41
|
+
NSString* const kInAppSelfHandled = @"MoEInAppCampaignSelfHandled";
|
|
42
|
+
NSString* const kPushTokenGenerated = @"MoEPushTokenGenerated";
|
|
43
|
+
NSString* const kPushClicked = @"MoEPushClicked";
|
|
@@ -7,8 +7,8 @@
|
|
|
7
7
|
objects = {
|
|
8
8
|
|
|
9
9
|
/* Begin PBXBuildFile section */
|
|
10
|
+
ACD518BE28ACAD510014B432 /* MoEReactInitializer.m in Sources */ = {isa = PBXBuildFile; fileRef = ACD518BC28ACAD510014B432 /* MoEReactInitializer.m */; };
|
|
10
11
|
ACFA62C125D3C4C4003F68AC /* MoEReactConstants.m in Sources */ = {isa = PBXBuildFile; fileRef = ACFA62C025D3C4C4003F68AC /* MoEReactConstants.m */; };
|
|
11
|
-
AF5962E923F6CEDB001C36F3 /* MOReactInitializer.m in Sources */ = {isa = PBXBuildFile; fileRef = AF5962E523F6CEDB001C36F3 /* MOReactInitializer.m */; };
|
|
12
12
|
AFF22D141DE315A7003DEB74 /* MoEReactBridge.m in Sources */ = {isa = PBXBuildFile; fileRef = AFF22D0F1DE315A7003DEB74 /* MoEReactBridge.m */; };
|
|
13
13
|
/* End PBXBuildFile section */
|
|
14
14
|
|
|
@@ -25,11 +25,11 @@
|
|
|
25
25
|
/* End PBXCopyFilesBuildPhase section */
|
|
26
26
|
|
|
27
27
|
/* Begin PBXFileReference section */
|
|
28
|
+
ACD518BC28ACAD510014B432 /* MoEReactInitializer.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MoEReactInitializer.m; sourceTree = "<group>"; };
|
|
29
|
+
ACD518BD28ACAD510014B432 /* MoEReactInitializer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MoEReactInitializer.h; sourceTree = "<group>"; };
|
|
28
30
|
ACFA62BD25D3C44F003F68AC /* MoEReactConstants.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MoEReactConstants.h; sourceTree = "<group>"; };
|
|
29
31
|
ACFA62C025D3C4C4003F68AC /* MoEReactConstants.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MoEReactConstants.m; sourceTree = "<group>"; };
|
|
30
|
-
AF5962DF23F6CEDB001C36F3 /* MOReactInitializer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MOReactInitializer.h; sourceTree = "<group>"; };
|
|
31
32
|
AF5962E423F6CEDB001C36F3 /* MOReactPluginInfo.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MOReactPluginInfo.h; sourceTree = "<group>"; };
|
|
32
|
-
AF5962E523F6CEDB001C36F3 /* MOReactInitializer.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MOReactInitializer.m; sourceTree = "<group>"; };
|
|
33
33
|
AFB2ED6A1DEC59830054BDA0 /* libMoEngage-iOS-SDK.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = "libMoEngage-iOS-SDK.a"; path = "/Users/Chengappa/Documents/Office/ReactNative/AwesomeProject/ios/Pods/../build/Debug-iphoneos/MoEngage-iOS-SDK/libMoEngage-iOS-SDK.a"; sourceTree = "<absolute>"; };
|
|
34
34
|
AFEF01DC1DD5D1D90017905F /* libMoEReactBridge.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libMoEReactBridge.a; sourceTree = BUILT_PRODUCTS_DIR; };
|
|
35
35
|
AFF22D0E1DE315A7003DEB74 /* MoEReactBridge.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MoEReactBridge.h; sourceTree = "<group>"; };
|
|
@@ -71,8 +71,8 @@
|
|
|
71
71
|
AF5962E423F6CEDB001C36F3 /* MOReactPluginInfo.h */,
|
|
72
72
|
AFF22D0E1DE315A7003DEB74 /* MoEReactBridge.h */,
|
|
73
73
|
AFF22D0F1DE315A7003DEB74 /* MoEReactBridge.m */,
|
|
74
|
-
|
|
75
|
-
|
|
74
|
+
ACD518BD28ACAD510014B432 /* MoEReactInitializer.h */,
|
|
75
|
+
ACD518BC28ACAD510014B432 /* MoEReactInitializer.m */,
|
|
76
76
|
ACFA62BD25D3C44F003F68AC /* MoEReactConstants.h */,
|
|
77
77
|
ACFA62C025D3C4C4003F68AC /* MoEReactConstants.m */,
|
|
78
78
|
);
|
|
@@ -148,8 +148,8 @@
|
|
|
148
148
|
buildActionMask = 2147483647;
|
|
149
149
|
files = (
|
|
150
150
|
ACFA62C125D3C4C4003F68AC /* MoEReactConstants.m in Sources */,
|
|
151
|
+
ACD518BE28ACAD510014B432 /* MoEReactInitializer.m in Sources */,
|
|
151
152
|
AFF22D141DE315A7003DEB74 /* MoEReactBridge.m in Sources */,
|
|
152
|
-
AF5962E923F6CEDB001C36F3 /* MOReactInitializer.m in Sources */,
|
|
153
153
|
);
|
|
154
154
|
runOnlyForDeploymentPostprocessing = 0;
|
|
155
155
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-moengage",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "8.0.0",
|
|
4
4
|
"description": "MoEngage is a mobile marketing automation company. This react-native SDK helps you track events, trigger smart notifications and in-apps, provides a drop-in Inbox Controller for notifications.",
|
|
5
5
|
"main": "src/index.ts",
|
|
6
6
|
"keywords": [
|
|
@@ -16,6 +16,11 @@
|
|
|
16
16
|
"test": "echo \"Error: no test specified\" && exit 1"
|
|
17
17
|
},
|
|
18
18
|
"author": "MoEngage",
|
|
19
|
-
"contributors": [
|
|
20
|
-
|
|
19
|
+
"contributors": [
|
|
20
|
+
"MoEngage <mobiledevs@moengage.com>"
|
|
21
|
+
],
|
|
22
|
+
"license": "ISC",
|
|
23
|
+
"devDependencies": {
|
|
24
|
+
"@types/react-native": "^0.69.3"
|
|
25
|
+
}
|
|
21
26
|
}
|