react-native-moengage 7.1.0 → 7.4.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 CHANGED
@@ -1,8 +1,32 @@
1
- ## 7.1.0
1
+ # react-native-moengage
2
+ ---
3
+ ## Change Log:
4
+ ### 7.4.0
5
+ Release Date: 12th May 2022
6
+ - Bugfix iOS: Fixed the PushClick callback issue in terminated state, that was appearing when the react-native version is above 0.65.
7
+
8
+ ### 7.3.0
9
+ Release Date: 16th September 2021
10
+ - HTML InApp Support Added.
11
+ - Bugfix:
12
+ - Handled `trackEvent()` with null properties.
13
+ - iOS
14
+ - Native SDK version updated to `~>7.1.0`.
15
+ - Base plugin version dependency updated to `~>2.1.0`.
16
+ - Android
17
+ - Native SDK updated to support version `11.4.00` and above.
18
+ - Bugfix:
19
+ - `enableSDKLogs()` not working on Android.
20
+
21
+ ### 7.2.0
22
+ Release Date: 11th May 2021
23
+ - Android Multi-Instance Phase 1 update.
24
+
25
+ ### 7.1.0
2
26
  Release Date: 17th March 2021
3
27
  - Added support to pass Array(String/Number) as event attributes in addAttribute method of MoEProperties.
4
28
 
5
- ## 7.0.0
29
+ ### 7.0.0
6
30
  Release Date: 25th February 2021
7
31
  - iOS
8
32
  - Plugin now supports iOS 10.0 and above
@@ -15,44 +39,44 @@ Release Date: 25th February 2021
15
39
  - Added APIs to enable and disable MoEngage SDK.
16
40
  - Added API to register a callback for push token generated event.
17
41
 
18
- ## 6.1.7
42
+ ### 6.1.7
19
43
  Release Date: 15th February 2021
20
44
  - Android artifacts use manven central instead of Jcenter.
21
45
  - Android Native SDK version `10.6.01`
22
46
  - Android Plugin Base `1.2.01`
23
47
 
24
- ## 6.1.6
48
+ ### 6.1.6
25
49
  Release Date: 21st January 2021
26
50
  - BugFix iOS: Token registered event skipped as its currently not supported in React Native.
27
51
 
28
- ## 6.1.5
52
+ ### 6.1.5
29
53
  Release Date: 18th January 2021
30
54
  - iOS Base Plugin dependency updated to support version `1.2` and above.
31
55
 
32
- ## 6.1.4
56
+ ### 6.1.4
33
57
  Release Date: 7th December 2020
34
58
  - Support for extending Native Android Callbacks if required.
35
59
  - Native Android SDK version required is `10.5.00` or above.
36
60
  - iOS Base Plugin Updated to version `1.1.1` to ensure SDK sets the UNUserNotification Center delegate only in cases where its `nil`.
37
61
 
38
- ## 6.1.3
62
+ ### 6.1.3
39
63
  Release Date: 25th November 2020
40
64
  - Android Base plugin dependency type updated to ensure compatability across gradle versions.
41
65
 
42
- ## 6.1.2
66
+ ### 6.1.2
43
67
  Release Date: 23rd November 2020
44
68
  - Android Base Plugin Updated to enable Custom Callbacks.
45
69
 
46
- ## 6.1.1
70
+ ### 6.1.1
47
71
  Release Date: 22nd October 2020
48
72
  - Bugfix
49
73
  - Events not being marked as non-interactive on Android
50
74
 
51
- ## 6.1.0
75
+ ### 6.1.0
52
76
  Release Date: 23rd September, 2020
53
77
  - Support for Push Templates added
54
78
 
55
- ## 6.0.0
79
+ ### 6.0.0
56
80
  Release Date: 7th August 2020
57
81
  - Breaking change in Initialization of iOS platform, refer to the [developer docs](https://docs.moengage.com/docs/sdk-initialization-1#ios) to know more about the changes.
58
82
  - Support for Self-Handled In-App
@@ -79,14 +103,14 @@ Release Date: 23rd September, 2020
79
103
  | ReactMoE.passPushToken(string) | ReactMoE.passFcmPushToken(string) |
80
104
  | ReactMoE.passPushPayload(JSONObject) | ReactMoE.passFcmPushPayload(JSONObject) |
81
105
 
82
- ## 5.0.0
106
+ ### 5.0.0
83
107
  Release Date: 18th Feb 2020
84
108
  - New Event Listeners added for both iOS and Android platforms i.e, `pushClicked`, `inAppCampaignShown` and `inAppCampaignShown`.
85
109
  - Earlier iOS Push and InApp Events deprecated to have it common for both Android and iOS (`notificationClicked`,`inAppShown` and `inAppClicked`)
86
110
  - APIs to pass push token and payload from React-Native Component/Javascript (Android Only API)
87
111
  - Fixing datatype conversion for user attributes long getting converted to double.
88
112
 
89
- ## 4.1.0
113
+ ### 4.1.0
90
114
  Release Date: 23rd Dec 2019
91
115
  - Android SDK version updated to 9.8.01
92
116
  - integration_type and integration_version added for both Android and iOS
@@ -15,7 +15,7 @@ Pod::Spec.new do |s|
15
15
  s.platform = :ios, "10.0"
16
16
  s.source_files = 'iOS/MoEReactBridge/**/*.{h,m}'
17
17
  s.dependency 'React'
18
- s.dependency 'MoEPluginBase','>= 2.0.2','< 2.1.0'
18
+ s.dependency 'MoEPluginBase','>= 2.3.0','< 2.4.0'
19
19
 
20
20
  s.prepare_command = <<-CMD
21
21
  echo // Generated file, do not edit > iOS/MoEReactBridge/MOReactPluginInfo.h
@@ -15,6 +15,7 @@ buildscript {
15
15
  rootProject.allprojects {
16
16
  repositories {
17
17
  google()
18
+ mavenLocal()
18
19
  mavenCentral()
19
20
  jcenter()
20
21
  }
@@ -22,8 +23,8 @@ rootProject.allprojects {
22
23
 
23
24
  ext {
24
25
  //dependency version
25
- moengageVersion = "11.0.04"
26
- basePluginVersion = "2.0.00"
26
+ moengageVersion = "11.4.00"
27
+ basePluginVersion = "2.2.0"
27
28
  //build versions
28
29
  minimumVersion = 16
29
30
  targetVersion = 29
@@ -196,6 +196,16 @@ class MoEReactBridge(reactContext: ReactApplicationContext) :
196
196
  }
197
197
  }
198
198
 
199
+ @ReactMethod
200
+ fun onOrientationChanged() {
201
+ try{
202
+ Logger.v("$tag onScreenOrientationChanged(): ")
203
+ pluginHelper.onConfigurationChanged()
204
+ }catch(e: Exception){
205
+ Logger.e("$tag onScreenOrientationChanged() : ", e)
206
+ }
207
+ }
208
+
199
209
 
200
210
  init {
201
211
  pluginHelper.setEventCallback(EventEmitterImpl(reactContext))
@@ -0,0 +1,36 @@
1
+ package com.moengage.react
2
+
3
+ import com.moengage.core.internal.inapp.InAppManager
4
+ import com.moengage.core.internal.logger.Logger
5
+ import com.moengage.inapp.MoEInAppHelper
6
+
7
+ /**
8
+ * @author Umang Chamaria
9
+ * Date: 2021/08/18
10
+ */
11
+ public class MoEReactHelper {
12
+
13
+ private val tag = "${MODULE_TAG}MoEReactHelper"
14
+
15
+ public fun onConfigurationChanged() {
16
+ if (!InAppManager.getInstance().hasModule()){
17
+ Logger.v("$tag onConfigurationChanged(): InApp Module not present.")
18
+ return
19
+ }
20
+ MoEInAppHelper.getInstance().onConfigurationChanged()
21
+ }
22
+
23
+ public companion object {
24
+
25
+ private var instance: MoEReactHelper? = null
26
+
27
+ @JvmStatic
28
+ public fun getInstance(): MoEReactHelper {
29
+ return instance ?: synchronized(MoEReactHelper::class.java) {
30
+ val inst = instance ?: MoEReactHelper()
31
+ instance = inst
32
+ inst
33
+ }
34
+ }
35
+ }
36
+ }
@@ -10,6 +10,7 @@
10
10
  #import <MoEngage/MoEngage.h>
11
11
  #import <MoEPluginBase/MoEPluginBase.h>
12
12
  #import "MoEReactConstants.h"
13
+ #import "MoEReactBridge.h"
13
14
 
14
15
  @interface MOReactInitializer() <MoEPluginBridgeDelegate>
15
16
 
@@ -43,7 +44,6 @@
43
44
  }
44
45
 
45
46
  - (void)intializeSDKWithConfig:(MOSDKConfig*)sdkConfig withSDKState:(BOOL)isSdkEnabled andLaunchOptions:(NSDictionary*)launchOptions{
46
- [[MoEPluginBridge sharedInstance] trackPluginVersion:MO_REACT_PLUGIN_VERSION forIntegrationType:ReactNative];
47
47
  [MoEPluginBridge sharedInstance].bridgeDelegate = self;
48
48
 
49
49
  if (sdkConfig.moeAppID == nil || sdkConfig == nil) {
@@ -53,7 +53,7 @@
53
53
  sdkConfig.pluginIntegrationType = REACT_NATIVE;
54
54
  sdkConfig.pluginIntegrationVersion = MO_REACT_PLUGIN_VERSION;
55
55
 
56
- [[MoEPluginInitializer sharedInstance] intializeSDKWithConfig:sdkConfig withSDKState:isSdkEnabled andLaunchOptions:launchOptions];
56
+ [[MoEPluginInitializer sharedInstance] initializeSDKWithConfig:sdkConfig withSDKState:isSdkEnabled andLaunchOptions:launchOptions];
57
57
  }
58
58
 
59
59
  -(MOSDKConfig*)fetchSDKConfig {
@@ -164,9 +164,8 @@
164
164
  }
165
165
 
166
166
  NSDictionary* userInfo = @{kEventName:name,kPayloadDict:updatedDict};
167
- [[NSNotificationCenter defaultCenter] postNotificationName:kEventEmitted
168
- object:self
169
- userInfo:userInfo];
167
+ MoEReactBridge *reactBridge = [MoEReactBridge allocWithZone: nil];
168
+ [reactBridge sendEventWithName:userInfo];
170
169
 
171
170
  }
172
171
 
@@ -1,2 +1,2 @@
1
1
  // Generated file, do not edit
2
- #define MO_REACT_PLUGIN_VERSION @"7.0.0"
2
+ #define MO_REACT_PLUGIN_VERSION @"7.3.0"
@@ -11,5 +11,5 @@
11
11
  #import <React/RCTEventEmitter.h>
12
12
 
13
13
  @interface MoEReactBridge : RCTEventEmitter <RCTBridgeModule>
14
-
14
+ -(void)sendEventWithName:(NSDictionary *)payloadDict;
15
15
  @end
@@ -16,38 +16,78 @@
16
16
  #import "MoEReactConstants.h"
17
17
 
18
18
  @interface MoEReactBridge()
19
-
20
19
  @end
21
20
 
22
21
  @implementation MoEReactBridge
23
22
 
23
+ {
24
+ bool hasListeners;
25
+ NSMutableArray *delayedEvents;
26
+ }
27
+
28
+ - (instancetype)init
29
+ {
30
+ if (self = [super init]) {
31
+ if (delayedEvents == nil)
32
+ delayedEvents = [NSMutableArray array];
33
+ }
34
+ return self;
35
+ }
36
+
37
+ + (id)allocWithZone:(NSZone *)zone {
38
+ static MoEReactBridge *sharedInstance = nil;
39
+ static dispatch_once_t onceToken;
40
+ dispatch_once(&onceToken, ^{
41
+ sharedInstance = [super allocWithZone:zone];
42
+ });
43
+ return sharedInstance;
44
+ }
45
+
46
+ + (BOOL)requiresMainQueueSetup {
47
+ return true;
48
+ }
49
+
24
50
  #pragma mark- Observers
25
51
  // Will be called when this module's first listener is added.
26
52
  -(void)startObserving {
27
- [[NSNotificationCenter defaultCenter] addObserver:self
28
- selector:@selector(emitEventInternal:)
29
- name:kEventEmitted
30
- object:nil];
53
+ hasListeners = YES;
54
+ [self flushDelayedEvents];
55
+
31
56
  }
32
57
 
33
58
  // Will be called when this module's last listener is removed, or on dealloc.
34
59
  -(void)stopObserving {
35
- [[NSNotificationCenter defaultCenter] removeObserver:self name:kEventEmitted object:nil];
60
+ hasListeners = NO;
36
61
  }
37
62
 
38
- -(void)emitEventInternal:(NSNotification *)notification
39
- {
40
- NSDictionary* userInfo = notification.userInfo;
41
- if (userInfo) {
42
- NSString* name = userInfo[kEventName];
43
- NSDictionary* payload = userInfo[kPayloadDict];
63
+ -(void)flushDelayedEvents{
64
+ if (delayedEvents.count > 0){
65
+ for (NSDictionary* payloadDict in delayedEvents){
66
+ [self emitEvent:payloadDict];
67
+ }
68
+ }
69
+
70
+ [delayedEvents removeAllObjects];
71
+ }
72
+
73
+ -(void)sendEventWithName:(NSDictionary *)payloadDict{
74
+ if (hasListeners) {
75
+ [self emitEvent:payloadDict];
76
+ } else {
77
+ [delayedEvents addObject:payloadDict];
78
+ }
79
+ }
80
+
81
+ -(void)emitEvent:(NSDictionary*)payloadDict{
82
+ if (payloadDict){
83
+ NSString* name = payloadDict[kEventName];
84
+ NSDictionary* payload = payloadDict[kPayloadDict];
44
85
  if (name != nil && payload != nil) {
45
86
  [self sendEventWithName:name body:payload];
46
87
  }
47
88
  }
48
89
  }
49
90
 
50
-
51
91
  #pragma mark- Event Emitters
52
92
  - (NSArray<NSString *> *)supportedEvents
53
93
  {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-moengage",
3
- "version": "7.1.0",
3
+ "version": "7.4.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": [
package/src/index.ts CHANGED
@@ -130,11 +130,17 @@ var ReactMoE = {
130
130
  */
131
131
  trackEvent: function (eventName: String, properties: MoEProperties) {
132
132
  commonValidationCheck();
133
- console.log("trackEvent with properties", properties);
133
+
134
+ if(properties == null) {
135
+ properties = new MoEProperties()
136
+ }
137
+
134
138
  if (!(properties instanceof MoEProperties)) {
135
139
  showError("trackEvent: properties must of MoEProperties type");
136
140
  return;
137
141
  }
142
+
143
+ console.log("trackEvent with properties", properties);
138
144
  //...(spread operator)it will append all the contents of the object/array into the target element
139
145
  let payload = {
140
146
  ...properties.toJSON(),
@@ -702,6 +708,13 @@ var ReactMoE = {
702
708
  } else if (Platform.OS == PLATFORM_IOS) {
703
709
  MoERNiOS.updateSdkState(false);
704
710
  }
711
+ },
712
+
713
+ onOrientationChanged: function() {
714
+ console.log("Will process screen rotation.")
715
+ if(Platform.OS == PLATFORM_ANDROID) {
716
+ MoERNAndroid.onOrientationChanged()
717
+ }
705
718
  }
706
719
  };
707
720
 
@@ -6,6 +6,7 @@ import { isValidObject } from "../utils/MoEHelper";
6
6
  export default class MoEInAppCampaign {
7
7
  campaignId: String;
8
8
  campaignName: String;
9
+ campaignContext: Map<String, Object>;
9
10
  customAction: MoEInAppCustomAction;
10
11
  selfHandled: MoEInAppSelfHandledCampaign;
11
12
  navigation: MoEInAppNavigation;
@@ -15,6 +16,7 @@ export default class MoEInAppCampaign {
15
16
  if (isValidObject(campaign)) {
16
17
  this.campaignId = campaign["campaignId"];
17
18
  this.campaignName = campaign["campaignName"];
19
+ this.campaignContext = campaign["campaignContext"];
18
20
  this.platform = campaign["platform"];
19
21
  this.customAction = new MoEInAppCustomAction(campaign["customAction"]);
20
22
  this.selfHandled = new MoEInAppSelfHandledCampaign(
@@ -28,6 +30,7 @@ export default class MoEInAppCampaign {
28
30
  var json = {
29
31
  campaignId: this.campaignId,
30
32
  campaignName: this.campaignName,
33
+ campaignContext: this.campaignContext,
31
34
  };
32
35
  if (isValidObject(this.customAction)) {
33
36
  json["customAction"] = this.customAction.toJSON();
@@ -90,7 +90,7 @@ export class MoERNAndroid {
90
90
  }
91
91
 
92
92
  static enableSDKLogs() {
93
- MoEReactBridge.enableSDKLogs();
93
+ MoEReactBridge.enableLogs();
94
94
  }
95
95
 
96
96
  static optOutDataTracking(shouldOptOutDataTracking: boolean){
@@ -141,6 +141,10 @@ export class MoERNAndroid {
141
141
  };
142
142
  MoEReactBridge.updateSdkState(JSON.stringify(payload));
143
143
  }
144
+
145
+ static onOrientationChanged() {
146
+ MoEReactBridge.onOrientationChanged()
147
+ }
144
148
  }
145
149
 
146
150
  const PUSH_SERVICE_FCM = "FCM"