react-native-moengage 8.3.0 → 8.5.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,20 @@
1
+ # 25-05-2023
2
+
3
+ ## 8.5.0
4
+ - Android
5
+ - Support for handling Foreground Push Notification Click
6
+ - Target & Compile SDK version updated to 33
7
+ - BugFix
8
+ - Self handled InApps Callback fix in Event Triggered Campaign
9
+ - iOS
10
+ - MoEngage-iOS-SDK version updated to `~>9.8.0`.
11
+
12
+ # 16-02-2023
13
+
14
+ ## 8.4.0
15
+ - iOS
16
+ - MoEngage-iOS-SDK version updated to `~>9.4.0`.
17
+
1
18
  # 09-02-2023
2
19
 
3
20
  ## 8.3.0
@@ -12,11 +12,11 @@ Pod::Spec.new do |s|
12
12
  s.license = package['license']
13
13
  s.authors = "MoEngage Inc."
14
14
  s.source = {:file => './' }
15
- s.platform = :ios, "10.0"
15
+ s.platform = :ios, "11.0"
16
16
  s.source_files = 'iOS/MoEReactBridge/**/*.{h,m}'
17
17
  s.dependency 'React'
18
- s.dependency 'MoEngagePluginBase','>= 4.0.0','< 4.1.0'
19
- s.dependency 'MoEngageRichNotification','>= 7.2.0','< 7.3.0'
18
+ s.dependency 'MoEngagePluginBase','>= 4.2.0','< 4.3.0'
19
+ s.dependency 'MoEngageRichNotification','>= 7.8.0','< 7.9.0'
20
20
 
21
21
  s.prepare_command = <<-CMD
22
22
  echo // Generated file, do not edit > iOS/MoEReactBridge/MoEngageReactPluginInfo.h
@@ -20,13 +20,13 @@ rootProject.allprojects {
20
20
 
21
21
  ext {
22
22
  //dependency version
23
- moengageCoreVersion = "12.6.00"
24
- moengageInAppVersion = "6.5.0"
25
- basePluginVersion = "3.2.0"
23
+ moengageCoreVersion = "12.8.00"
24
+ moengageInAppVersion = "6.7.0"
25
+ basePluginVersion = "3.3.1"
26
26
  //build versions
27
27
  minimumVersion = 21
28
- targetVersion = 31
29
- compileVersion = 31
28
+ targetVersion = 33
29
+ compileVersion = 33
30
30
  }
31
31
 
32
32
  apply plugin: 'com.android.library'
@@ -1,13 +1,16 @@
1
1
  package com.moengage.react
2
2
 
3
+ import android.os.Bundle
3
4
  import com.facebook.react.bridge.ReactContext
4
5
  import com.facebook.react.bridge.WritableMap
5
6
  import com.facebook.react.common.LifecycleState
6
7
  import com.facebook.react.modules.core.DeviceEventManagerModule
8
+ import com.moe.pushlibrary.activities.MoEActivity
7
9
  import com.moengage.core.LogLevel
10
+ import com.moengage.core.PUSH_NOTIFICATION_NAVIGATION_ACTIVITY_NAME
11
+ import com.moengage.core.PUSH_NOTIFICATION_NAVIGATION_DEEPLINK_LEGACY
8
12
  import com.moengage.core.internal.logger.Logger
9
13
  import com.moengage.plugin.base.internal.EventEmitter
10
- import com.moengage.plugin.base.internal.instanceMetaFromJson
11
14
  import com.moengage.plugin.base.internal.model.events.Event
12
15
  import com.moengage.plugin.base.internal.model.events.EventType
13
16
  import com.moengage.plugin.base.internal.model.events.inapp.InAppActionEvent
@@ -16,7 +19,10 @@ import com.moengage.plugin.base.internal.model.events.inapp.InAppSelfHandledEven
16
19
  import com.moengage.plugin.base.internal.model.events.push.PermissionEvent
17
20
  import com.moengage.plugin.base.internal.model.events.push.PushClickedEvent
18
21
  import com.moengage.plugin.base.internal.model.events.push.TokenEvent
19
- import org.json.JSONObject
22
+ import com.moengage.pushbase.NAVIGATION_TYPE_RICH_LANDING
23
+ import com.moengage.pushbase.NAVIGATION_TYPE_SCREEN_NAME
24
+ import com.moengage.pushbase.NAV_ACTION
25
+ import com.moengage.pushbase.model.action.NavigationAction
20
26
 
21
27
 
22
28
  /**
@@ -69,13 +75,6 @@ class EventEmitterImpl(private val reactContext: ReactContext) : EventEmitter {
69
75
  Logger.print { "$tag emitPushClicked() : $event" }
70
76
  val eventName = eventMapping[event.eventType] ?: return
71
77
  val payload = PayloadGenerator().pushPayloadToWriteableMap(event.payload)
72
- if (GlobalCache.lifecycleAwarePushCallbackEnabled
73
- && reactContext.lifecycleState != LifecycleState.RESUMED
74
- ) {
75
- Logger.print { "$tag emitPushClicked() : ${reactContext.lifecycleState}" }
76
- GlobalCache.addPushClickedEventToCache(payload)
77
- return
78
- }
79
78
  emit(eventName, payload)
80
79
  }
81
80
 
@@ -101,16 +100,6 @@ class EventEmitterImpl(private val reactContext: ReactContext) : EventEmitter {
101
100
  val payload = PayloadGenerator().permissionResultToWriteableMap(event.result)
102
101
  emit(eventName, payload)
103
102
  }
104
-
105
- internal fun emitPendingEvents() {
106
- if (GlobalCache.lifecycleAwarePushCallbackEnabled) {
107
- val cachedPushClickedEvent = GlobalCache.getPushClickedCachedEvent() ?: return
108
- val eventName = eventMapping[EventType.PUSH_CLICKED] ?: return
109
- GlobalCache.removePushClickedEventFromCache()
110
-
111
- emit(eventName, cachedPushClickedEvent)
112
- }
113
- }
114
103
  }
115
104
 
116
105
  val eventMapping = mapOf<EventType, String>(
@@ -1,25 +1,7 @@
1
1
  package com.moengage.react
2
2
 
3
- import com.facebook.react.bridge.WritableMap
4
-
5
3
  object GlobalCache {
6
4
 
7
- var lifecycleAwarePushCallbackEnabled = false
5
+ var lifecycleAwareCallbackEnabled = false
8
6
  internal set
9
-
10
- private var pushClickedCachedEvent: WritableMap? = null
11
-
12
- fun getPushClickedCachedEvent(): WritableMap? {
13
- return pushClickedCachedEvent
14
- }
15
-
16
- internal fun addPushClickedEventToCache(
17
- pushClickedEvent: WritableMap
18
- ) {
19
- this.pushClickedCachedEvent = pushClickedEvent
20
- }
21
-
22
- internal fun removePushClickedEventFromCache() {
23
- pushClickedCachedEvent = null
24
- }
25
7
  }
@@ -44,11 +44,11 @@ object MoEInitializer {
44
44
  fun initializeDefaultInstance(
45
45
  context: Context,
46
46
  builder: MoEngage.Builder,
47
- lifecycleAwarePushCallbackEnabled: Boolean = false
47
+ lifecycleAwareCallbackEnabled: Boolean = false
48
48
  ) {
49
49
  try {
50
50
  Logger.print { "$tag initialize() : Will try to initialize the sdk." }
51
- GlobalCache.lifecycleAwarePushCallbackEnabled = lifecycleAwarePushCallbackEnabled
51
+ GlobalCache.lifecycleAwareCallbackEnabled = lifecycleAwareCallbackEnabled
52
52
  PluginInitializer.initialize(
53
53
  builder,
54
54
  IntegrationMeta(INTEGRATION_TYPE, BuildConfig.MOENGAGE_REACT_LIBRARY_VERSION)
@@ -63,11 +63,11 @@ object MoEInitializer {
63
63
  context: Context,
64
64
  builder: MoEngage.Builder,
65
65
  sdkState: SdkState,
66
- lifecycleAwarePushCallbackEnabled: Boolean = false
66
+ lifecycleAwareCallbackEnabled: Boolean = false
67
67
  ) {
68
68
  try {
69
69
  Logger.print { "$tag initialize() : Initialising MoEngage SDK." }
70
- GlobalCache.lifecycleAwarePushCallbackEnabled = lifecycleAwarePushCallbackEnabled
70
+ GlobalCache.lifecycleAwareCallbackEnabled = lifecycleAwareCallbackEnabled
71
71
  PluginInitializer.initialize(
72
72
  builder,
73
73
  IntegrationMeta(INTEGRATION_TYPE, BuildConfig.MOENGAGE_REACT_LIBRARY_VERSION),
@@ -6,8 +6,10 @@ import com.facebook.react.bridge.ReactApplicationContext
6
6
  import com.facebook.react.bridge.ReactContextBaseJavaModule
7
7
  import com.facebook.react.bridge.ReactMethod
8
8
  import com.moengage.core.LogLevel
9
+ import com.moengage.core.MoECoreHelper
9
10
  import com.moengage.core.internal.logger.Logger
10
11
  import com.moengage.core.internal.utils.getSdkVersion
12
+ import com.moengage.core.listeners.AppBackgroundListener
11
13
  import com.moengage.plugin.base.internal.PluginHelper
12
14
  import com.moengage.plugin.base.internal.setEventEmitter
13
15
 
@@ -23,17 +25,20 @@ class MoEReactBridge(private val reactContext: ReactApplicationContext) :
23
25
  private val pluginHelper = PluginHelper()
24
26
  private val moeSdkVersion = getSdkVersion()
25
27
 
28
+ private val backgroundStateListener =
29
+ AppBackgroundListener { _, _ -> pluginHelper.onFrameworkDetached() }
30
+
26
31
  override fun getName(): String {
27
32
  return "MoEReactBridge"
28
33
  }
29
34
 
30
35
  @ReactMethod
31
- fun addListener(eventName:String) {
36
+ fun addListener(eventName: String) {
32
37
  // Keep: Required for RN built in Event Emitter Calls.
33
- }
38
+ }
34
39
 
35
40
  @ReactMethod
36
- fun removeListeners(count:Int) {
41
+ fun removeListeners(count: Int) {
37
42
  // Keep: Required for RN built in Event Emitter Calls.
38
43
  }
39
44
 
@@ -152,9 +157,10 @@ class MoEReactBridge(private val reactContext: ReactApplicationContext) :
152
157
  try {
153
158
  Logger.print { "$tag initialize() : " }
154
159
  pluginHelper.initialise(payload)
155
- val eventEmitterImpl = EventEmitterImpl(reactContext)
156
- eventEmitterImpl.emitPendingEvents()
157
- setEventEmitter(eventEmitterImpl)
160
+ setEventEmitter(EventEmitterImpl(reactContext))
161
+ if (GlobalCache.lifecycleAwareCallbackEnabled) {
162
+ MoECoreHelper.addAppBackgroundListener(backgroundStateListener)
163
+ }
158
164
  } catch (t: Throwable) {
159
165
  Logger.print(LogLevel.ERROR, t) { "$tag initialize() : " }
160
166
  }
@@ -9,6 +9,7 @@
9
9
  #import "MoEngageReactPluginInfo.h"
10
10
  #import "MoEngageReactConstants.h"
11
11
  #import "MoEReactBridge.h"
12
+ #import "MoEngageReactUtils.h"
12
13
  #import <MoEngageSDK/MoEngageSDK.h>
13
14
  #import <MoEngageObjCUtils/MoEngageObjCUtils.h>
14
15
  @import MoEngagePluginBase;
@@ -37,7 +38,7 @@
37
38
  - (void)initializeDefaultSDKConfig:(MoEngageSDKConfig*)sdkConfig andLaunchOptions:(NSDictionary*)launchOptions{
38
39
  MoEngagePlugin *plugin = [[MoEngagePlugin alloc] init];
39
40
  [plugin initializeDefaultInstanceWithSdkConfig:sdkConfig launchOptions:launchOptions];
40
- [self commonSetUp:plugin identifier:sdkConfig.identifier];
41
+ [self commonSetUp:plugin identifier:sdkConfig.appId];
41
42
  }
42
43
 
43
44
  - (void)initializeDefaultInstance:(BOOL)isSdkEnabled andLaunchOptions:(NSDictionary*)launchOptions{
@@ -60,7 +61,7 @@
60
61
 
61
62
  MoEngagePlugin *plugin = [[MoEngagePlugin alloc] init];
62
63
  [plugin initializeDefaultInstanceWithSdkConfig:sdkConfig sdkState:sdkState launchOptions:launchOptions];
63
- [self commonSetUp: plugin identifier:sdkConfig.identifier];
64
+ [self commonSetUp: plugin identifier:sdkConfig.appId];
64
65
  }
65
66
 
66
67
  #pragma mark- Utils
@@ -100,19 +101,15 @@
100
101
  }
101
102
 
102
103
  if ([moeDict objectForKey:kDisablePeriodicFlush] != nil && [moeDict objectForKey:kDisablePeriodicFlush] != [NSNull null]) {
103
- sdkConfig.analyticsDisablePeriodicFlush = [moeDict getBooleanForKey:kDisablePeriodicFlush];
104
+ sdkConfig.analyticsDisablePeriodicFlush = [MoEngageReactUtils getBooleanForKey:kDisablePeriodicFlush dict:moeDict];
104
105
  }
105
106
 
106
107
  if ([moeDict objectForKey:kPeriodicFlushDuration] != nil && [moeDict objectForKey:kPeriodicFlushDuration] != [NSNull null]) {
107
- sdkConfig.analyticsPeriodicFlushDuration = [moeDict getIntegerForKey:kPeriodicFlushDuration];
108
- }
109
-
110
- if ([moeDict objectForKey:kEncryptNetworkRequests] != nil && [moeDict objectForKey:kEncryptNetworkRequests] != [NSNull null]) {
111
- sdkConfig.encryptNetworkRequests = [moeDict getBooleanForKey:kDisablePeriodicFlush];
108
+ sdkConfig.analyticsPeriodicFlushDuration = [MoEngageReactUtils getIntegerForKey:kPeriodicFlushDuration dict:moeDict];
112
109
  }
113
110
 
114
111
  if ([moeDict objectForKey:kEnableLogs] != nil && [moeDict objectForKey:kEnableLogs] != [NSNull null]) {
115
- sdkConfig.enableLogs = [moeDict getBooleanForKey:kEnableLogs];
112
+ sdkConfig.enableLogs = [MoEngageReactUtils getBooleanForKey:kEnableLogs dict:moeDict];
116
113
  }
117
114
  }
118
115
 
@@ -136,6 +133,9 @@
136
133
  } else if ([stringVal isEqual: kDataCenter4])
137
134
  {
138
135
  dataCenter = MoEngageDataCenterData_center_04;
136
+ } else if ([stringVal isEqual: kDataCenter5])
137
+ {
138
+ dataCenter = MoEngageDataCenterData_center_05;
139
139
  }
140
140
  else
141
141
  {
@@ -28,6 +28,7 @@ extern NSString* const kDataCenter1;
28
28
  extern NSString* const kDataCenter2;
29
29
  extern NSString* const kDataCenter3;
30
30
  extern NSString* const kDataCenter4;
31
+ extern NSString* const kDataCenter5;
31
32
 
32
33
 
33
34
  //PayLoad Constants
@@ -25,6 +25,7 @@ NSString* const kDataCenter1 = @"DATA_CENTER_01";
25
25
  NSString* const kDataCenter2 = @"DATA_CENTER_02";
26
26
  NSString* const kDataCenter3 = @"DATA_CENTER_03";
27
27
  NSString* const kDataCenter4 = @"DATA_CENTER_04";
28
+ NSString* const kDataCenter5 = @"DATA_CENTER_05";
28
29
 
29
30
 
30
31
  //PayLoad Constants
@@ -0,0 +1,14 @@
1
+ //
2
+ // MoEngageReactUtils.h
3
+ // Pods
4
+ //
5
+ // Created by Rakshitha on 14/02/23.
6
+ //
7
+
8
+ #import <Foundation/Foundation.h>
9
+ #import <UIKit/UIKit.h>
10
+
11
+ @interface MoEngageReactUtils : NSObject
12
+ +(NSInteger)getIntegerForKey:(NSString *)key dict:(NSDictionary*)dict;
13
+ +(BOOL)getBooleanForKey:(NSString *)key dict:(NSDictionary*)dict;
14
+ @end
@@ -0,0 +1,40 @@
1
+ //
2
+ // MoEngageReactUtils.m
3
+ // CocoaAsyncSocket
4
+ //
5
+ // Created by Rakshitha on 14/02/23.
6
+ //
7
+
8
+ #import <Foundation/Foundation.h>
9
+ #import "MoEngageReactUtils.h"
10
+
11
+ @implementation MoEngageReactUtils
12
+ +(NSInteger)getIntegerForKey:(NSString *)key dict:(NSDictionary*)dict {
13
+
14
+ NSString *value = [self stringForkey:key dict:dict];
15
+ if (value == NULL) {
16
+ return -1;
17
+ }
18
+ return [value integerValue];
19
+ }
20
+
21
+ +(NSString * __nullable)stringForkey:(NSString *)key dict:(NSDictionary*)dict {
22
+ if (key == NULL || key.length == 0) {
23
+ return NULL;
24
+ }
25
+ id value = [dict objectForKey:key];
26
+ if (value) {
27
+ return [NSString stringWithFormat:@"%@", value];
28
+ }
29
+ return NULL;
30
+ }
31
+
32
+ +(BOOL)getBooleanForKey:(NSString *)key dict:(NSDictionary*)dict {
33
+
34
+ NSString *value = [self stringForkey:key dict:dict];
35
+ if (value == NULL) {
36
+ return NO;
37
+ }
38
+ return [value boolValue];
39
+ }
40
+ @end
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-moengage",
3
- "version": "8.3.0",
3
+ "version": "8.5.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": [
@@ -23,4 +23,4 @@
23
23
  "devDependencies": {
24
24
  "@types/react-native": "^0.69.3"
25
25
  }
26
- }
26
+ }
package/src/index.ts CHANGED
@@ -26,7 +26,8 @@ import {
26
26
  getUserAttributeJson,
27
27
  getUserLocAttributeJson,
28
28
  getPushPermissionRequestCountJson,
29
- getDeviceIdTrackingJson
29
+ getDeviceIdTrackingJson,
30
+ getInitConfigJson
30
31
  } from "./utils/MoEJsonBuilder";
31
32
  import {
32
33
  USER_ATTRIBUTE_UNIQUE_ID,
@@ -41,6 +42,8 @@ import {
41
42
  } from "./utils/MoEConstants";
42
43
  import MoESelfHandledCampaignData from "./models/MoESelfHandledCampaignData";
43
44
  import {MoEngagePermissionType} from "./models/MoEngagePermissionType";
45
+ import MoEInitConfig from "./models/MoEInitConfig";
46
+ import MoEPushConfig from "./models/MoEPushConfig";
44
47
 
45
48
  const MoEReactBridge = require("react-native").NativeModules.MoEReactBridge;
46
49
  const PLATFORM_ANDROID = "android";
@@ -132,11 +135,17 @@ var ReactMoE = {
132
135
  _eventTypeHandler.delete(type);
133
136
  },
134
137
 
135
- initialize: function (appId:string) {
138
+ /**
139
+ * Initialise the MoEngage SDK, once the hybrid component is mounted
140
+ *
141
+ * @param appId AppId for the application, can be found on MoEngage Dashboard
142
+ * @param initConfig instance of {@link MoEInitConfig}, works only in Android & has no effect for other plaforms.
143
+ */
144
+ initialize: function (appId:string, initConfig?: MoEInitConfig) {
136
145
  moeAppId = appId;
137
146
  commonValidationCheck();
138
147
  if (Platform.OS == PLATFORM_ANDROID) {
139
- MoERNAndroid.initialize(getAppIdJson(appId));
148
+ MoERNAndroid.initialize(getInitConfigJson(appId, initConfig));
140
149
  } else if (Platform.OS == PLATFORM_IOS) {
141
150
  MoERNiOS.initialize(getAppIdJson(appId));
142
151
  }
@@ -805,5 +814,7 @@ export {
805
814
  MoEGeoLocation,
806
815
  MoEProperties,
807
816
  MoEAppStatus,
817
+ MoEInitConfig,
818
+ MoEPushConfig
808
819
  };
809
820
  export default ReactMoE;
@@ -0,0 +1,26 @@
1
+ import MoEPushConfig from "./MoEPushConfig";
2
+
3
+ /**
4
+ * Config class for MoEngage SDK
5
+ * Note: This Config is only for Android platform and is a no-operation method for other plaforms.
6
+ */
7
+ export default class MoEInitConfig {
8
+
9
+ pushConfig: MoEPushConfig;
10
+
11
+ /**
12
+ * Create an instance of {@link MoEInitConfig}
13
+ *
14
+ * @param pushConfig instance of {@link MoEPushConfig}
15
+ */
16
+ constructor (pushConfig: MoEPushConfig) {
17
+ this.pushConfig = pushConfig;
18
+ }
19
+
20
+ /**
21
+ * Default Config for {@link MoEInitConfig}
22
+ */
23
+ static defaultConfig() {
24
+ return new MoEInitConfig(MoEPushConfig.defaultConfig());
25
+ }
26
+ }
@@ -2,10 +2,12 @@ export default class MoEPushCampaign {
2
2
  payload: Map<String, Object>;
3
3
  isDefaultAction: Boolean;
4
4
  clickAction: Map<String, Object>;
5
+ selfHandledPushRedirection: boolean;
5
6
 
6
- constructor(payload: Map<String, Object>, isDefaultAction: Boolean, clickAction: Map<String, Object>) {
7
+ constructor(payload: Map<String, Object>, isDefaultAction: Boolean, clickAction: Map<String, Object>, selfHandledPushRedirection: boolean) {
7
8
  this.payload = payload;
8
9
  this.isDefaultAction = isDefaultAction;
9
10
  this.clickAction = clickAction;
11
+ this.selfHandledPushRedirection = selfHandledPushRedirection;
10
12
  }
11
13
  }
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Config class for Push Notification
3
+ * Note: This Config is only for Android platform and is a no-operation method for other plaforms.
4
+ */
5
+ export default class MoEPushConfig {
6
+
7
+ shouldDeliverCallbackOnForegroundClick: boolean;
8
+
9
+ /**
10
+ * Create an instance of {@link MoEPushConfig}
11
+ *
12
+ * @param shouldDeliverCallbackOnForegroundClick true to handle the callback in the hybrid side
13
+ * if notification is clicked in foreground,
14
+ */
15
+ constructor (shouldDeliverCallbackOnForegroundClick: boolean) {
16
+ this.shouldDeliverCallbackOnForegroundClick = shouldDeliverCallbackOnForegroundClick;
17
+ }
18
+
19
+ /**
20
+ * Default Config for {@link MoEPushConfig}
21
+ */
22
+ static defaultConfig() {
23
+ return new MoEPushConfig(false);
24
+ }
25
+ }
@@ -2,7 +2,7 @@ import MoEAccountMeta from "../models/MoEAccountMeta";
2
2
  import MoEPushCampaign from "../models/MoEPushCampaign";
3
3
  import MoEPushPayload from "../models/MoEPushPayload";
4
4
  import MoEPushToken from "../models/MoEPushToken";
5
- import { APP_ID, MOE_CLICKED_ACTION, MOE_IS_DEFAULT_ACTION, MOE_PAYLOAD, MOE_PLATFORM, MOE_PUSH_CAMPAIGN_OBJ_ERROR, MOE_PUSH_SERVICE, MOE_PUSH_TOKEN_OBJ_ERROR, MOE_TOKEN } from "../utils/MoEConstants";
5
+ import { APP_ID, MOE_CLICKED_ACTION, MOE_IS_DEFAULT_ACTION, MOE_PAYLOAD, MOE_PLATFORM, MOE_PUSH_CAMPAIGN_OBJ_ERROR, MOE_PUSH_SERVICE, MOE_PUSH_TOKEN_OBJ_ERROR, MOE_TOKEN, SELF_HANDLED_PUSH_REDIRECTION_KEY } from "../utils/MoEConstants";
6
6
 
7
7
 
8
8
  /**
@@ -68,7 +68,10 @@ export function getMoEPushPayload(pushPayload: { [k: string]: any },accountMetaP
68
68
  var payload = pushPayload[MOE_PAYLOAD];
69
69
  var isDefaultAction = pushPayload[MOE_IS_DEFAULT_ACTION];
70
70
  var clickAction = pushPayload[MOE_CLICKED_ACTION];
71
- var pushCampaignPayload = new MoEPushCampaign(payload, isDefaultAction, clickAction);
71
+ var selfHandledPushRedirection = SELF_HANDLED_PUSH_REDIRECTION_KEY in pushPayload
72
+ ? pushPayload[SELF_HANDLED_PUSH_REDIRECTION_KEY]
73
+ : false;
74
+ var pushCampaignPayload = new MoEPushCampaign(payload, isDefaultAction, clickAction, selfHandledPushRedirection);
72
75
  var accountMeta = new MoEAccountMeta(accountMetaPayload[APP_ID])
73
76
  var platform = pushPayload[MOE_PLATFORM];
74
77
  return new MoEPushPayload(accountMeta, pushCampaignPayload,platform);
@@ -59,3 +59,10 @@ export const USER_ATTRIBUTE_USER_LOCATION = 'USER_ATTRIBUTE_USER_LOCATION';
59
59
  export const MOE_PERMISSION_TYPE = "type";
60
60
  export const MOE_PERMISSION_STATE = "isGranted";
61
61
 
62
+ // INIT CONFIG
63
+ export const KEY_MOE_CONFIG = "config";
64
+ export const KEY_PUSH_CONFIG = "pushConfig";
65
+
66
+ // PUSH CLICK KEY
67
+ export const SELF_HANDLED_PUSH_REDIRECTION_KEY = "selfHandledPushRedirection";
68
+
@@ -5,6 +5,7 @@ import MoESelfHandledCampaignData from "../models/MoESelfHandledCampaignData";
5
5
  import { MOE_LOCATION } from "./MoEConstants";
6
6
  import { MoEPropertiesToJson} from "./MoEObjectToJson";
7
7
  import {MoEngagePermissionType} from "../models/MoEngagePermissionType";
8
+ import MoEInitConfig from "../models/MoEInitConfig";
8
9
 
9
10
  export function getInAppCampaignJson(moEInAppData: MoEInAppData, type: string, appId: String) {
10
11
  var json: { [k: string]: any } = {
@@ -250,4 +251,19 @@ export function getDeviceIdTrackingJson(isDeviceIdTrackingEnabled: Boolean, appI
250
251
  }
251
252
  }
252
253
  return json;
254
+ }
255
+
256
+ export function getInitConfigJson(appId: String, initConfig?: MoEInitConfig) {
257
+ if (initConfig == undefined) initConfig = MoEInitConfig.defaultConfig()
258
+ var json: { [k: string]: any } = {
259
+ accountMeta: {
260
+ appId: appId
261
+ },
262
+ initConfig: {
263
+ pushConfig: {
264
+ shouldDeliverCallbackOnForegroundClick: initConfig.pushConfig.shouldDeliverCallbackOnForegroundClick
265
+ }
266
+ }
267
+ }
268
+ return json;
253
269
  }