react-native-moengage 8.0.0 → 8.1.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 +19 -0
- package/ReactNativeMoEngage.podspec +1 -1
- package/android/build.gradle +6 -6
- package/android/gradle/wrapper/gradle-wrapper.properties +1 -1
- package/android/src/main/java/com/moengage/react/EventEmitterImpl.kt +11 -1
- package/android/src/main/java/com/moengage/react/MoEReactBridge.kt +37 -0
- package/android/src/main/java/com/moengage/react/PayloadGenerator.kt +9 -0
- package/iOS/MoEReactBridge/MoEReactBridge.m +1 -1
- package/iOS/MoEReactBridge/MoEngageInitializer.h +17 -2
- package/iOS/MoEReactBridge/MoEngageInitializer.m +14 -3
- package/iOS/MoEReactBridge/MoEngageReactConstants.h +1 -0
- package/iOS/MoEReactBridge/MoEngageReactConstants.m +1 -0
- package/iOS/MoEReactBridge/MoEngageReactPluginInfo.h +1 -1
- package/package.json +1 -1
- package/src/index.ts +65 -8
- package/src/models/MoEngagePermissionType.ts +3 -0
- package/src/models/MoEngagePersimissionResultData.ts +14 -0
- package/src/moeParser/MoEngagePayloadParser.ts +11 -0
- package/src/platform/MoERNAndroid.ts +27 -1
- package/src/utils/MoEConstants.ts +2 -0
- package/src/utils/MoEEventHandlerHelper.ts +48 -42
- package/src/utils/MoEJsonBuilder.ts +9 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,22 @@
|
|
|
1
|
+
# 28-10-2022
|
|
2
|
+
|
|
3
|
+
## 8.1.0
|
|
4
|
+
- Android
|
|
5
|
+
- AGP version updated to `7.3.1`
|
|
6
|
+
- Gradle version updated to `7.4`
|
|
7
|
+
- Target SDK version - 31
|
|
8
|
+
- Compile SDK Version - 31
|
|
9
|
+
- Support for Android SDK version `12.4.00`
|
|
10
|
+
- InApp `6.4.0`
|
|
11
|
+
|
|
12
|
+
- iOS
|
|
13
|
+
- Deprecated API
|
|
14
|
+
|
|
15
|
+
| Then | Now |
|
|
16
|
+
|:----------------------------------------------------------------------------------------------------------------------------------------:|:----------------------------------------------------------------------------------------------------------------------------------------------------------:|
|
|
17
|
+
| - (void)initializeDefaultInstance:(BOOL)isSdkEnabled andLaunchOptions:(NSDictionary*)launchOptions | - (void)initializeDefaultInstanceWithState:(MoEngageSDKState)sdkState andLaunchOptions:(NSDictionary*)launchOptions; |
|
|
18
|
+
| - (void)initializeDefaultSDKConfig:(MOSDKConfig*)sdkConfig withSDKState:(BOOL)isSdkEnabled andLaunchOptions:(NSDictionary*)launchOptions | - (void)initializeDefaultSDKConfigWithState:(MOSDKConfig*)sdkConfig withSDKState:(MoEngageSDKState)sdkState andLaunchOptions:(NSDictionary*)launchOptions; |
|
|
19
|
+
|
|
1
20
|
## 27-10-2022
|
|
2
21
|
|
|
3
22
|
### 8.0.0
|
|
@@ -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 'MoEngagePluginBase','>= 3.
|
|
18
|
+
s.dependency 'MoEngagePluginBase','>= 3.1.0','< 3.2.0'
|
|
19
19
|
|
|
20
20
|
s.prepare_command = <<-CMD
|
|
21
21
|
echo // Generated file, do not edit > iOS/MoEReactBridge/MoEngageReactPluginInfo.h
|
package/android/build.gradle
CHANGED
|
@@ -6,7 +6,7 @@ buildscript {
|
|
|
6
6
|
}
|
|
7
7
|
|
|
8
8
|
dependencies {
|
|
9
|
-
classpath 'com.android.tools.build:gradle:7.1
|
|
9
|
+
classpath 'com.android.tools.build:gradle:7.3.1'
|
|
10
10
|
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion"
|
|
11
11
|
}
|
|
12
12
|
}
|
|
@@ -20,13 +20,13 @@ rootProject.allprojects {
|
|
|
20
20
|
|
|
21
21
|
ext {
|
|
22
22
|
//dependency version
|
|
23
|
-
moengageCoreVersion = "12.
|
|
24
|
-
moengageInAppVersion = "6.
|
|
25
|
-
basePluginVersion = "3.
|
|
23
|
+
moengageCoreVersion = "12.4.00"
|
|
24
|
+
moengageInAppVersion = "6.4.0"
|
|
25
|
+
basePluginVersion = "3.1.0"
|
|
26
26
|
//build versions
|
|
27
27
|
minimumVersion = 21
|
|
28
|
-
targetVersion =
|
|
29
|
-
compileVersion =
|
|
28
|
+
targetVersion = 31
|
|
29
|
+
compileVersion = 31
|
|
30
30
|
}
|
|
31
31
|
|
|
32
32
|
apply plugin: 'com.android.library'
|
|
@@ -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-7.
|
|
3
|
+
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-all.zip
|
|
4
4
|
distributionPath=wrapper/dists
|
|
5
5
|
zipStorePath=wrapper/dists
|
|
6
6
|
zipStoreBase=GRADLE_USER_HOME
|
|
@@ -11,6 +11,7 @@ import com.moengage.plugin.base.internal.model.events.EventType
|
|
|
11
11
|
import com.moengage.plugin.base.internal.model.events.inapp.InAppActionEvent
|
|
12
12
|
import com.moengage.plugin.base.internal.model.events.inapp.InAppLifecycleEvent
|
|
13
13
|
import com.moengage.plugin.base.internal.model.events.inapp.InAppSelfHandledEvent
|
|
14
|
+
import com.moengage.plugin.base.internal.model.events.push.PermissionEvent
|
|
14
15
|
import com.moengage.plugin.base.internal.model.events.push.PushClickedEvent
|
|
15
16
|
import com.moengage.plugin.base.internal.model.events.push.TokenEvent
|
|
16
17
|
|
|
@@ -33,6 +34,7 @@ class EventEmitterImpl(private val reactContext: ReactContext) : EventEmitter {
|
|
|
33
34
|
event as InAppActionEvent
|
|
34
35
|
)
|
|
35
36
|
EventType.INAPP_SELF_HANDLED_AVAILABLE -> emitInAppSelfHandled(event as InAppSelfHandledEvent)
|
|
37
|
+
EventType.PERMISSION -> emitPermissionResult(event as PermissionEvent)
|
|
36
38
|
}
|
|
37
39
|
} catch (t: Throwable) {
|
|
38
40
|
Logger.print(LogLevel.ERROR, t) { "$tag emit() : " }
|
|
@@ -82,6 +84,13 @@ class EventEmitterImpl(private val reactContext: ReactContext) : EventEmitter {
|
|
|
82
84
|
Logger.print(LogLevel.ERROR, t) { "$tag emit() : " }
|
|
83
85
|
}
|
|
84
86
|
}
|
|
87
|
+
|
|
88
|
+
private fun emitPermissionResult(event: PermissionEvent) {
|
|
89
|
+
Logger.print { "$tag emitPermissionResult() : Event $event" }
|
|
90
|
+
val eventName = eventMapping[event.eventType] ?: return
|
|
91
|
+
val payload = PayloadGenerator().permissionResultToWriteableMap(event.result)
|
|
92
|
+
emit(eventName, payload)
|
|
93
|
+
}
|
|
85
94
|
}
|
|
86
95
|
|
|
87
96
|
val eventMapping = mapOf<EventType, String>(
|
|
@@ -91,5 +100,6 @@ val eventMapping = mapOf<EventType, String>(
|
|
|
91
100
|
EventType.INAPP_CLOSED to "MoEInAppCampaignDismissed",
|
|
92
101
|
EventType.INAPP_CUSTOM_ACTION to "MoEInAppCampaignCustomAction",
|
|
93
102
|
EventType.INAPP_SELF_HANDLED_AVAILABLE to "MoEInAppCampaignSelfHandled",
|
|
94
|
-
EventType.PUSH_TOKEN_GENERATED to "MoEPushTokenGenerated"
|
|
103
|
+
EventType.PUSH_TOKEN_GENERATED to "MoEPushTokenGenerated",
|
|
104
|
+
EventType.PERMISSION to "MoEPermissionResult"
|
|
95
105
|
)
|
|
@@ -217,4 +217,41 @@ class MoEReactBridge(private val reactContext: ReactApplicationContext) :
|
|
|
217
217
|
Logger.print(LogLevel.ERROR, t) { "$tag deviceIdentifierTrackingStatusUpdate() : " }
|
|
218
218
|
}
|
|
219
219
|
}
|
|
220
|
+
|
|
221
|
+
@ReactMethod
|
|
222
|
+
fun setupNotificationChannels() {
|
|
223
|
+
try {
|
|
224
|
+
pluginHelper.setUpNotificationChannels(context)
|
|
225
|
+
} catch (t: Throwable) {
|
|
226
|
+
Logger.print(LogLevel.ERROR, t) { "$tag setupNotificationChannel() :" }
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
@ReactMethod
|
|
231
|
+
fun navigateToSettings() {
|
|
232
|
+
try {
|
|
233
|
+
pluginHelper.navigateToSettings(context)
|
|
234
|
+
} catch (t: Throwable) {
|
|
235
|
+
Logger.print(LogLevel.ERROR, t) { "$tag navigateToSettings() :" }
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
@ReactMethod
|
|
240
|
+
fun requestPushPermission() {
|
|
241
|
+
try {
|
|
242
|
+
pluginHelper.requestPushPermission(context)
|
|
243
|
+
} catch (t: Throwable) {
|
|
244
|
+
Logger.print(LogLevel.ERROR, t) { "$tag requestPushPermission() :" }
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
@ReactMethod
|
|
249
|
+
fun permissionResponse(payload: String) {
|
|
250
|
+
try {
|
|
251
|
+
Logger.print { "$tag permissionResponse() : Payload: $payload" }
|
|
252
|
+
pluginHelper.permissionResponse(context, payload)
|
|
253
|
+
} catch (t: Throwable) {
|
|
254
|
+
Logger.print(LogLevel.ERROR, t) { "$tag permissionResponse() :" }
|
|
255
|
+
}
|
|
256
|
+
}
|
|
220
257
|
}
|
|
@@ -7,6 +7,7 @@ import com.moengage.inapp.model.ClickData
|
|
|
7
7
|
import com.moengage.inapp.model.InAppData
|
|
8
8
|
import com.moengage.inapp.model.SelfHandledCampaignData
|
|
9
9
|
import com.moengage.plugin.base.internal.*
|
|
10
|
+
import com.moengage.plugin.base.internal.model.PermissionResult
|
|
10
11
|
import com.moengage.plugin.base.internal.model.PushPayload
|
|
11
12
|
import com.moengage.plugin.base.internal.model.events.push.TokenEvent
|
|
12
13
|
|
|
@@ -57,4 +58,12 @@ internal class PayloadGenerator {
|
|
|
57
58
|
map.putString(ARGUMENT_PAYLOAD, json.toString())
|
|
58
59
|
return map
|
|
59
60
|
}
|
|
61
|
+
|
|
62
|
+
fun permissionResultToWriteableMap(result: PermissionResult): WritableMap {
|
|
63
|
+
val map = Arguments.createMap()
|
|
64
|
+
val json = permissionResultToJson(result)
|
|
65
|
+
Logger.print { "$tag permissionResultToWriteableMap() : Payload Json: $json" }
|
|
66
|
+
map.putString(ARGUMENT_PAYLOAD, json.toString())
|
|
67
|
+
return map
|
|
68
|
+
}
|
|
60
69
|
}
|
|
@@ -91,7 +91,7 @@
|
|
|
91
91
|
#pragma mark- Event Emitters
|
|
92
92
|
- (NSArray<NSString *> *)supportedEvents
|
|
93
93
|
{
|
|
94
|
-
return @[kPushClicked, kPushTokenGenerated, kInAppShown, kInAppClicked, kInAppDismissed, kInAppCustomAction, kInAppSelfHandled];
|
|
94
|
+
return @[kPushClicked, kPushTokenGenerated, kInAppShown, kInAppClicked, kInAppDismissed, kInAppCustomAction, kInAppSelfHandled, kPermissionResult];
|
|
95
95
|
}
|
|
96
96
|
|
|
97
97
|
RCT_EXPORT_MODULE();
|
|
@@ -20,12 +20,19 @@ NS_ASSUME_NONNULL_BEGIN
|
|
|
20
20
|
/// @version 8.0.0 and above
|
|
21
21
|
- (void)initializeDefaultInstance:(NSDictionary*)launchOptions;
|
|
22
22
|
|
|
23
|
+
/// Initialization Methods to setup SDK with configuration parameters from Info.plist file
|
|
24
|
+
/// @param sdkState MoEngageSDKState enum indicating if SDK is Enabled/Disabled, refer (link)[https://docs.moengage.com/docs/gdpr-compliance-1#enabledisable-sdk] for more info
|
|
25
|
+
/// @param launchOptions Launch Options dictionary
|
|
26
|
+
/// @warning Make sure to call only one of the initialization methods available (either with plist OR with MOSDKConfig instance)
|
|
27
|
+
/// @version 8.1.0 and above
|
|
28
|
+
- (void)initializeDefaultInstanceWithState:(MoEngageSDKState)sdkState andLaunchOptions:(NSDictionary*)launchOptions;
|
|
29
|
+
|
|
23
30
|
/// Initialization Methods to setup SDK with configuration parameters from Info.plist file
|
|
24
31
|
/// @param isSdkEnabled Bool indicating if SDK is Enabled/Disabled, refer (link)[https://docs.moengage.com/docs/gdpr-compliance-1#enabledisable-sdk] for more info
|
|
25
32
|
/// @param launchOptions Launch Options dictionary
|
|
26
33
|
/// @warning Make sure to call only one of the initialization methods available (either with plist OR with MOSDKConfig instance)
|
|
27
34
|
/// @version 8.0.0 and above
|
|
28
|
-
- (void)initializeDefaultInstance:(BOOL)isSdkEnabled andLaunchOptions:(NSDictionary*)launchOptions;
|
|
35
|
+
- (void)initializeDefaultInstance:(BOOL)isSdkEnabled andLaunchOptions:(NSDictionary*)launchOptions __deprecated_msg("Use initializeDefaultInstanceWithState:andLaunchOptions instead.");
|
|
29
36
|
|
|
30
37
|
/// Initialization Methods to setup SDK with MOSDKConfig instance instead of from Info.plist file
|
|
31
38
|
/// @param sdkConfig MOSDKConfig instance for SDK configuration
|
|
@@ -34,13 +41,21 @@ NS_ASSUME_NONNULL_BEGIN
|
|
|
34
41
|
/// @version 8.0.0 and above
|
|
35
42
|
- (void)initializeDefaultSDKConfig:(MOSDKConfig*)sdkConfig andLaunchOptions:(NSDictionary*)launchOptions;
|
|
36
43
|
|
|
44
|
+
/// Initialization Methods to setup SDK with MOSDKConfig instance instead of from Info.plist file
|
|
45
|
+
/// @param sdkConfig MOSDKConfig instance for SDK configuration
|
|
46
|
+
/// @param sdkState MoEngageSDKState indicating if SDK is Enabled/Disabled, refer (link)[https://docs.moengage.com/docs/gdpr-compliance-1#enabledisable-sdk] for more info
|
|
47
|
+
/// @param launchOptions Launch Options dictionary
|
|
48
|
+
/// @warning Make sure to call only one of the initialization methods available (either with plist OR with MOSDKConfig instance)
|
|
49
|
+
/// @version 8.1.0 and above
|
|
50
|
+
- (void)initializeDefaultSDKConfigWithState:(MOSDKConfig*)sdkConfig withSDKState:(MoEngageSDKState)sdkState andLaunchOptions:(NSDictionary*)launchOptions;
|
|
51
|
+
|
|
37
52
|
/// Initialization Methods to setup SDK with MOSDKConfig instance instead of from Info.plist file
|
|
38
53
|
/// @param sdkConfig MOSDKConfig instance for SDK configuration
|
|
39
54
|
/// @param isSdkEnabled Bool indicating if SDK is Enabled/Disabled, refer (link)[https://docs.moengage.com/docs/gdpr-compliance-1#enabledisable-sdk] for more info
|
|
40
55
|
/// @param launchOptions Launch Options dictionary
|
|
41
56
|
/// @warning Make sure to call only one of the initialization methods available (either with plist OR with MOSDKConfig instance)
|
|
42
57
|
/// @version 8.0.0 and above
|
|
43
|
-
- (void)initializeDefaultSDKConfig:(MOSDKConfig*)sdkConfig withSDKState:(BOOL)isSdkEnabled andLaunchOptions:(NSDictionary*)launchOptions;
|
|
58
|
+
- (void)initializeDefaultSDKConfig:(MOSDKConfig*)sdkConfig withSDKState:(BOOL)isSdkEnabled andLaunchOptions:(NSDictionary*)launchOptions __deprecated_msg("Use initializeDefaultSDKConfigWithState:andLaunchOptions instead.");
|
|
44
59
|
@end
|
|
45
60
|
|
|
46
61
|
NS_ASSUME_NONNULL_END
|
|
@@ -43,13 +43,24 @@
|
|
|
43
43
|
|
|
44
44
|
- (void)initializeDefaultInstance:(BOOL)isSdkEnabled andLaunchOptions:(NSDictionary*)launchOptions{
|
|
45
45
|
MOSDKConfig *sdkConfig = [self fetchSDKConfig];
|
|
46
|
-
|
|
46
|
+
MoEngageSDKState currentSDKState = isSdkEnabled ? MoEngageSDKStateEnabled: MoEngageSDKStateDisabled;
|
|
47
|
+
[self initializeDefaultSDKConfigWithState:sdkConfig withSDKState:currentSDKState andLaunchOptions:launchOptions];
|
|
47
48
|
}
|
|
48
49
|
|
|
49
|
-
- (void)
|
|
50
|
+
- (void)initializeDefaultInstanceWithState:(MoEngageSDKState)sdkState andLaunchOptions:(NSDictionary*)launchOptions{
|
|
51
|
+
MOSDKConfig *sdkConfig = [self fetchSDKConfig];
|
|
52
|
+
[self initializeDefaultSDKConfigWithState:sdkConfig withSDKState:sdkState andLaunchOptions:launchOptions];
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
- (void)initializeDefaultSDKConfig:(MOSDKConfig*)sdkConfig withSDKState:(BOOL)isSDKEnabled andLaunchOptions:(NSDictionary*)launchOptions{
|
|
56
|
+
MoEngageSDKState currentSDKState = isSDKEnabled ? MoEngageSDKStateEnabled: MoEngageSDKStateDisabled;
|
|
57
|
+
[self initializeDefaultSDKConfigWithState:sdkConfig withSDKState:currentSDKState andLaunchOptions:launchOptions];
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
- (void)initializeDefaultSDKConfigWithState:(MOSDKConfig*)sdkConfig withSDKState:(MoEngageSDKState)sdkState andLaunchOptions:(NSDictionary*)launchOptions{
|
|
50
61
|
|
|
51
62
|
MoEngagePlugin *plugin = [[MoEngagePlugin alloc] init];
|
|
52
|
-
[plugin initializeDefaultInstanceWithSdkConfig:sdkConfig sdkState:
|
|
63
|
+
[plugin initializeDefaultInstanceWithSdkConfig:sdkConfig sdkState:sdkState launchOptions:launchOptions];
|
|
53
64
|
[self commonSetUp: plugin identifier:sdkConfig.identifier];
|
|
54
65
|
}
|
|
55
66
|
|
|
@@ -41,3 +41,4 @@ NSString* const kInAppCustomAction = @"MoEInAppCampaignCustomAction";
|
|
|
41
41
|
NSString* const kInAppSelfHandled = @"MoEInAppCampaignSelfHandled";
|
|
42
42
|
NSString* const kPushTokenGenerated = @"MoEPushTokenGenerated";
|
|
43
43
|
NSString* const kPushClicked = @"MoEPushClicked";
|
|
44
|
+
NSString* const kPermissionResult = @"MoEPermissionResult";
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// Generated file, do not edit
|
|
2
|
-
#define MOE_REACT_PLUGIN_VERSION @"
|
|
2
|
+
#define MOE_REACT_PLUGIN_VERSION @"8.0.0"
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-moengage",
|
|
3
|
-
"version": "8.
|
|
3
|
+
"version": "8.1.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
|
@@ -1,18 +1,44 @@
|
|
|
1
|
-
import { Platform
|
|
1
|
+
import {NativeEventEmitter, Platform} from "react-native";
|
|
2
2
|
import MoEProperties from "./models/MoEProperties";
|
|
3
3
|
import MoEGeoLocation from "./models/MoEGeoLocation";
|
|
4
4
|
import * as MoEHelper from "./utils/MoEHelper";
|
|
5
5
|
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
6
|
+
import {MoEAppStatus} from "./models/MoEAppStatus";
|
|
7
|
+
import {MoERNAndroid} from "./platform/MoERNAndroid";
|
|
8
|
+
import {MoERNiOS} from "./platform/MoERNiOS";
|
|
9
9
|
|
|
10
10
|
import MoEInAppCustomAction from "./models/MoEInAppCustomAction";
|
|
11
11
|
import MoEInAppNavigation from "./models/MoEInAppNavigation";
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
|
|
12
|
+
import {executeHandler} from "./utils/MoEEventHandlerHelper";
|
|
13
|
+
import {
|
|
14
|
+
getAdIdTrackingJson,
|
|
15
|
+
getAliasJson,
|
|
16
|
+
getAndroidIdTrackingJson,
|
|
17
|
+
getAppIdJson,
|
|
18
|
+
getAppStatusJson,
|
|
19
|
+
getInAppContextJson,
|
|
20
|
+
getMoEPropertiesJson,
|
|
21
|
+
getMoEPushCampaignJson,
|
|
22
|
+
getMoEPushTokenJson,
|
|
23
|
+
getOptOutTrackingJson,
|
|
24
|
+
getSdkStateJson,
|
|
25
|
+
getSelfHandledJson,
|
|
26
|
+
getUserAttributeJson,
|
|
27
|
+
getUserLocAttributeJson
|
|
28
|
+
} from "./utils/MoEJsonBuilder";
|
|
29
|
+
import {
|
|
30
|
+
USER_ATTRIBUTE_UNIQUE_ID,
|
|
31
|
+
USER_ATTRIBUTE_USER_BDAY,
|
|
32
|
+
USER_ATTRIBUTE_USER_EMAIL,
|
|
33
|
+
USER_ATTRIBUTE_USER_FIRST_NAME,
|
|
34
|
+
USER_ATTRIBUTE_USER_GENDER,
|
|
35
|
+
USER_ATTRIBUTE_USER_LAST_NAME,
|
|
36
|
+
USER_ATTRIBUTE_USER_LOCATION,
|
|
37
|
+
USER_ATTRIBUTE_USER_MOBILE,
|
|
38
|
+
USER_ATTRIBUTE_USER_NAME
|
|
39
|
+
} from "./utils/MoEConstants";
|
|
15
40
|
import MoESelfHandledCampaignData from "./models/MoESelfHandledCampaignData";
|
|
41
|
+
import {MoEngagePermissionType} from "./models/MoEngagePermissionType";
|
|
16
42
|
|
|
17
43
|
const MoEReactBridge = require("react-native").NativeModules.MoEReactBridge;
|
|
18
44
|
const PLATFORM_ANDROID = "android";
|
|
@@ -27,6 +53,7 @@ const MOE_INAPP_CLICKED = "MoEInAppCampaignClicked";
|
|
|
27
53
|
const MOE_INAPP_DISMISSED = "MoEInAppCampaignDismissed";
|
|
28
54
|
const MOE_INAPP_CUSTOM_ACTION = "MoEInAppCampaignCustomAction";
|
|
29
55
|
const MOE_INAPP_SELF_HANDLE = "MoEInAppCampaignSelfHandled";
|
|
56
|
+
const MOE_PERMISSION_RESULT = "MoEPermissionResult";
|
|
30
57
|
|
|
31
58
|
const eventBroadcastNames = [
|
|
32
59
|
MOE_PUSH_CLICKED,
|
|
@@ -36,6 +63,7 @@ const eventBroadcastNames = [
|
|
|
36
63
|
MOE_INAPP_DISMISSED,
|
|
37
64
|
MOE_INAPP_CUSTOM_ACTION,
|
|
38
65
|
MOE_INAPP_SELF_HANDLE,
|
|
66
|
+
MOE_PERMISSION_RESULT
|
|
39
67
|
];
|
|
40
68
|
|
|
41
69
|
// JS Event Names
|
|
@@ -46,6 +74,7 @@ const INAPP_CLICKED = "inAppCampaignClicked";
|
|
|
46
74
|
const INAPP_DISMISSED = "inAppCampaignDismissed";
|
|
47
75
|
const INAPP_CUTOM_ACTION = "inAppCampaignCustomAction";
|
|
48
76
|
const INAPP_SELF_HANDLE = "inAppCampaignSelfHandled";
|
|
77
|
+
export const PERMISSION_RESULT = "permissionResult";
|
|
49
78
|
|
|
50
79
|
const PUSH_SERVICE_FCM = "FCM"
|
|
51
80
|
const PUSH_SERVICE_PUSH_KIT = "PUSH_KIT"
|
|
@@ -58,6 +87,7 @@ const _eventNames = [
|
|
|
58
87
|
INAPP_DISMISSED,
|
|
59
88
|
INAPP_CUTOM_ACTION,
|
|
60
89
|
INAPP_SELF_HANDLE,
|
|
90
|
+
PERMISSION_RESULT
|
|
61
91
|
];
|
|
62
92
|
|
|
63
93
|
var _eventTypeHandler = new Map();
|
|
@@ -693,8 +723,35 @@ var ReactMoE = {
|
|
|
693
723
|
if (Platform.OS == PLATFORM_ANDROID) {
|
|
694
724
|
MoERNAndroid.disableAndroidIdTracking(payload);
|
|
695
725
|
}
|
|
696
|
-
}
|
|
726
|
+
},
|
|
697
727
|
|
|
728
|
+
pushPermissionResponseAndroid: function (isGranted: boolean) {
|
|
729
|
+
console.log("Will track permission response");
|
|
730
|
+
if (Platform.OS == PLATFORM_ANDROID) {
|
|
731
|
+
MoERNAndroid.permissionResponse(isGranted, MoEngagePermissionType.PUSH)
|
|
732
|
+
}
|
|
733
|
+
},
|
|
734
|
+
|
|
735
|
+
setupNotificationChannelsAndroid: function () {
|
|
736
|
+
console.log("Will setup notification");
|
|
737
|
+
if (Platform.OS == PLATFORM_ANDROID) {
|
|
738
|
+
MoERNAndroid.setupNotificationChannels();
|
|
739
|
+
}
|
|
740
|
+
},
|
|
741
|
+
|
|
742
|
+
navigateToSettingsAndroid: function () {
|
|
743
|
+
console.log("Will navigate to settings");
|
|
744
|
+
if (Platform.OS == PLATFORM_ANDROID) {
|
|
745
|
+
MoERNAndroid.navigateToSettings();
|
|
746
|
+
}
|
|
747
|
+
},
|
|
748
|
+
|
|
749
|
+
requestPushPermissionAndroid: function () {
|
|
750
|
+
console.log("Will request push permission.");
|
|
751
|
+
if (Platform.OS == PLATFORM_ANDROID) {
|
|
752
|
+
MoERNAndroid.requestPushPermission();
|
|
753
|
+
}
|
|
754
|
+
}
|
|
698
755
|
|
|
699
756
|
};
|
|
700
757
|
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { MoEngagePermissionType } from "./MoEngagePermissionType";
|
|
2
|
+
import {MoEPlatform} from "./MoEPlatform";
|
|
3
|
+
|
|
4
|
+
export default class MoEngagePersimissionResultData {
|
|
5
|
+
platform: MoEPlatform;
|
|
6
|
+
isGranted: boolean;
|
|
7
|
+
type: MoEngagePermissionType;
|
|
8
|
+
|
|
9
|
+
constructor(platform: MoEPlatform, isGranted: boolean, type: MoEngagePermissionType) {
|
|
10
|
+
this.platform = platform;
|
|
11
|
+
this.isGranted = isGranted;
|
|
12
|
+
this.type = type;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import {MoEngagePermissionType} from "../models/MoEngagePermissionType";
|
|
2
|
+
import MoEngagePersimissionResultData from "../models/MoEngagePersimissionResultData";
|
|
3
|
+
import {MOE_PERMISSION_STATE, MOE_PERMISSION_TYPE, MOE_PLATFORM} from "../utils/MoEConstants";
|
|
4
|
+
|
|
5
|
+
export function getPermissionResult(payload: { [k: string]: any }) {
|
|
6
|
+
return new MoEngagePersimissionResultData(
|
|
7
|
+
payload[MOE_PLATFORM],
|
|
8
|
+
payload[MOE_PERMISSION_STATE],
|
|
9
|
+
payload[MOE_PERMISSION_TYPE]
|
|
10
|
+
)
|
|
11
|
+
}
|
|
@@ -1,4 +1,14 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { MoEngagePermissionType } from "../models/MoEngagePermissionType";
|
|
2
|
+
import {
|
|
3
|
+
getAdIdTrackingJson,
|
|
4
|
+
getAndroidIdTrackingJson,
|
|
5
|
+
getAppIdJson,
|
|
6
|
+
getMoEPushCampaignJson,
|
|
7
|
+
getMoEPushTokenJson,
|
|
8
|
+
getOptOutTrackingJson,
|
|
9
|
+
getPermissionResponseJson,
|
|
10
|
+
getSdkStateJson
|
|
11
|
+
} from "../utils/MoEJsonBuilder";
|
|
2
12
|
|
|
3
13
|
const MoEReactBridge = require("react-native").NativeModules.MoEReactBridge;
|
|
4
14
|
const PLATFORM_ANDROID = "android";
|
|
@@ -117,6 +127,22 @@ export class MoERNAndroid {
|
|
|
117
127
|
static disableAndroidIdTracking(payload: { [k: string]: any }) {
|
|
118
128
|
MoEReactBridge.deviceIdentifierTrackingStatusUpdate(JSON.stringify(payload))
|
|
119
129
|
}
|
|
130
|
+
|
|
131
|
+
static permissionResponse(isGranted: boolean, permissionType: MoEngagePermissionType) {
|
|
132
|
+
MoEReactBridge.permissionResponse(JSON.stringify(getPermissionResponseJson(isGranted, permissionType)));
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
static setupNotificationChannels() {
|
|
136
|
+
MoEReactBridge.setupNotificationChannels();
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
static navigateToSettings() {
|
|
140
|
+
MoEReactBridge.navigateToSettings()
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
static requestPushPermission() {
|
|
144
|
+
MoEReactBridge.requestPushPermission();
|
|
145
|
+
}
|
|
120
146
|
}
|
|
121
147
|
|
|
122
148
|
const PUSH_SERVICE_FCM = "FCM"
|
|
@@ -56,4 +56,6 @@ export const USER_ATTRIBUTE_USER_BDAY = 'USER_ATTRIBUTE_USER_BDAY';
|
|
|
56
56
|
export const USER_ATTRIBUTE_USER_GENDER = 'USER_ATTRIBUTE_USER_GENDER';
|
|
57
57
|
export const USER_ATTRIBUTE_USER_LOCATION = 'USER_ATTRIBUTE_USER_LOCATION';
|
|
58
58
|
|
|
59
|
+
export const MOE_PERMISSION_TYPE = "type";
|
|
60
|
+
export const MOE_PERMISSION_STATE = "isGranted";
|
|
59
61
|
|
|
@@ -1,47 +1,53 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import {isValidObject} from "../utils/MoEHelper";
|
|
2
|
+
import {
|
|
3
|
+
getCustomActionObj,
|
|
4
|
+
getMoEInAppData,
|
|
5
|
+
getNavigationObj,
|
|
6
|
+
getMoESelfHandledCampaignData
|
|
7
|
+
} from "../moeParser/MoEInAppParser";
|
|
8
|
+
import {getMoEPushPayload, getMoEPushToken} from "../moeParser/MoEPushNotificationParser";
|
|
9
|
+
import {MOE_DATA, ACCOUNT_META, MOE_PAYLOAD} from "./MoEConstants";
|
|
10
|
+
import {PERMISSION_RESULT} from "..";
|
|
11
|
+
import {getPermissionResult} from "../moeParser/MoEngagePayloadParser";
|
|
5
12
|
|
|
6
13
|
export function executeHandler(
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
14
|
+
handler: Function,
|
|
15
|
+
notification: any,
|
|
16
|
+
type: String
|
|
10
17
|
) {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
18
|
+
if (handler && type) {
|
|
19
|
+
const payload = notification[MOE_PAYLOAD];
|
|
20
|
+
const notificationPayload = JSON.parse(payload);
|
|
21
|
+
if (isValidObject(notificationPayload)) {
|
|
22
|
+
if (type == "pushTokenGenerated") {
|
|
23
|
+
var pushTokenObject = getMoEPushToken(notificationPayload);
|
|
24
|
+
pushTokenObject != undefined ? handler(pushTokenObject) : null;
|
|
25
|
+
} else if (type == PERMISSION_RESULT) {
|
|
26
|
+
let payload = getPermissionResult(notificationPayload)
|
|
27
|
+
handler(payload)
|
|
28
|
+
} else {
|
|
29
|
+
const accountMeta = notificationPayload[ACCOUNT_META];
|
|
30
|
+
if (accountMeta != undefined && isValidObject(accountMeta)) {
|
|
31
|
+
const payload = notificationPayload[MOE_DATA];
|
|
32
|
+
if (type == "inAppCampaignShown" || type == "inAppCampaignDismissed") {
|
|
33
|
+
var inAppObject = getMoEInAppData(payload, accountMeta);
|
|
34
|
+
inAppObject != undefined ? handler(inAppObject) : null;
|
|
35
|
+
} else if (type == "inAppCampaignSelfHandled") {
|
|
36
|
+
var selfHandled = getMoESelfHandledCampaignData(payload, accountMeta);
|
|
37
|
+
selfHandled != undefined ? handler(selfHandled) : null;
|
|
38
|
+
} else if (type == "inAppCampaignCustomAction") {
|
|
39
|
+
var cutomAction = getCustomActionObj(payload, accountMeta);
|
|
40
|
+
cutomAction != undefined ? handler(cutomAction) : null;
|
|
41
|
+
} else if (type == "inAppCampaignClicked") {
|
|
42
|
+
var navigationAction = getNavigationObj(payload, accountMeta);
|
|
43
|
+
navigationAction != undefined ? handler(navigationAction) : null;
|
|
44
|
+
} else if (type == "pushClicked") {
|
|
45
|
+
var pushCampaignObject = getMoEPushPayload(payload, accountMeta);
|
|
46
|
+
pushCampaignObject != undefined ? handler(pushCampaignObject) : null;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
}
|
|
38
51
|
}
|
|
39
|
-
|
|
40
|
-
var pushCampaignObject = getMoEPushPayload(payload,accountMeta);
|
|
41
|
-
pushCampaignObject != undefined ? handler(pushCampaignObject) : null;
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
}}
|
|
46
|
-
}
|
|
52
|
+
}
|
|
47
53
|
}
|
|
@@ -4,6 +4,7 @@ import MoEProperties from "../models/MoEProperties";
|
|
|
4
4
|
import MoESelfHandledCampaignData from "../models/MoESelfHandledCampaignData";
|
|
5
5
|
import { MOE_LOCATION } from "./MoEConstants";
|
|
6
6
|
import { MoEPropertiesToJson} from "./MoEObjectToJson";
|
|
7
|
+
import {MoEngagePermissionType} from "../models/MoEngagePermissionType";
|
|
7
8
|
|
|
8
9
|
export function getInAppCampaignJson(moEInAppData: MoEInAppData, type: string, appId: String) {
|
|
9
10
|
var json: { [k: string]: any } = {
|
|
@@ -217,4 +218,12 @@ export function getOptOutTrackingJson(type: string, state: boolean, appId: strin
|
|
|
217
218
|
}
|
|
218
219
|
}
|
|
219
220
|
return json;
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
export function getPermissionResponseJson(isGranted: boolean, permissionType: MoEngagePermissionType) {
|
|
224
|
+
let json: { [k: string]: any } = {
|
|
225
|
+
isGranted: isGranted,
|
|
226
|
+
type: permissionType.toLowerCase()
|
|
227
|
+
}
|
|
228
|
+
return json;
|
|
220
229
|
}
|