react-native-moengage 8.7.1 → 9.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 CHANGED
@@ -1,3 +1,15 @@
1
+ # 18-03-2024
2
+
3
+ ## 9.0.0
4
+ - Added Nudge Support
5
+ - Bugfix
6
+ - Exception thrown `MoEInAppSelfHandledCampaign is an invalid object` while logging
7
+ - iOS
8
+ - MoEngage-iOS-SDK version updated to `~>9.16.1`.
9
+ - Android
10
+ - Support for MoEngage Core 13.00.00 and above
11
+ - Added support for AGP `8.2.2` and above
12
+
1
13
  # 12-02-2024
2
14
 
3
15
  ## 8.7.1
package/LICENSE.txt ADDED
@@ -0,0 +1,8 @@
1
+ The Licensee desires to conduct a technical trial (hereafter referred to as the "Trial") or deployment of the source code or binaries contained within MoEngage SDK (“Software”) under a limited license from the Licensor.
2
+
3
+
4
+ The Licensee may not modify: (i) permit any third party to use the Software; (ii) modify or translate the Software except as otherwise permitted; (iii) reverse engineer, decompile, or disassemble the Software; (iv) copy the Software, except as expressly provided above; or (vi) remove or obscure any proprietary rights notices or labels on the Software.
5
+ Licensee may not transfer the Software or any rights under this Agreement without the Licensor's prior written consent.
6
+ MoEngage owns the Software and all intellectual property rights embodied therein, including copyrights and valuable trade secrets embodied in the Software.
7
+ The Licensee shall not alter or remove this copyright notice.
8
+ 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 THE USER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
package/README.md CHANGED
@@ -1,88 +1,9 @@
1
- # React Native MoEngage
1
+ # React Native MoEngage
2
2
 
3
- ## SDK Installation
4
- Install MoEngage's React Native plugin using the npm package manager. And then link your native dependencies :
5
- ```
6
- $ npm install react-native-moengage
7
- $ react-native link
8
- ```
3
+ This plugin is for using the MoEngage platform. Using this plugin you can use the following features of the MoEngage platform
9
4
 
10
- After installing the plugin lets move on to platform specific configuration.
5
+ - Analytics/Data Tracking
6
+ - Push Notification
7
+ - InApp Notifications
11
8
 
12
- ### Android
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
- }
28
- ```
29
-
30
- In android/settings.gradle add the following
31
-
32
- ```groovy
33
- include ':react-native-moengage'
34
- project(':react-native-moengage').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-moengage/android')
35
- ```
36
-
37
- In android/app/build.gradle add the following
38
-
39
- ```groovy
40
- dependencies {
41
- ...
42
-
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")
48
- }
49
- ```
50
- Add the MoEngage React Package in the Application class's getPackages() Also enable auto integration in the onCreate()
51
-
52
- ```java
53
- public class MainApplication extends Application implements ReactApplication {
54
-
55
- private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) {
56
- @Override
57
- protected boolean getUseDeveloperSupport() {
58
- return BuildConfig.DEBUG;
59
- }
60
-
61
- @Override
62
- protected List<ReactPackage> getPackages() {
63
- return Arrays.<ReactPackage>asList(
64
- new MainReactPackage(), new MoEReactPackage());
65
- }
66
- };
67
-
68
- @Override public void onCreate() {
69
- super.onCreate();
70
- MoEHelper.getInstance(getApplicationContext()).autoIntegrate(this);
71
- }
72
-
73
- @Override
74
- public ReactNativeHost getReactNativeHost() {
75
- return mReactNativeHost;
76
- }
77
- }
78
- ```
79
- In case you are facing issues with the import add the below import statement in your java file.
80
-
81
- ```java
82
- import com.moengage.react.MoEReactPackage;
83
- ```
84
-
85
- ### iOS
86
- There are no additional steps required for installation.
87
-
88
- 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
9
+ Refer to our [integration documentation](https://developers.moengage.com/hc/en-us/categories/4404199274900-React-Native-SDK) to learn more on how to integrate and use the plugin.
@@ -15,8 +15,8 @@ Pod::Spec.new do |s|
15
15
  s.platforms = { :ios => "11.0", :tvos => "11.0" }
16
16
  s.source_files = 'iOS/MoEReactBridge/**/*.{h,m}'
17
17
  s.dependency 'React'
18
- s.dependency 'MoEngagePluginBase','>= 4.6.0','< 4.7.0'
19
- s.ios.dependency 'MoEngageRichNotification','>= 7.14.0','< 7.15.0'
18
+ s.dependency 'MoEngagePluginBase','>= 4.7.0','< 4.8.0'
19
+ s.ios.dependency 'MoEngageRichNotification','>= 7.15.0','< 7.16.0'
20
20
 
21
21
  s.prepare_command = <<-CMD
22
22
  echo // Generated file, do not edit > iOS/MoEReactBridge/MoEngageReactPluginInfo.h
@@ -6,7 +6,7 @@ buildscript {
6
6
  }
7
7
 
8
8
  dependencies {
9
- classpath 'com.android.tools.build:gradle:8.0.2'
9
+ classpath 'com.android.tools.build:gradle:8.2.2'
10
10
  classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion"
11
11
  }
12
12
  }
@@ -20,12 +20,11 @@ rootProject.allprojects {
20
20
 
21
21
  ext {
22
22
  //dependency version
23
- moengageCoreVersion = "12.10.00"
24
- moengageInAppVersion = "7.1.0"
25
- basePluginVersion = "3.4.0"
23
+ moengageCoreVersion = "13.00.01"
24
+ moengageInAppVersion = "8.1.0"
25
+ basePluginVersion = "4.0.0"
26
26
  //build versions
27
27
  minimumVersion = 21
28
- targetVersion = 33
29
28
  compileVersion = 33
30
29
  }
31
30
 
@@ -37,7 +36,6 @@ android {
37
36
  namespace "com.moengage.react"
38
37
  defaultConfig {
39
38
  minSdk minimumVersion
40
- targetSdk targetVersion
41
39
  versionCode 1
42
40
  versionName "1.0"
43
41
 
@@ -58,6 +56,9 @@ android {
58
56
  kotlinOptions {
59
57
  freeCompilerArgs = ['-Xjvm-default=all']
60
58
  }
59
+ buildFeatures {
60
+ buildConfig true
61
+ }
61
62
  }
62
63
 
63
64
  dependencies {
@@ -1,6 +1,6 @@
1
1
  #Thu Aug 18 13:23:11 IST 2022
2
2
  distributionBase=GRADLE_USER_HOME
3
- distributionUrl=https\://services.gradle.org/distributions/gradle-8.1-all.zip
3
+ distributionUrl=https\://services.gradle.org/distributions/gradle-8.2-all.zip
4
4
  distributionPath=wrapper/dists
5
5
  zipStorePath=wrapper/dists
6
6
  zipStoreBase=GRADLE_USER_HOME
@@ -1,2 +1 @@
1
- android.useAndroidX=true
2
- android.defaults.buildfeatures.buildconfig=true
1
+ android.useAndroidX=true
@@ -67,7 +67,8 @@ class EventEmitterImpl(private val reactContext: ReactContext) : EventEmitter {
67
67
  private fun emitInAppSelfHandled(event: InAppSelfHandledEvent) {
68
68
  Logger.print { "$tag emitInAppSelfHandled() : $event" }
69
69
  val eventName = eventMapping[event.eventType] ?: return
70
- val payload = PayloadGenerator().selfHandledDataToWriteableMap(event.data)
70
+ val payload =
71
+ PayloadGenerator().selfHandledDataToWriteableMap(event.accountMeta, event.data)
71
72
  emit(eventName, payload)
72
73
  }
73
74
 
@@ -189,9 +189,9 @@ class MoEReactBridge(private val reactContext: ReactApplicationContext) :
189
189
  @ReactMethod
190
190
  fun validateSdkVersion(promise: Promise) {
191
191
  Logger.print { "$tag validateSdkVersion() : Validating Version" }
192
- if (moeSdkVersion > 130000) {
192
+ if (moeSdkVersion > 140000) {
193
193
  Logger.print(LogLevel.ERROR) { "$tag validateSdkVersion() : invalid version" }
194
- promise.reject("error", "Use SDK version 12.x.xx")
194
+ promise.reject("error", "Use SDK version less than 14.xx.xx")
195
195
  } else {
196
196
  Logger.print { "$tag validateSdkVersion() : valid version" }
197
197
  promise.resolve("valid version");
@@ -294,4 +294,18 @@ class MoEReactBridge(private val reactContext: ReactApplicationContext) :
294
294
  promise.reject(t)
295
295
  }
296
296
  }
297
+
298
+ /**
299
+ * Try to show a non-intrusive In-App nudge
300
+ * @since Todo: Add Version
301
+ */
302
+ @ReactMethod
303
+ fun showNudge(payload: String) {
304
+ try {
305
+ Logger.print { "$tag showNudge() : Payload: $payload" }
306
+ pluginHelper.showNudge(context, payload)
307
+ } catch (t: Throwable) {
308
+ Logger.print(LogLevel.ERROR, t) { "$tag showNudge() :" }
309
+ }
310
+ }
297
311
  }
@@ -3,6 +3,7 @@ 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.core.model.AccountMeta
6
7
  import com.moengage.inapp.model.ClickData
7
8
  import com.moengage.inapp.model.InAppData
8
9
  import com.moengage.inapp.model.SelfHandledCampaignData
@@ -51,10 +52,13 @@ internal class PayloadGenerator {
51
52
  return map
52
53
  }
53
54
 
54
- fun selfHandledDataToWriteableMap(data: SelfHandledCampaignData): WritableMap {
55
- val map = Arguments.createMap()
56
- val json = selfHandledDataToJson(data)
55
+ fun selfHandledDataToWriteableMap(
56
+ accountMeta: AccountMeta,
57
+ data: SelfHandledCampaignData?
58
+ ): WritableMap {
57
59
  Logger.print { "$tag selfHandledDataToWriteableMap() : $data" }
60
+ val map = Arguments.createMap()
61
+ val json = selfHandledDataToJson(accountMeta, data)
58
62
  map.putString(ARGUMENT_PAYLOAD, json.toString())
59
63
  return map
60
64
  }
@@ -140,6 +140,11 @@ RCT_EXPORT_METHOD(showInApp:(NSDictionary *)payload)
140
140
  [[MoEngagePluginBridge sharedInstance] showInApp:payload];
141
141
  }
142
142
 
143
+ RCT_EXPORT_METHOD(showNudge:(NSDictionary *)payload)
144
+ {
145
+ [[MoEngagePluginBridge sharedInstance] showNudge: payload];
146
+ }
147
+
143
148
  #pragma mark Self handled In App
144
149
 
145
150
  RCT_EXPORT_METHOD(getSelfHandledInApp:(NSDictionary *)payload)
@@ -109,7 +109,8 @@
109
109
  }
110
110
 
111
111
  if ([moeDict objectForKey:kEnableLogs] != nil && [moeDict objectForKey:kEnableLogs] != [NSNull null]) {
112
- sdkConfig.enableLogs = [MoEngageReactUtils getBooleanForKey:kEnableLogs dict:moeDict];
112
+ BOOL isLogsEnabled = [MoEngageReactUtils getBooleanForKey:kEnableLogs dict:moeDict];
113
+ sdkConfig.consoleLogConfig = [[MoEngageConsoleLogConfig alloc] initWithIsLoggingEnabled:isLogsEnabled loglevel:MoEngageLoggerTypeVerbose];
113
114
  }
114
115
  }
115
116
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-moengage",
3
- "version": "8.7.1",
3
+ "version": "9.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
  "files": [
@@ -26,11 +26,14 @@
26
26
  "scripts": {
27
27
  "test": "echo \"Error: no test specified\" && exit 1"
28
28
  },
29
- "author": "MoEngage",
29
+ "author": {
30
+ "name": "MoEngage",
31
+ "email": "mobiledevs@moengage.com"
32
+ },
30
33
  "contributors": [
31
34
  "MoEngage <mobiledevs@moengage.com>"
32
35
  ],
33
- "license": "ISC",
36
+ "license": "SEE LICENSE IN LICENSE.txt",
34
37
  "devDependencies": {
35
38
  "@types/react-native": "^0.69.3"
36
39
  }
package/src/index.ts CHANGED
@@ -10,6 +10,7 @@ import {MoERNiOS} from "./platform/MoERNiOS";
10
10
  import MoEInAppCustomAction from "./models/MoEInAppCustomAction";
11
11
  import MoEInAppNavigation from "./models/MoEInAppNavigation";
12
12
  import {executeHandler} from "./utils/MoEEventHandlerHelper";
13
+
13
14
  import {
14
15
  getAdIdTrackingJson,
15
16
  getAliasJson,
@@ -27,7 +28,8 @@ import {
27
28
  getUserLocAttributeJson,
28
29
  getPushPermissionRequestCountJson,
29
30
  getDeviceIdTrackingJson,
30
- getInitConfigJson
31
+ getInitConfigJson,
32
+ getNudgeDisplayJson
31
33
  } from "./utils/MoEJsonBuilder";
32
34
  import {
33
35
  USER_ATTRIBUTE_UNIQUE_ID,
@@ -50,6 +52,7 @@ import MoEngageGlobalCache from "./utils/MoEngageGlobalCache";
50
52
  import MoEngageLogger from "./logger/MoEngageLogger";
51
53
  import UserDeletionData from "./models/UserDeletionData";
52
54
  import MoEAccountMeta from "./models/MoEAccountMeta";
55
+ import { MoEngageNudgePosition } from "./models/MoEngageNudgePosition";
53
56
 
54
57
  const MoEReactBridge = require("react-native").NativeModules.MoEReactBridge;
55
58
  const PLATFORM_ANDROID = "android";
@@ -465,6 +468,20 @@ var ReactMoE = {
465
468
  }
466
469
  },
467
470
 
471
+ /**
472
+ * Call This method to show the nudge
473
+ * @param position position at which nudge should be displayed.
474
+ */
475
+ showNudge: function(position: MoEngageNudgePosition = MoEngageNudgePosition.Any){
476
+ commonValidationCheck();
477
+ let jsonPayload = getNudgeDisplayJson(position, moeAppId);
478
+ if (Platform.OS == PLATFORM_ANDROID) {
479
+ MoERNAndroid.showNudge(jsonPayload);
480
+ } else if (Platform.OS == PLATFORM_IOS) {
481
+ MoERNiOS.showNudge(jsonPayload);
482
+ }
483
+ },
484
+
468
485
  /**
469
486
  * Call this method when you show the self handled in-app so we can update impressions.
470
487
  * @param {MoESelfHandledCampaignData}campInfo : campaign information object
@@ -834,6 +851,7 @@ export {
834
851
  MoEPushConfig,
835
852
  MoEngageLogConfig,
836
853
  MoEngageLogLevel,
837
- MoEngageLogger
854
+ MoEngageLogger,
855
+ MoEngageNudgePosition,
838
856
  };
839
857
  export default ReactMoE;
@@ -1,6 +1,5 @@
1
1
  export enum MoEPushService {
2
2
  APNS = "APNS",
3
3
  FCM = "FCM",
4
- MI_PUSH = "MI_PUSH",
5
4
  PUSH_KIT = "PUSH_KIT",
6
5
  }
@@ -0,0 +1,7 @@
1
+ export enum MoEngageNudgePosition {
2
+ Top = "top",
3
+ Bottom = "bottom",
4
+ BottomLeft = "bottomLeft",
5
+ BottomRight = "bottomRight",
6
+ Any = "any"
7
+ }
@@ -111,7 +111,7 @@ export function getMoESelfHandledCampaignData(json: { [k: string]: any }, accoun
111
111
  var campaign = getMoESelfHandledCampaign(json);
112
112
  return new MoESelfHandledCampaignData(accountMeta, platform, campaign, campaignData);
113
113
  }
114
- else return undefined
114
+ else return null
115
115
  }
116
116
 
117
117
 
@@ -160,13 +160,16 @@ export function isSelfHandledCampaignValid(obj: { [k: string]: any }) {
160
160
  try {
161
161
  if (obj[MOE_SELF_HANDLED] != undefined && isValidObject(obj[MOE_SELF_HANDLED])) {
162
162
  var selfHandled = obj[MOE_SELF_HANDLED];
163
- if (selfHandled[MOE_PAYLOAD] != undefined && selfHandled[MOE_DISMISSINTERVAL] != undefined)
163
+ if (selfHandled[MOE_PAYLOAD] != undefined && selfHandled[MOE_DISMISSINTERVAL] != undefined) {
164
+ MoEngageLogger.info("SelfHandled campaign has data");
164
165
  return true;
165
- else throw new Error(MOE_SELF_HANDLED_OBJ_ERROR);
166
+ } else {
167
+ MoEngageLogger.info("SelfHandled campaign has no data");
168
+ return false;
169
+ }
166
170
 
167
- }
168
- else {
169
- throw new Error(MOE_SELF_HANDLED_OBJ_ERROR);
171
+ } else {
172
+ return false;
170
173
  }
171
174
  }
172
175
  catch (error: any) {
@@ -161,4 +161,12 @@ export class MoERNAndroid {
161
161
  const deleteUserPayload = await MoEReactBridge.deleteUser(JSON.stringify(payload));
162
162
  return getUserDeletionData(deleteUserPayload);
163
163
  }
164
+
165
+ /**
166
+ * Try to show a non-intrusive In-App nudge
167
+ * @since Todo: Add Version
168
+ */
169
+ static showNudge(payload: { [k: string]: any }) {
170
+ MoEReactBridge.showNudge(JSON.stringify(payload));
171
+ }
164
172
  }
@@ -31,6 +31,10 @@ export class MoERNiOS {
31
31
  MoEReactBridge.showInApp(payload);
32
32
  }
33
33
 
34
+ static showNudge(payload: { [k: string]: any }) {
35
+ MoEReactBridge.showNudge(payload);
36
+ }
37
+
34
38
  static getSelfHandledInApp(payload: { [k: string]: any }) {
35
39
  MoEReactBridge.getSelfHandledInApp(payload);
36
40
  }
@@ -7,6 +7,7 @@ import { MoEPropertiesToJson} from "./MoEObjectToJson";
7
7
  import {MoEngagePermissionType} from "../models/MoEngagePermissionType";
8
8
  import MoEInitConfig from "../models/MoEInitConfig";
9
9
  import MoEngageLogger from "../logger/MoEngageLogger";
10
+ import { MoEngageNudgePosition } from "../models/MoEngageNudgePosition";
10
11
 
11
12
  export function getInAppCampaignJson(moEInAppData: MoEInAppData, type: string, appId: String) {
12
13
  var json: { [k: string]: any } = {
@@ -267,4 +268,16 @@ export function getInitConfigJson(appId: String, initConfig: MoEInitConfig) {
267
268
  }
268
269
  }
269
270
  return json;
270
- }
271
+ }
272
+
273
+ export function getNudgeDisplayJson(nudgePosition: MoEngageNudgePosition, appId: String) {
274
+ var json: { [k: string]: any } = {
275
+ accountMeta: {
276
+ appId: appId
277
+ },
278
+ data: {
279
+ position: nudgePosition.toString()
280
+ }
281
+ }
282
+ return json;
283
+ }