react-native-moengage 7.2.0 → 7.4.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.
package/CHANGELOG.md CHANGED
@@ -1,12 +1,34 @@
1
- ## 7.2.0
2
- Release Date: 17th March 2021
1
+ ## Changelog:
2
+
3
+ ### 7.4.1
4
+ - Device identifier tracking update as per Google's User data policy. Advertising Id is only tracked after user consent.
5
+
6
+ ### 7.4.0
7
+ Release Date: 12th May 2022
8
+ - Bugfix iOS: Fixed the PushClick callback issue in terminated state, that was appearing when the react-native version is above 0.65.
9
+
10
+ ### 7.3.0
11
+ Release Date: 16th September 2021
12
+ - HTML InApp Support Added.
13
+ - Bugfix:
14
+ - Handled `trackEvent()` with null properties.
15
+ - iOS
16
+ - Native SDK version updated to `~>7.1.0`.
17
+ - Base plugin version dependency updated to `~>2.1.0`.
18
+ - Android
19
+ - Native SDK updated to support version `11.4.00` and above.
20
+ - Bugfix:
21
+ - `enableSDKLogs()` not working on Android.
22
+
23
+ ### 7.2.0
24
+ Release Date: 11th May 2021
3
25
  - Android Multi-Instance Phase 1 update.
4
26
 
5
- ## 7.1.0
27
+ ### 7.1.0
6
28
  Release Date: 17th March 2021
7
29
  - Added support to pass Array(String/Number) as event attributes in addAttribute method of MoEProperties.
8
30
 
9
- ## 7.0.0
31
+ ### 7.0.0
10
32
  Release Date: 25th February 2021
11
33
  - iOS
12
34
  - Plugin now supports iOS 10.0 and above
@@ -19,44 +41,44 @@ Release Date: 25th February 2021
19
41
  - Added APIs to enable and disable MoEngage SDK.
20
42
  - Added API to register a callback for push token generated event.
21
43
 
22
- ## 6.1.7
44
+ ### 6.1.7
23
45
  Release Date: 15th February 2021
24
46
  - Android artifacts use manven central instead of Jcenter.
25
47
  - Android Native SDK version `10.6.01`
26
48
  - Android Plugin Base `1.2.01`
27
49
 
28
- ## 6.1.6
50
+ ### 6.1.6
29
51
  Release Date: 21st January 2021
30
52
  - BugFix iOS: Token registered event skipped as its currently not supported in React Native.
31
53
 
32
- ## 6.1.5
54
+ ### 6.1.5
33
55
  Release Date: 18th January 2021
34
56
  - iOS Base Plugin dependency updated to support version `1.2` and above.
35
57
 
36
- ## 6.1.4
58
+ ### 6.1.4
37
59
  Release Date: 7th December 2020
38
60
  - Support for extending Native Android Callbacks if required.
39
61
  - Native Android SDK version required is `10.5.00` or above.
40
62
  - iOS Base Plugin Updated to version `1.1.1` to ensure SDK sets the UNUserNotification Center delegate only in cases where its `nil`.
41
63
 
42
- ## 6.1.3
64
+ ### 6.1.3
43
65
  Release Date: 25th November 2020
44
66
  - Android Base plugin dependency type updated to ensure compatability across gradle versions.
45
67
 
46
- ## 6.1.2
68
+ ### 6.1.2
47
69
  Release Date: 23rd November 2020
48
70
  - Android Base Plugin Updated to enable Custom Callbacks.
49
71
 
50
- ## 6.1.1
72
+ ### 6.1.1
51
73
  Release Date: 22nd October 2020
52
74
  - Bugfix
53
75
  - Events not being marked as non-interactive on Android
54
76
 
55
- ## 6.1.0
77
+ ### 6.1.0
56
78
  Release Date: 23rd September, 2020
57
79
  - Support for Push Templates added
58
80
 
59
- ## 6.0.0
81
+ ### 6.0.0
60
82
  Release Date: 7th August 2020
61
83
  - 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.
62
84
  - Support for Self-Handled In-App
@@ -83,14 +105,14 @@ Release Date: 23rd September, 2020
83
105
  | ReactMoE.passPushToken(string) | ReactMoE.passFcmPushToken(string) |
84
106
  | ReactMoE.passPushPayload(JSONObject) | ReactMoE.passFcmPushPayload(JSONObject) |
85
107
 
86
- ## 5.0.0
108
+ ### 5.0.0
87
109
  Release Date: 18th Feb 2020
88
110
  - New Event Listeners added for both iOS and Android platforms i.e, `pushClicked`, `inAppCampaignShown` and `inAppCampaignShown`.
89
111
  - Earlier iOS Push and InApp Events deprecated to have it common for both Android and iOS (`notificationClicked`,`inAppShown` and `inAppClicked`)
90
112
  - APIs to pass push token and payload from React-Native Component/Javascript (Android Only API)
91
113
  - Fixing datatype conversion for user attributes long getting converted to double.
92
114
 
93
- ## 4.1.0
115
+ ### 4.1.0
94
116
  Release Date: 23rd Dec 2019
95
117
  - Android SDK version updated to 9.8.01
96
118
  - integration_type and integration_version added for both Android and iOS
package/README.md CHANGED
@@ -10,23 +10,46 @@ $ react-native link
10
10
  After installing the plugin lets move on to platform specific configuration.
11
11
 
12
12
  ### Android
13
- In android/settings.gradle add the following
13
+ Add `mavenCentral()` repository in the project-level `build.gradle` file.
14
+
15
+ ```groovy
16
+ buildscript {
17
+ repositories
18
+ {
19
+ mavenCentral()
20
+ }
21
+ }
22
+
23
+ allprojects {
24
+ repositories {
25
+ mavenCentral()
26
+ }
27
+ }
14
28
  ```
29
+
30
+ In android/settings.gradle add the following
31
+
32
+ ```groovy
15
33
  include ':react-native-moengage'
16
34
  project(':react-native-moengage').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-moengage/android')
17
35
  ```
18
36
 
19
37
  In android/app/build.gradle add the following
20
- ```
38
+
39
+ ```groovy
21
40
  dependencies {
22
41
  ...
23
42
 
24
- compile project(':react-native-moengage')
43
+ implementation project(':react-native-moengage')
44
+ implementation("com.moengage:moe-android-sdk:11.6.02")
45
+ implementation("androidx.core:core:1.3.1")
46
+ implementation("androidx.appcompat:appcompat:1.2.0")
47
+ implementation("androidx.lifecycle:lifecycle-process:2.2.0")
25
48
  }
26
49
  ```
27
50
  Add the MoEngage React Package in the Application class's getPackages() Also enable auto integration in the onCreate()
28
51
 
29
- ```
52
+ ```java
30
53
  public class MainApplication extends Application implements ReactApplication {
31
54
 
32
55
  private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) {
@@ -55,7 +78,7 @@ Add the MoEngage React Package in the Application class's getPackages() Also ena
55
78
  ```
56
79
  In case you are facing issues with the import add the below import statement in your java file.
57
80
 
58
- ```
81
+ ```java
59
82
  import com.moengage.react.MoEReactPackage;
60
83
  ```
61
84
 
@@ -69,4 +92,4 @@ Incase if you get errors in the test targets of the project, go to build setting
69
92
 
70
93
  Thats it!! SDK is successfully installed in the project, and ready to use.
71
94
 
72
- For more info on how to use react-native-moengage, refer to our developer docs: https://docs.moengage.com/docs/sdk-integration-2
95
+ For more info on how to use react-native-moengage, refer to our developer docs: https://developers.moengage.com/hc/en-us/categories/4404199274900-React-Native-SDK
@@ -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.2.00"
26
- basePluginVersion = "2.1.00"
26
+ moengageVersion = "11.6.02"
27
+ basePluginVersion = "2.2.2"
27
28
  //build versions
28
29
  minimumVersion = 16
29
30
  targetVersion = 29
@@ -196,6 +196,26 @@ 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
+
209
+ @ReactMethod
210
+ fun deviceIdentifierTrackingStatusUpdate(payload: String) {
211
+ try {
212
+ Logger.v("$tag deviceIdentifierTrackingStatusUpdate(): $payload")
213
+ pluginHelper.deviceIdentifierTrackingStatusUpdate(context, payload)
214
+ } catch (e: Exception) {
215
+ Logger.e("$tag deviceIdentifierTrackingStatusUpdate() : ", e)
216
+ }
217
+ }
218
+
199
219
 
200
220
  init {
201
221
  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
+ }
@@ -4,7 +4,6 @@ import com.facebook.react.ReactPackage
4
4
  import com.facebook.react.bridge.NativeModule
5
5
  import com.facebook.react.bridge.ReactApplicationContext
6
6
  import com.facebook.react.uimanager.ViewManager
7
- import java.util.*
8
7
 
9
8
  /**
10
9
  * @author Umang Chamaria
@@ -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.2.0",
3
+ "version": "7.4.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
  "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,7 +708,62 @@ 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
+ }
718
+ },
719
+
720
+ /**
721
+ * API to enable Advertising Id tracking for Android.
722
+ */
723
+ enableAdIdTracking: function() {
724
+ console.log("Will enable advertising-id tracking");
725
+ if(Platform.OS == PLATFORM_ANDROID) {
726
+ MoERNAndroid.enableAdIdTracking();
727
+ }
728
+ },
729
+
730
+ /**
731
+ * API to disable Advertising Id tracking for Android.
732
+ *
733
+ * By default Advertising Id tracking is disabled, call this method only if you have enabled
734
+ * Advertising Id tracking at some point.
735
+ */
736
+ disableAdIdTracking: function() {
737
+ console.log("Will disable advertising-id tracking");
738
+ if(Platform.OS == PLATFORM_ANDROID) {
739
+ MoERNAndroid.disableAdIdTracking();
740
+ }
741
+ },
742
+
743
+ /**
744
+ * API to enable Android Id tracking for Android.
745
+ */
746
+ enableAndroidIdTracking: function() {
747
+ console.log("Will enable android-id tracking");
748
+ if(Platform.OS == PLATFORM_ANDROID) {
749
+ MoERNAndroid.enableAndroidIdTracking();
750
+ }
751
+ },
752
+
753
+ /**
754
+ * API to disable Android Id tracking for Android.
755
+ *
756
+ * By default Android Id tracking is disabled, call this method only if you have enabled
757
+ * Advertising Id tracking at some point.
758
+ */
759
+ disableAndroidIdTracking: function() {
760
+ console.log("Will disable android-id tracking");
761
+ if(Platform.OS == PLATFORM_ANDROID) {
762
+ MoERNAndroid.disableAndroidIdTracking();
763
+ }
705
764
  }
765
+
766
+
706
767
  };
707
768
 
708
769
  export {
@@ -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,38 @@ export class MoERNAndroid {
141
141
  };
142
142
  MoEReactBridge.updateSdkState(JSON.stringify(payload));
143
143
  }
144
+
145
+ static onOrientationChanged() {
146
+ MoEReactBridge.onOrientationChanged()
147
+ }
148
+
149
+ static enableAdIdTracking() {
150
+ let payload = {
151
+ "isAdIdTrackingEnabled": true
152
+ }
153
+ MoEReactBridge.deviceIdentifierTrackingStatusUpdate(JSON.stringify(payload))
154
+ }
155
+
156
+ static disableAdIdTracking() {
157
+ let payload = {
158
+ "isAdIdTrackingEnabled": false
159
+ }
160
+ MoEReactBridge.deviceIdentifierTrackingStatusUpdate(JSON.stringify(payload))
161
+ }
162
+
163
+ static enableAndroidIdTracking() {
164
+ let payload = {
165
+ "isAndroidIdTrackingEnabled": true
166
+ }
167
+ MoEReactBridge.deviceIdentifierTrackingStatusUpdate(JSON.stringify(payload))
168
+ }
169
+
170
+ static disableAndroidIdTracking() {
171
+ let payload = {
172
+ "isAndroidIdTrackingEnabled": false
173
+ }
174
+ MoEReactBridge.deviceIdentifierTrackingStatusUpdate(JSON.stringify(payload))
175
+ }
144
176
  }
145
177
 
146
178
  const PUSH_SERVICE_FCM = "FCM"