react-native-moengage 9.1.0 → 10.0.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.
@@ -8,14 +8,12 @@
8
8
  #import "MoEngageInitializer.h"
9
9
  #import "MoEngageReactPluginInfo.h"
10
10
  #import "MoEngageReactConstants.h"
11
- #import "MoEReactBridge.h"
12
11
  #import "MoEngageReactUtils.h"
13
12
  #import <MoEngageSDK/MoEngageSDK.h>
14
13
  #import <MoEngageObjCUtils/MoEngageObjCUtils.h>
15
- @import MoEngagePluginBase;
16
- @interface MoEngageInitializer() <MoEngagePluginBridgeDelegate>
14
+ #import "MoEReactNativeHandler.h"
17
15
 
18
- @end
16
+ @import MoEngagePluginBase;
19
17
 
20
18
  @implementation MoEngageInitializer
21
19
 
@@ -31,32 +29,12 @@
31
29
  }
32
30
  #pragma mark- Initialization methods
33
31
 
34
- - (void)initializeDefaultInstance:(NSDictionary*)launchOptions{
35
- [self initializeDefaultSDKConfig:[self fetchSDKConfig] andLaunchOptions:launchOptions];
36
- }
37
-
38
32
  - (void)initializeDefaultSDKConfig:(MoEngageSDKConfig*)sdkConfig andLaunchOptions:(NSDictionary*)launchOptions{
39
33
  MoEngagePlugin *plugin = [[MoEngagePlugin alloc] init];
40
34
  [plugin initializeDefaultInstanceWithSdkConfig:sdkConfig launchOptions:launchOptions];
41
35
  [self commonSetUp:plugin identifier:sdkConfig.appId];
42
36
  }
43
37
 
44
- - (void)initializeDefaultInstance:(BOOL)isSdkEnabled andLaunchOptions:(NSDictionary*)launchOptions{
45
- MoEngageSDKConfig *sdkConfig = [self fetchSDKConfig];
46
- MoEngageSDKState currentSDKState = isSdkEnabled ? MoEngageSDKStateEnabled: MoEngageSDKStateDisabled;
47
- [self initializeDefaultSDKConfigWithState:sdkConfig withSDKState:currentSDKState andLaunchOptions:launchOptions];
48
- }
49
-
50
- - (void)initializeDefaultInstanceWithState:(MoEngageSDKState)sdkState andLaunchOptions:(NSDictionary*)launchOptions{
51
- MoEngageSDKConfig *sdkConfig = [self fetchSDKConfig];
52
- [self initializeDefaultSDKConfigWithState:sdkConfig withSDKState:sdkState andLaunchOptions:launchOptions];
53
- }
54
-
55
- - (void)initializeDefaultSDKConfig:(MoEngageSDKConfig*)sdkConfig withSDKState:(BOOL)isSDKEnabled andLaunchOptions:(NSDictionary*)launchOptions{
56
- MoEngageSDKState currentSDKState = isSDKEnabled ? MoEngageSDKStateEnabled: MoEngageSDKStateDisabled;
57
- [self initializeDefaultSDKConfigWithState:sdkConfig withSDKState:currentSDKState andLaunchOptions:launchOptions];
58
- }
59
-
60
38
  - (void)initializeDefaultSDKConfigWithState:(MoEngageSDKConfig *)sdkConfig withSDKState:(MoEngageSDKState)sdkState andLaunchOptions:(NSDictionary*)launchOptions{
61
39
 
62
40
  MoEngagePlugin *plugin = [[MoEngagePlugin alloc] init];
@@ -72,96 +50,6 @@
72
50
  }
73
51
 
74
52
  - (void)setPluginBridgeDelegate: (NSString*)identifier {
75
- [[MoEngagePluginBridge sharedInstance] setPluginBridgeDelegate:self identifier:identifier];
76
- }
77
-
78
- -(MoEngageSDKConfig*)fetchSDKConfig {
79
- NSDictionary *infoDict = [[NSBundle mainBundle] infoDictionary];
80
- MoEngageSDKConfig *sdkConfig;
81
-
82
- if ( [infoDict objectForKey: kMoEngage] != nil && [infoDict objectForKey: kMoEngage] != [NSNull null]) {
83
- NSDictionary* moeDict = [infoDict objectForKey: kMoEngage];
84
- if ([moeDict objectForKey: kAppId] != nil && [moeDict objectForKey:kAppId] != [NSNull null]) {
85
-
86
- NSString *appId = [moeDict objectForKey: kAppId];
87
- if (appId.length > 0) {
88
- sdkConfig = [[MoEngageSDKConfig alloc] initWithAppID:appId];
89
- }
90
- } else {
91
- 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");
92
- return nil;
93
- }
94
-
95
- if ([moeDict objectForKey: kDataCenter] != nil && [moeDict objectForKey:kDataCenter] != [NSNull null]) {
96
- sdkConfig.moeDataCenter = [self getDataCenterFromString: [moeDict objectForKey: kDataCenter]];
97
- }
98
-
99
- if ([moeDict objectForKey:kAppGroupId] != nil && [moeDict objectForKey:kAppGroupId] != [NSNull null]) {
100
- sdkConfig.appGroupID = [moeDict objectForKey:kAppGroupId];
101
- }
102
-
103
- if ([moeDict objectForKey:kDisablePeriodicFlush] != nil && [moeDict objectForKey:kDisablePeriodicFlush] != [NSNull null]) {
104
- sdkConfig.analyticsDisablePeriodicFlush = [MoEngageReactUtils getBooleanForKey:kDisablePeriodicFlush dict:moeDict];
105
- }
106
-
107
- if ([moeDict objectForKey:kPeriodicFlushDuration] != nil && [moeDict objectForKey:kPeriodicFlushDuration] != [NSNull null]) {
108
- sdkConfig.analyticsPeriodicFlushDuration = [MoEngageReactUtils getIntegerForKey:kPeriodicFlushDuration dict:moeDict];
109
- }
110
-
111
- if ([moeDict objectForKey:kEnableLogs] != nil && [moeDict objectForKey:kEnableLogs] != [NSNull null]) {
112
- BOOL isLogsEnabled = [MoEngageReactUtils getBooleanForKey:kEnableLogs dict:moeDict];
113
- sdkConfig.consoleLogConfig = [[MoEngageConsoleLogConfig alloc] initWithIsLoggingEnabled:isLogsEnabled loglevel:MoEngageLoggerTypeVerbose];
114
- }
115
- }
116
-
117
- return sdkConfig;
118
- }
119
-
120
- - (MoEngageDataCenter)getDataCenterFromString:(NSString*)stringVal {
121
- MoEngageDataCenter dataCenter = MoEngageDataCenterData_center_01;
122
-
123
- if ([stringVal isEqual:kDataCenter1])
124
- {
125
- dataCenter = MoEngageDataCenterData_center_01;
126
- }
127
- else if ([stringVal isEqual:kDataCenter2])
128
- {
129
- dataCenter = MoEngageDataCenterData_center_02;
130
- }
131
- else if ([stringVal isEqual:kDataCenter3])
132
- {
133
- dataCenter = MoEngageDataCenterData_center_03;
134
- } else if ([stringVal isEqual: kDataCenter4])
135
- {
136
- dataCenter = MoEngageDataCenterData_center_04;
137
- } else if ([stringVal isEqual: kDataCenter5])
138
- {
139
- dataCenter = MoEngageDataCenterData_center_05;
140
- }
141
- else
142
- {
143
- NSLog(@"%@", kInvalidDataCenterAlert);
144
- }
145
-
146
- return dataCenter;
147
- }
148
- #pragma mark- MoEPluginBridgeDelegate
149
- - (void)sendMessageWithEvent:(NSString *)event message:(NSDictionary<NSString *,id> *)message {
150
- NSMutableDictionary* updatedDict = [NSMutableDictionary dictionary];
151
-
152
- if (message) {
153
- NSError *err;
154
- NSData * jsonData = [NSJSONSerialization dataWithJSONObject:message options:0 error:&err];
155
- if (jsonData) {
156
- NSString* strPayload = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
157
- updatedDict[kPayload] = strPayload;
158
- } else {
159
- NSLog(@"Error converting to dictionary to string %@", err.localizedDescription);
160
- }
161
- }
162
-
163
- NSDictionary* userInfo = @{kEventName:event,kPayloadDict:updatedDict};
164
- MoEReactBridge *reactBridge = [MoEReactBridge allocWithZone: nil];
165
- [reactBridge sendEventWithName:userInfo];
53
+ [[MoEReactNativeHandler sharedInstance] setDelegate:identifier];
166
54
  }
167
55
  @end
@@ -1,2 +1,2 @@
1
1
  // Generated file, do not edit
2
- #define MOE_REACT_PLUGIN_VERSION @"8.1.2"
2
+ #define MOE_REACT_PLUGIN_VERSION @"9.0.0"
@@ -11,4 +11,5 @@
11
11
  @interface MoEngageReactUtils : NSObject
12
12
  +(NSInteger)getIntegerForKey:(NSString *)key dict:(NSDictionary*)dict;
13
13
  +(BOOL)getBooleanForKey:(NSString *)key dict:(NSDictionary*)dict;
14
+ +(NSDictionary*)getJSONRepresentation:(NSString*)string;
14
15
  @end
@@ -37,4 +37,10 @@
37
37
  }
38
38
  return [value boolValue];
39
39
  }
40
+
41
+ +(NSDictionary*)getJSONRepresentation:(NSString*)string {
42
+ NSData *data = [string dataUsingEncoding:NSUTF8StringEncoding];
43
+ NSDictionary *jsonOutput = [NSJSONSerialization JSONObjectWithData:data options:0 error:nil];
44
+ return jsonOutput;
45
+ }
40
46
  @end
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-moengage",
3
- "version": "9.1.0",
3
+ "version": "10.0.1",
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
  "files": [
@@ -36,5 +36,13 @@
36
36
  "license": "SEE LICENSE IN LICENSE.txt",
37
37
  "devDependencies": {
38
38
  "@types/react-native": "^0.69.3"
39
+ },
40
+ "codegenConfig": {
41
+ "name": "NativeMoEngageSpec",
42
+ "type": "modules",
43
+ "jsSrcsDir": "src",
44
+ "android": {
45
+ "javaPackageName": "com.moengage.react"
46
+ }
39
47
  }
40
48
  }
@@ -0,0 +1,201 @@
1
+ import type { TurboModule } from 'react-native/Libraries/TurboModule/RCTExport';
2
+ import { TurboModuleRegistry } from 'react-native';
3
+
4
+ export interface Spec extends TurboModule {
5
+
6
+ /**
7
+ * Initialise the MoEngage SDK, once the hybrid component is mounted
8
+ *
9
+ * @param payload Stringified JSON payload
10
+ *
11
+ */
12
+ initialize: (payload: string) => void;
13
+
14
+ /**
15
+ * Tells the SDK whether this is a migration or a fresh installation.
16
+ *
17
+ * @param payload Stringified JSON payload
18
+ *
19
+ */
20
+ setAppStatus: (payload: string) => void;
21
+
22
+ /**
23
+ * Tracks the specified event
24
+ *
25
+ * @param payload Stringified JSON payload
26
+ *
27
+ */
28
+ trackEvent: (payload: string) => void;
29
+
30
+ /**
31
+ * Sets the user specific attribute.
32
+ *
33
+ * @param payload Stringified JSON payload
34
+ *
35
+ */
36
+ setUserAttribute: (payload: string) => void;
37
+
38
+ /**
39
+ *
40
+ * Update user's unique id which was previously set by setUserUniqueID()
41
+ *
42
+ * @param payload Stringified JSON payload
43
+ *
44
+ */
45
+ setAlias: (payload: string) => void;
46
+
47
+ /**
48
+ * Notifys the SDK that the user has logged out of the app.
49
+ *
50
+ * @param payload Stringified JSON payload
51
+ *
52
+ */
53
+ logout: (payload: string) => void;
54
+
55
+ /**
56
+ * Call this method wherever InApp message has to be shown, if available
57
+ *
58
+ * @param payload Stringified JSON payload
59
+ *
60
+ */
61
+ showInApp: (payload: string) => void;
62
+
63
+ /**
64
+ * Call This method to show the nudge
65
+ *
66
+ * @param payload Stringified JSON payload
67
+ *
68
+ */
69
+ showNudge: (payload: string) => void;
70
+
71
+ /**
72
+ * Call this method to get the campaign info for self handled inApps
73
+ *
74
+ * @param payload Stringified JSON payload
75
+ *
76
+ */
77
+ getSelfHandledInApp: (payload: string) => void;
78
+
79
+ /**
80
+ * Call this method to update the impressions of self handled inapps.
81
+ *
82
+ * @param payload Stringified JSON payload
83
+ *
84
+ */
85
+ updateSelfHandledInAppStatus: (payload: string) => void;
86
+
87
+ /**
88
+ * Call this method to the current context for inApp module.
89
+ *
90
+ * @param payload
91
+ *
92
+ */
93
+ setAppContext: (payload: string) => void;
94
+
95
+ /**
96
+ * Call this method to the reset current context for inApp module.
97
+ *
98
+ * @param payload Stringified JSON payload
99
+ *
100
+ */
101
+ resetAppContext: (payload: string) => void;
102
+
103
+ /**
104
+ * API to opt out/in from data tracking.
105
+ *
106
+ * @param payload Stringified JSON payload
107
+ *
108
+ */
109
+ optOutDataTracking: (payload: string) => void;
110
+
111
+ /**
112
+ * API to opt enable/disable the SDK.
113
+ *
114
+ * @param payload Stringified JSON payload
115
+ *
116
+ */
117
+ updateSdkState: (payload: string) => void;
118
+
119
+ /// Anroid specific
120
+
121
+ /**
122
+ * Pass the FCM push token to the MoEngage SDK.
123
+ *
124
+ * @param payload Stringfied JSON with data as FCM token
125
+ */
126
+ passFcmPushToken: (payload: string) => void;
127
+
128
+ /**
129
+ * Pass push payload to the MoEngage SDK.
130
+ *
131
+ * @param payload Stringified JSON with data as Push Notification Payload
132
+ */
133
+ passFcmPushPayload: (payload: string) => void;
134
+
135
+ /**
136
+ * Pass the HMS PushKit push token to the MoEngage SDK.
137
+ *
138
+ * @param payload Stringified JSON with data as Push Kit token
139
+ */
140
+ passPushKitPushToken: (payload: string) => void;
141
+
142
+ /**
143
+ * Notify the MoEngage SDK about the device orientation change
144
+ */
145
+ onOrientationChanged: () => void;
146
+
147
+ /**
148
+ * Notify the SDK when the push permission is granted from user
149
+ *
150
+ * @param payload Stringified JSON with data as permission state
151
+ */
152
+ pushPermissionResponseAndroid: (payload: string) => void;
153
+
154
+ /**
155
+ * API to create the MoEngage default notification channel
156
+ */
157
+ setupNotificationChannels: () => void;
158
+
159
+ /**
160
+ * API to redirect user to Notification permission page
161
+ */
162
+ navigateToSettingsAndroid: () => void;
163
+
164
+ /**
165
+ * API to request the push permission on Android 13 and above.
166
+ */
167
+ requestPushPermissionAndroid: () => void;
168
+
169
+ /**
170
+ * Updates the Notification request attempt count, the request attempt count will be incremented by the passed fresh count.
171
+ *
172
+ * @param payload Stringified JSON with data as incremented count
173
+ */
174
+ updatePushPermissionRequestCountAndroid: (payload: string) => void;
175
+
176
+ /**
177
+ *
178
+ * Update the Device identifier tracking status
179
+ *
180
+ * @param payload Stringified JSON with data as tracking status
181
+ */
182
+ deviceIdentifierTrackingStatusUpdate:(payload: string) => void;
183
+
184
+ /**
185
+ * Delete User Data From MoEngage Server
186
+ *
187
+ * @param payload Stringified JSON payload
188
+ *
189
+ */
190
+ deleteUser(payload: string): Promise<Object | Error>;
191
+
192
+ /// ios specific
193
+ registerForPush: () => void;
194
+
195
+ addListener: (eventType: string) => void;
196
+ removeListeners: (count: number) => void;
197
+ }
198
+
199
+ const MoEReactBridge = TurboModuleRegistry.getEnforcing<Spec>('MoEReactBridge');
200
+ export default MoEReactBridge;
201
+