react-native-moengage 7.4.0 → 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.
Files changed (53) hide show
  1. package/CHANGELOG.md +57 -3
  2. package/README.md +29 -6
  3. package/ReactNativeMoEngage.podspec +3 -3
  4. package/android/build.gradle +11 -12
  5. package/android/gradle/wrapper/gradle-wrapper.properties +3 -3
  6. package/android/gradle.properties +0 -1
  7. package/android/src/main/java/com/moengage/react/EventEmitterImpl.kt +46 -21
  8. package/android/src/main/java/com/moengage/react/MoEInitializer.kt +44 -13
  9. package/android/src/main/java/com/moengage/react/MoEReactBridge.kt +87 -80
  10. package/android/src/main/java/com/moengage/react/MoEReactHelper.kt +2 -2
  11. package/android/src/main/java/com/moengage/react/MoEReactPackage.kt +0 -1
  12. package/android/src/main/java/com/moengage/react/PayloadGenerator.kt +32 -17
  13. package/iOS/MoEReactBridge/MoEReactBridge.h +1 -1
  14. package/iOS/MoEReactBridge/MoEReactBridge.m +34 -60
  15. package/iOS/MoEReactBridge/{MOReactInitializer.h → MoEngageInitializer.h} +11 -11
  16. package/iOS/MoEReactBridge/MoEngageInitializer.m +153 -0
  17. package/iOS/MoEReactBridge/{MoEReactConstants.h → MoEngageReactConstants.h} +12 -3
  18. package/iOS/MoEReactBridge/{MoEReactConstants.m → MoEngageReactConstants.m} +13 -7
  19. package/iOS/MoEReactBridge/MoEngageReactPluginInfo.h +2 -0
  20. package/iOS/MoEReactBridge.xcodeproj/project.pbxproj +6 -6
  21. package/package.json +8 -3
  22. package/src/index.ts +169 -190
  23. package/src/models/MoEAccountMeta.ts +8 -0
  24. package/src/models/MoEAction.ts +4 -0
  25. package/src/models/MoEActionType.ts +4 -0
  26. package/src/models/MoECampaignContext.ts +10 -0
  27. package/src/models/MoECampaignData.ts +14 -0
  28. package/src/models/MoEClickData.ts +18 -0
  29. package/src/models/MoEGeoLocation.ts +2 -10
  30. package/src/models/MoEInAppCustomAction.ts +8 -13
  31. package/src/models/MoEInAppData.ts +16 -0
  32. package/src/models/MoEInAppNavigation.ts +14 -24
  33. package/src/models/MoENavigationType.ts +4 -0
  34. package/src/models/MoEPlatform.ts +4 -0
  35. package/src/models/MoEProperties.ts +19 -15
  36. package/src/models/MoEPushCampaign.ts +6 -22
  37. package/src/models/MoEPushPayload.ts +14 -0
  38. package/src/models/MoEPushService.ts +4 -4
  39. package/src/models/MoEPushToken.ts +6 -15
  40. package/src/models/MoESelfHandledCampaign.ts +10 -0
  41. package/src/models/MoESelfHandledCampaignData.ts +18 -0
  42. package/src/moeParser/MoEInAppParser.ts +192 -0
  43. package/src/moeParser/MoEPushNotificationParser.ts +78 -0
  44. package/src/platform/MoERNAndroid.ts +48 -76
  45. package/src/platform/MoERNiOS.ts +27 -60
  46. package/src/utils/MoEConstants.ts +59 -0
  47. package/src/utils/MoEEventHandlerHelper.ts +38 -25
  48. package/src/utils/MoEJsonBuilder.ts +220 -0
  49. package/src/utils/MoEObjectToJson.ts +44 -0
  50. package/iOS/MoEReactBridge/MOReactInitializer.m +0 -172
  51. package/iOS/MoEReactBridge/MOReactPluginInfo.h +0 -2
  52. package/src/models/MoEInAppCampaign.ts +0 -46
  53. package/src/models/MoEInAppSelfHandledCampaign.ts +0 -34
package/CHANGELOG.md CHANGED
@@ -1,6 +1,60 @@
1
- # react-native-moengage
2
- ---
3
- ## Change Log:
1
+ ## 27-10-2022
2
+
3
+ ### 8.0.0
4
+ - Support for Android SDK version `12.3.02` and above.
5
+ - Support for iOS SDK version `8.3.1` and above.
6
+ - TS Lint warnings resolved.
7
+ - Breaking Changes
8
+ - InApp Model `MoEInAppCampaign` broken down from a single object to multiple objects
9
+ - `MoEInAppData`
10
+ - `MoEClickData`
11
+ - `MoESelfHandledCampaignData`
12
+ - Push Models
13
+ - `MoEPushCampaign` --> `MoEPushPayload`
14
+ - Breaking APIs in Javascript
15
+
16
+ | Then | Now |
17
+ |:------------:|:-----------------:|
18
+ | initialize() | initialize(appId) |
19
+
20
+ - Removed APIs
21
+
22
+ | Removed APIs |
23
+ |:---------------------------:|
24
+ | selfHandledPrimaryClicked() |
25
+ | enableSDKLogs() |
26
+ | optOutInAppNotification() |
27
+ | optOutPushNotification() |
28
+
29
+ - Android
30
+ - Build Configuration Updates
31
+ - Minimum SDK version - 21
32
+ - Target SDK version - 30
33
+ - Compile SDK Version - 30
34
+ - Mi SDK update to Version 5.x.x, refer to the [Configuring Xiaomi Push](https://developers.moengage.com/hc/en-us/articles/4403466194708) and update the integration.
35
+ - Deprecated APIs
36
+
37
+ | Then | Now |
38
+ |:--------------------------------------------------------------:|:-----------------------------------------------------------------------------:|
39
+ | MoEInitializer.initialize(Context, MoEngage.Builder) | MoEInitializer.initializeDefaultInstance(Context, MoEngage.Builder) |
40
+ | MoEInitializer.initialize(Context, MoEngage.Builder, SdkState) | MoEInitializer.initializeDefaultInstance(Context, MoEngage.Builder, SdkState) |
41
+
42
+ - iOS
43
+ - `MOReactInitializer` renamed to `MoEngageInitializer`
44
+ - Deprecated APIs
45
+
46
+ | Then | Now |
47
+ |:-------------------------------------------------------------------------------------------------------------------------------------:|:-----------------------------------------------------------------------------------------------------------------------------------------:|
48
+ | - (void)intializeSDKWithLaunchOptions:(NSDictionary*)launchOptions; | - (void)initializeDefaultInstance:(NSDictionary*)launchOptions; |
49
+ | - (void)intializeSDKWithState:(BOOL)isSdkEnabled andLaunchOptions:(NSDictionary*)launchOptions; | - (void)initializeDefaultInstance:(BOOL)isSdkEnabled andLaunchOptions:(NSDictionary*)launchOptions; |
50
+ | - (void)intializeSDKWithConfig:(MOSDKConfig*)sdkConfig andLaunchOptions:(NSDictionary*)launchOptions; | - (void)initializeDefaultSDKConfig:(MOSDKConfig*)sdkConfig andLaunchOptions:(NSDictionary*)launchOptions; |
51
+ | - (void)intializeSDKWithConfig:(MOSDKConfig*)sdkConfig withSDKState:(BOOL)isSdkEnabled andLaunchOptions:(NSDictionary*)launchOptions; | - (void)initializeDefaultSDKConfig:(MOSDKConfig*)sdkConfig withSDKState:(BOOL)isSdkEnabled andLaunchOptions:(NSDictionary*)launchOptions; |
52
+
53
+
54
+ ### 7.4.1
55
+ Release Date: 15th July 2022
56
+ - Device identifier tracking update as per Google's User data policy. Advertising Id is only tracked after user consent.
57
+
4
58
  ### 7.4.0
5
59
  Release Date: 12th May 2022
6
60
  - Bugfix iOS: Fixed the PushClick callback issue in terminated state, that was appearing when the react-native version is above 0.65.
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,10 +15,10 @@ 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.3.0','< 2.4.0'
18
+ s.dependency 'MoEngagePluginBase','>= 3.0.0','< 3.1.0'
19
19
 
20
20
  s.prepare_command = <<-CMD
21
- echo // Generated file, do not edit > iOS/MoEReactBridge/MOReactPluginInfo.h
22
- echo "#define MO_REACT_PLUGIN_VERSION @\\"#{package["version"]}\\"" >> iOS/MoEReactBridge/MOReactPluginInfo.h
21
+ echo // Generated file, do not edit > iOS/MoEReactBridge/MoEngageReactPluginInfo.h
22
+ echo "#define MOE_REACT_PLUGIN_VERSION @\\"#{package["version"]}\\"" >> iOS/MoEReactBridge/MoEngageReactPluginInfo.h
23
23
  CMD
24
24
  end
@@ -1,13 +1,12 @@
1
1
  buildscript {
2
- ext.kotlinVersion = '1.4.20'
2
+ ext.kotlinVersion = '1.6.0'
3
3
  repositories {
4
4
  google()
5
5
  mavenCentral()
6
- jcenter()
7
6
  }
8
7
 
9
8
  dependencies {
10
- classpath 'com.android.tools.build:gradle:4.1.2'
9
+ classpath 'com.android.tools.build:gradle:7.1.2'
11
10
  classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion"
12
11
  }
13
12
  }
@@ -15,20 +14,19 @@ buildscript {
15
14
  rootProject.allprojects {
16
15
  repositories {
17
16
  google()
18
- mavenLocal()
19
17
  mavenCentral()
20
- jcenter()
21
18
  }
22
19
  }
23
20
 
24
21
  ext {
25
22
  //dependency version
26
- moengageVersion = "11.4.00"
27
- basePluginVersion = "2.2.0"
23
+ moengageCoreVersion = "12.2.04"
24
+ moengageInAppVersion = "6.3.0"
25
+ basePluginVersion = "3.0.0"
28
26
  //build versions
29
- minimumVersion = 16
30
- targetVersion = 29
31
- compileVersion = 29
27
+ minimumVersion = 21
28
+ targetVersion = 30
29
+ compileVersion = 30
32
30
  }
33
31
 
34
32
  apply plugin: 'com.android.library'
@@ -66,9 +64,10 @@ dependencies {
66
64
  implementation fileTree(include: ['*.jar'], dir: 'libs')
67
65
 
68
66
  implementation("org.jetbrains.kotlin:kotlin-stdlib:$kotlinVersion")
69
-
70
- compileOnly ("com.moengage:moe-android-sdk:$moengageVersion")
67
+
68
+ compileOnly ("com.moengage:moe-android-sdk:$moengageCoreVersion")
71
69
  api("com.moengage:plugin-base:$basePluginVersion")
70
+ compileOnly("com.moengage:inapp:$moengageInAppVersion")
72
71
 
73
72
  compileOnly 'com.facebook.react:react-native:+'
74
73
 
@@ -1,6 +1,6 @@
1
- #Sun Jan 31 18:33:58 IST 2021
1
+ #Thu Aug 18 13:23:11 IST 2022
2
2
  distributionBase=GRADLE_USER_HOME
3
+ distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-all.zip
3
4
  distributionPath=wrapper/dists
4
- zipStoreBase=GRADLE_USER_HOME
5
5
  zipStorePath=wrapper/dists
6
- distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-all.zip
6
+ zipStoreBase=GRADLE_USER_HOME
@@ -1,2 +1 @@
1
- android.enableJetifier=true
2
1
  android.useAndroidX=true
@@ -3,9 +3,16 @@ package com.moengage.react
3
3
  import com.facebook.react.bridge.ReactContext
4
4
  import com.facebook.react.bridge.WritableMap
5
5
  import com.facebook.react.modules.core.DeviceEventManagerModule
6
+ import com.moengage.core.LogLevel
6
7
  import com.moengage.core.internal.logger.Logger
7
- import com.moengage.plugin.base.EventEmitter
8
- import com.moengage.plugin.base.model.*
8
+ import com.moengage.plugin.base.internal.EventEmitter
9
+ import com.moengage.plugin.base.internal.model.events.Event
10
+ import com.moengage.plugin.base.internal.model.events.EventType
11
+ import com.moengage.plugin.base.internal.model.events.inapp.InAppActionEvent
12
+ import com.moengage.plugin.base.internal.model.events.inapp.InAppLifecycleEvent
13
+ import com.moengage.plugin.base.internal.model.events.inapp.InAppSelfHandledEvent
14
+ import com.moengage.plugin.base.internal.model.events.push.PushClickedEvent
15
+ import com.moengage.plugin.base.internal.model.events.push.TokenEvent
9
16
 
10
17
 
11
18
  /**
@@ -17,35 +24,53 @@ class EventEmitterImpl(private val reactContext: ReactContext) : EventEmitter {
17
24
 
18
25
  override fun emit(event: Event) {
19
26
  try {
20
- Logger.v("$tag emit() : $event")
21
- when(event){
22
- is InAppEvent -> emitInAppEvent(event)
23
- is PushEvent -> emitPushEvent(event)
24
- is TokenEvent -> emitPushToken(event)
27
+ Logger.print { "$tag emit() : $event" }
28
+ when (event.eventType) {
29
+ EventType.PUSH_CLICKED -> emitPushClicked(event as PushClickedEvent)
30
+ EventType.PUSH_TOKEN_GENERATED -> emitPushToken(event as TokenEvent)
31
+ EventType.INAPP_CLOSED, EventType.INAPP_SHOWN -> emitInAppLifecycle(event as InAppLifecycleEvent)
32
+ EventType.INAPP_CUSTOM_ACTION, EventType.INAPP_NAVIGATION -> emitInAppAction(
33
+ event as InAppActionEvent
34
+ )
35
+ EventType.INAPP_SELF_HANDLED_AVAILABLE -> emitInAppSelfHandled(event as InAppSelfHandledEvent)
25
36
  }
26
- } catch (e: Exception) {
27
- Logger.e("$tag emit() : ", e)
37
+ } catch (t: Throwable) {
38
+ Logger.print(LogLevel.ERROR, t) { "$tag emit() : " }
28
39
  }
29
40
  }
30
41
 
31
- private fun emitInAppEvent(inAppEvent: InAppEvent){
32
- Logger.v("$tag emitInAppEvent() : Event $inAppEvent")
33
- val eventName = eventMapping[inAppEvent.eventType] ?: return
34
- val payload = PayloadGenerator().inAppCampaignToWriteableMap(inAppEvent.inAppCampaign)
42
+ private fun emitInAppAction(event: InAppActionEvent) {
43
+ Logger.print { "$tag emitInAppNavigation() : $event" }
44
+ val eventName = eventMapping[event.eventType] ?: return
45
+ val payload = PayloadGenerator().inAppNavigationToWriteableMap(event.clickData)
35
46
  emit(eventName, payload)
36
47
  }
37
48
 
38
- private fun emitPushEvent(pushEvent: PushEvent){
39
- Logger.v("$tag emitPushEvent() : Event $pushEvent")
40
- val eventName = eventMapping[pushEvent.eventType] ?: return
41
- val payload = PayloadGenerator().pushPayloadToWriteableMap(pushEvent.payload)
49
+ private fun emitInAppLifecycle(event: InAppLifecycleEvent) {
50
+ Logger.print { "$tag emitInAppLifecycle() : $event" }
51
+ val eventName = eventMapping[event.eventType] ?: return
52
+ val payload = PayloadGenerator().inAppDataToWriteableMap(event.inAppData)
53
+ emit(eventName, payload)
54
+ }
55
+
56
+ private fun emitInAppSelfHandled(event: InAppSelfHandledEvent) {
57
+ Logger.print { "$tag emitInAppSelfHandled() : $event" }
58
+ val eventName = eventMapping[event.eventType] ?: return
59
+ val payload = PayloadGenerator().selfHandledDataToWriteableMap(event.data)
60
+ emit(eventName, payload)
61
+ }
62
+
63
+ private fun emitPushClicked(event: PushClickedEvent) {
64
+ Logger.print { "$tag emitPushClicked() : $event" }
65
+ val eventName = eventMapping[event.eventType] ?: return
66
+ val payload = PayloadGenerator().pushPayloadToWriteableMap(event.payload)
42
67
  emit(eventName, payload)
43
68
  }
44
69
 
45
70
  private fun emitPushToken(tokenEvent: TokenEvent) {
46
- Logger.v("$tag emitPushToken() : Event $tokenEvent")
71
+ Logger.print { "$tag emitPushToken() : $tokenEvent" }
47
72
  val eventName = eventMapping[tokenEvent.eventType] ?: return
48
- val payload = PayloadGenerator().tokenToWriteableMap(tokenEvent.pushToken)
73
+ val payload = PayloadGenerator().tokenToWriteableMap(tokenEvent)
49
74
  emit(eventName, payload)
50
75
  }
51
76
 
@@ -53,8 +78,8 @@ class EventEmitterImpl(private val reactContext: ReactContext) : EventEmitter {
53
78
  try {
54
79
  reactContext.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter::class.java)
55
80
  .emit(eventName, params)
56
- } catch (e: Exception) {
57
- Logger.e("$tag emit() : ", e)
81
+ } catch (t: Throwable) {
82
+ Logger.print(LogLevel.ERROR, t) { "$tag emit() : " }
58
83
  }
59
84
  }
60
85
  }
@@ -1,10 +1,12 @@
1
1
  package com.moengage.react
2
2
 
3
3
  import android.content.Context
4
+ import com.moengage.core.LogLevel
4
5
  import com.moengage.core.MoEngage
5
6
  import com.moengage.core.internal.logger.Logger
6
7
  import com.moengage.core.internal.model.IntegrationMeta
7
- import com.moengage.plugin.base.PluginInitializer.initialize
8
+ import com.moengage.core.model.SdkState
9
+ import com.moengage.plugin.base.internal.PluginInitializer
8
10
 
9
11
 
10
12
  /**
@@ -14,26 +16,55 @@ import com.moengage.plugin.base.PluginInitializer.initialize
14
16
  object MoEInitializer {
15
17
  private const val tag = "${MODULE_TAG}MoEInitializer"
16
18
 
19
+ @Deprecated(
20
+ "",
21
+ level = DeprecationLevel.WARNING,
22
+ replaceWith = ReplaceWith(
23
+ "initializeDefaultInstance(context, builder)",
24
+ "com.moengage.react.MoEInitializer.initializeDefaultInstance"
25
+ )
26
+ )
17
27
  fun initialize(context: Context, builder: MoEngage.Builder) {
28
+ initializeDefaultInstance(context, builder)
29
+ }
30
+
31
+ @Deprecated(
32
+ "",
33
+ level = DeprecationLevel.WARNING,
34
+ replaceWith = ReplaceWith(
35
+ "initializeDefaultInstance(context, builder, sdkState)",
36
+ "com.moengage.react.MoEInitializer.initializeDefaultInstance"
37
+ )
38
+ )
39
+ fun initialize(context: Context, builder: MoEngage.Builder, sdkState: SdkState) {
40
+ initializeDefaultInstance(context, builder, sdkState)
41
+ }
42
+
43
+ fun initializeDefaultInstance(context: Context, builder: MoEngage.Builder) {
18
44
  try {
19
- Logger.v("$tag initialize() : Will try to initialize the sdk.")
20
- initialize(context, builder, true)
21
- } catch (e: Exception) {
22
- Logger.e("$tag initialize() : ", e)
45
+ Logger.print { "$tag initialize() : Will try to initialize the sdk." }
46
+ PluginInitializer.initialize(
47
+ builder,
48
+ IntegrationMeta(INTEGRATION_TYPE, BuildConfig.MOENGAGE_REACT_LIBRARY_VERSION)
49
+ )
50
+ } catch (t: Throwable) {
51
+ Logger.print(LogLevel.ERROR, t) { "$tag initialize() : " }
23
52
  }
24
53
  }
25
54
 
26
- fun initialize(context: Context, builder: MoEngage.Builder, isSdkEnabled: Boolean) {
55
+ fun initializeDefaultInstance(context: Context, builder: MoEngage.Builder, sdkState: SdkState) {
27
56
  try {
28
- Logger.v("$tag initialize() : Initialising MoEngage SDK.")
29
- initialize(
30
- context, builder,
57
+ Logger.print { "$tag initialize() : Initialising MoEngage SDK." }
58
+ PluginInitializer.initialize(
59
+ builder,
31
60
  IntegrationMeta(INTEGRATION_TYPE, BuildConfig.MOENGAGE_REACT_LIBRARY_VERSION),
32
- isSdkEnabled
61
+ sdkState
33
62
  )
34
- Logger.v("$tag initialize() : Initialising MoEngage SDK.")
35
- } catch (e: Exception) {
36
- Logger.e("$tag initialize() : ", e)
63
+ Logger.print { "$tag initialize() : " }
64
+ } catch (t: Throwable) {
65
+ Logger.print(LogLevel.ERROR, t) { "$tag initialize() : " }
37
66
  }
38
67
  }
68
+
69
+
39
70
  }