@selligent-marketing-cloud/selligent-react-native 3.5.1 → 3.6.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/README.md +1 -1
- package/android/build.gradle +1 -1
- package/android/libs/RNSelligentMobileSDK.aar +0 -0
- package/android/src/main/java/com/selligent/RNSelligent.java +24 -5
- package/constants.d.ts +1 -0
- package/constants.js +3 -1
- package/documentation/README.md +35 -3
- package/index.js +1 -0
- package/ios/RNSelligentMapper.m +2 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -10,7 +10,7 @@ This module supports the following SDK and tools:
|
|
|
10
10
|
|
|
11
11
|
| SDK | Version |
|
|
12
12
|
| ------------------------------------------------------------------------------ | ------- |
|
|
13
|
-
| [Android SDK](https://github.com/SelligentMarketingCloud/MobileSDK-Android) | 4.4.
|
|
13
|
+
| [Android SDK](https://github.com/SelligentMarketingCloud/MobileSDK-Android) | 4.4.1 |
|
|
14
14
|
| [iOS SDK](https://github.com/SelligentMarketingCloud/MobileSDK-iOS) | 3.8.1 |
|
|
15
15
|
| ReactNative | 0.72.4 |
|
|
16
16
|
| Expo SDK | 49 |
|
package/android/build.gradle
CHANGED
|
@@ -63,7 +63,7 @@ dependencies {
|
|
|
63
63
|
exclude group:'com.facebook.fbjni'
|
|
64
64
|
exclude group:'com.facebook.yoga'
|
|
65
65
|
}
|
|
66
|
-
implementation 'com.selligent.sdk:selligent_mobile_sdk:4.4.
|
|
66
|
+
implementation 'com.selligent.sdk:selligent_mobile_sdk:4.4.1'
|
|
67
67
|
implementation 'com.google.code.gson:gson:2.9.0'
|
|
68
68
|
implementation 'com.google.firebase:firebase-messaging:23.2.1'
|
|
69
69
|
implementation 'androidx.work:work-runtime:2.8.1'
|
|
Binary file
|
|
@@ -31,6 +31,7 @@ import com.facebook.react.modules.core.DeviceEventManagerModule;
|
|
|
31
31
|
import com.google.gson.Gson;
|
|
32
32
|
import com.google.gson.reflect.TypeToken;
|
|
33
33
|
import com.selligent.rnmobilesdk.BroadcastEventType;
|
|
34
|
+
import com.selligent.rnmobilesdk.ButtonAction;
|
|
34
35
|
import com.selligent.rnmobilesdk.ButtonBroadcastEventDataParser;
|
|
35
36
|
import com.selligent.rnmobilesdk.DeviceIdBroadcastEventDataParser;
|
|
36
37
|
import com.selligent.rnmobilesdk.Event;
|
|
@@ -64,6 +65,7 @@ public class RNSelligent extends ReactContextBaseJavaModule implements Lifecycle
|
|
|
64
65
|
EventReceiver eventReceiver;
|
|
65
66
|
SMForegroundGcmBroadcastReceiver receiver;
|
|
66
67
|
private static SMInAppRefreshType inAppMessageRefreshType;
|
|
68
|
+
private static boolean inAppMessageCustomUi;
|
|
67
69
|
|
|
68
70
|
public static final String REACT_CLASS = "SelligentReactNative"; // for logging purposes
|
|
69
71
|
|
|
@@ -108,9 +110,10 @@ public class RNSelligent extends ReactContextBaseJavaModule implements Lifecycle
|
|
|
108
110
|
final Settings settings = Settings.fromHashMap(settingsHashMap);
|
|
109
111
|
final SMSettings smSettings = SMSettingsFactory.getSMSettings(settings);
|
|
110
112
|
final String notificationActivityName = settings.getActivityName();
|
|
111
|
-
|
|
113
|
+
|
|
112
114
|
SMManager.NOTIFICATION_ACTIVITY = getActivityClass(notificationActivityName);
|
|
113
115
|
inAppMessageRefreshType = settings.getInAppMessageRefreshType().getSmInAppRefreshType();
|
|
116
|
+
inAppMessageCustomUi = settings.getCustomInAppUi();
|
|
114
117
|
|
|
115
118
|
final SMManager smManager = getSMManager();
|
|
116
119
|
SMManager.DEBUG = BuildConfig.BUILD_TYPE.equals("debug") || settings.getEnableAndroidLogging();
|
|
@@ -225,7 +228,7 @@ public class RNSelligent extends ReactContextBaseJavaModule implements Lifecycle
|
|
|
225
228
|
buttonMap.putString("id", button.id);
|
|
226
229
|
buttonMap.putString("value", button.value);
|
|
227
230
|
buttonMap.putString("label", button.label);
|
|
228
|
-
buttonMap.putInt("type", button.
|
|
231
|
+
buttonMap.putInt("type", ButtonAction.valueOf(button.action).getValue());
|
|
229
232
|
|
|
230
233
|
buttonsArray.pushMap(buttonMap);
|
|
231
234
|
}
|
|
@@ -605,9 +608,9 @@ public class RNSelligent extends ReactContextBaseJavaModule implements Lifecycle
|
|
|
605
608
|
{
|
|
606
609
|
receiver = new SMForegroundGcmBroadcastReceiver(currentActivity);
|
|
607
610
|
}
|
|
608
|
-
currentActivity.registerReceiver(receiver, receiver.getIntentFilter());
|
|
609
611
|
|
|
610
|
-
|
|
612
|
+
currentActivity.registerReceiver(receiver, receiver.getIntentFilter());
|
|
613
|
+
this.DisplayInAppMessage(currentActivity.getIntent(), currentActivity);
|
|
611
614
|
}
|
|
612
615
|
}
|
|
613
616
|
|
|
@@ -629,10 +632,26 @@ public class RNSelligent extends ReactContextBaseJavaModule implements Lifecycle
|
|
|
629
632
|
|
|
630
633
|
if (currentActivity != null) {
|
|
631
634
|
currentActivity.setIntent(intent);
|
|
632
|
-
|
|
635
|
+
this.DisplayInAppMessage(intent, currentActivity);
|
|
633
636
|
}
|
|
634
637
|
}
|
|
635
638
|
|
|
636
639
|
@Override
|
|
637
640
|
public void onActivityResult(Activity activity, int requestCode, int resultCode, Intent data) { }
|
|
641
|
+
|
|
642
|
+
private void DisplayInAppMessage(Intent intent, Activity currentActivity) {
|
|
643
|
+
smManager.checkAndDisplayMessage(intent, currentActivity, message -> {
|
|
644
|
+
if (!inAppMessageCustomUi) {
|
|
645
|
+
return true;
|
|
646
|
+
}
|
|
647
|
+
|
|
648
|
+
DeviceEventManagerModule.RCTDeviceEventEmitter rctDeviceEventEmitter = reactContext.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class);
|
|
649
|
+
InAppMessageBroadcastEventDataParser inAppDataParser = new InAppMessageBroadcastEventDataParser();
|
|
650
|
+
String eventName = BroadcastEventType.DisplayingInAppMessage.getBroadcastEventType();
|
|
651
|
+
WritableMap data = inAppDataParser.wrap(message);
|
|
652
|
+
rctDeviceEventEmitter.emit(eventName, getBroadcastData(eventName, data));
|
|
653
|
+
|
|
654
|
+
return false;
|
|
655
|
+
});
|
|
656
|
+
}
|
|
638
657
|
}
|
package/constants.d.ts
CHANGED
|
@@ -74,4 +74,5 @@ export namespace BroadcastEventType {
|
|
|
74
74
|
const RECEIVED_REMOTE_NOTIFICATION = "ReceivedRemoteNotification";
|
|
75
75
|
const UNIVERSAL_LINK_EXECUTED = "UniversalLinkExecuted";
|
|
76
76
|
const TRIGGERED_CUSTOM_EVENT = "TriggeredCustomEvent";
|
|
77
|
+
const DISPLAYING_IN_APP_MESSAGE = "DisplayingInAppMessage";
|
|
77
78
|
}
|
package/constants.js
CHANGED
|
@@ -174,7 +174,9 @@ const SelligentConstants = {
|
|
|
174
174
|
/** Received an universal link execution */
|
|
175
175
|
UNIVERSAL_LINK_EXECUTED: "UniversalLinkExecuted",
|
|
176
176
|
/** A custom event has been triggered */
|
|
177
|
-
TRIGGERED_CUSTOM_EVENT: "TriggeredCustomEvent"
|
|
177
|
+
TRIGGERED_CUSTOM_EVENT: "TriggeredCustomEvent",
|
|
178
|
+
/** An IAM is about to be displayed (when `customInAppUi` is set to `true` in `selligent.json`) */
|
|
179
|
+
DISPLAYING_IN_APP_MESSAGE: "DisplayingInAppMessage"
|
|
178
180
|
},
|
|
179
181
|
|
|
180
182
|
};
|
package/documentation/README.md
CHANGED
|
@@ -66,6 +66,7 @@ The following properties can be used in the `selligent.json` to further configur
|
|
|
66
66
|
| url | string | The Marigold Engage webservice url to be used to integrate with your Marigold Engage platform |
|
|
67
67
|
| clientId | string | The Marigold Engage client id to be used to integrate with your Marigold Engage platform |
|
|
68
68
|
| privateKey | string | The Marigold Engage private key to be used to integrate with your Marigold Engage platform |
|
|
69
|
+
| customInAppUi | boolean| When this is enabled and a "push + inapp" notification is clicked, the SDK will NOT display the inApp message and instead a `SelligentConstants.BroadcastEventType.DISPLAYING_IN_APP_MESSAGE` event will be sent |
|
|
69
70
|
| delayedPushAction | boolean| (iOS Only) Optin for a specific push action handling (wait for React UI to be ready) when coming from a push message and having the app killed |
|
|
70
71
|
| interceptSelligentUniversalLinks | boolean| (iOS Only) Optin to customly handle the execution of universal links coming from a Push/IAM [more information](#universal-linking---ios) |
|
|
71
72
|
| clearCacheIntervalValue | [enum](#clearcacheintervalvalue) | How much time the SDK will keep things in cache |
|
|
@@ -482,7 +483,7 @@ The `data` property is an object itself containing more information specific to
|
|
|
482
483
|
|
|
483
484
|
| Property | Type | Description |
|
|
484
485
|
| -------- | ------ | ------------------ |
|
|
485
|
-
| id | string | Internal id of the message
|
|
486
|
+
| id | string | Internal id of the message |
|
|
486
487
|
| title | string | Title of the message |
|
|
487
488
|
|
|
488
489
|
```javascript
|
|
@@ -512,7 +513,7 @@ The response of the success callback is an array of objects which contain the in
|
|
|
512
513
|
| -------------- | ------------------------------------------------------------------------------- | ---------------------------------------------------------- |
|
|
513
514
|
| id | string | Internal id of the IAM |
|
|
514
515
|
| title | string | Title of the IAM |
|
|
515
|
-
| body | string | Body of the IAM |
|
|
516
|
+
| body | string | Body of the IAM. For message of type `ALERT` it will be the text corresponding to the body of the Alert, for type `HTML` it will be the html code, for type `URL`, `IMAGE` and `PASSBOOK` it will be an URL. |
|
|
516
517
|
| type | [enum](#inappmessagetype) | Type of the IAM |
|
|
517
518
|
| creationDate | number | Creation date of the IAM in unix time |
|
|
518
519
|
| expirationDate | number | Expiration date of the IAM in unix time |
|
|
@@ -529,6 +530,36 @@ The `buttons` property is an array of button-objects which contain the informati
|
|
|
529
530
|
| value | string | Value of the button of the in app message | Both |
|
|
530
531
|
| type | number | Type of the button of the in app message | Both |
|
|
531
532
|
|
|
533
|
+
- When the IAM is linked to a push notification, you can set `customInAppUi` to `true` in `selligent.json` and subscribe to `SelligentConstants.BroadcastEventType.DISPLAYING_IN_APP_MESSAGE` events through the `Selligent.subscribeToEvents`, to know when messages are about to be displayed.
|
|
534
|
+
You will also need to set `addInAppMessageFromPushToInAppMessageList` to `true` in `selligent.json` to be able to retrieve the full object calling `Selligent.getInAppMessages` and do not forget to use the [IAM Helper methods](#iam-helper-methods) to properly track Open and Click interactions.
|
|
535
|
+
For Android, to avoid the SDK directly displaying the IAM if the App is in foreground, do also set `remoteMessageDisplayType` to `22` (NOTIFICATION) in `selligent.json`.
|
|
536
|
+
The response of the success callback is an object which contains information on the type of broadcast event and the data attached to it.
|
|
537
|
+
|
|
538
|
+
| Property | Type | Description |
|
|
539
|
+
| ------------------ | ------------------------------------------------------- | ----------------------------------------------------------------- |
|
|
540
|
+
| broadcastEventType | [enum](#broadcasteventtype) | The type of broadcast event |
|
|
541
|
+
| data | object | Contains more information specific to the type of broadcast event |
|
|
542
|
+
|
|
543
|
+
The `data` property is an object itself containing more information specific to the type of the broadcast event:
|
|
544
|
+
|
|
545
|
+
- DISPLAYING_IN_APP_MESSAGE
|
|
546
|
+
|
|
547
|
+
| Property | Type | Description |
|
|
548
|
+
| -------- | ------ | ------------------ |
|
|
549
|
+
| id | string | Internal id of the message |
|
|
550
|
+
| title | string | Title of the message |
|
|
551
|
+
|
|
552
|
+
```javascript
|
|
553
|
+
Selligent.subscribeToEvents(
|
|
554
|
+
() => {},
|
|
555
|
+
() => {},
|
|
556
|
+
(response) => {
|
|
557
|
+
if (response?.broadcastEventType === SelligentConstants.BroadcastEventType.DISPLAYING_IN_APP_MESSAGE) {
|
|
558
|
+
}
|
|
559
|
+
}
|
|
560
|
+
)
|
|
561
|
+
```
|
|
562
|
+
|
|
532
563
|
To display any of these messages, you can call `Selligent.displayMessage`:
|
|
533
564
|
|
|
534
565
|
### Selligent.displayMessage
|
|
@@ -596,7 +627,7 @@ In the other hand, you can also use the native methods `RNSelligent/willPresentN
|
|
|
596
627
|
|
|
597
628
|
### IAM Helper methods
|
|
598
629
|
|
|
599
|
-
If you decide to display the
|
|
630
|
+
If you decide to display the IAM on your own (without `Selligent.displayMessage` and `Selligent.displayNotification`), listening for new messages with the `Selligent.subscribeToEvents` and/or getting the full list with `Selligent.getInAppMessages`. You will be able to build your own layout with the object provided from the mentioned functions and then you can use the helper methods described here to still push KPI statistics to the Marigold Engage platform:
|
|
600
631
|
|
|
601
632
|
- setInAppMessageAsSeen: sets an IAM as seen and sends the corresponding `Opened` event to the Marigold Engage platform
|
|
602
633
|
|
|
@@ -905,3 +936,4 @@ Defines the type of a broadcast event.
|
|
|
905
936
|
| RECEIVED_REMOTE_NOTIFICATION | string | ReceivedRemoteNotification | A remote notification has been received |
|
|
906
937
|
| iOS.UNIVERSAL_LINK_EXECUTED | string | UniversalLinkExecuted | An universal link has been executed |
|
|
907
938
|
| TRIGGERED_CUSTOM_EVENT | string | TriggeredCustomEvent | A custom event has been triggered |
|
|
939
|
+
| DISPLAYING_IN_APP_MESSAGE | string | DisplayingInAppMessage | An IAM is about to be displayed (when `customInAppUi` is set to `true` in `selligent.json`) |
|
package/index.js
CHANGED
|
@@ -306,6 +306,7 @@ export default Object.assign(
|
|
|
306
306
|
RNSEventEmitter.addListener(SelligentConstants.BroadcastEventType.RECEIVED_DEVICE_ID, eventCallback);
|
|
307
307
|
RNSEventEmitter.addListener(SelligentConstants.BroadcastEventType.RECEIVED_REMOTE_NOTIFICATION, eventCallback);
|
|
308
308
|
RNSEventEmitter.addListener(SelligentConstants.BroadcastEventType.TRIGGERED_CUSTOM_EVENT, eventCallback);
|
|
309
|
+
RNSEventEmitter.addListener(SelligentConstants.BroadcastEventType.DISPLAYING_IN_APP_MESSAGE, eventCallback);
|
|
309
310
|
|
|
310
311
|
if (Platform.OS === "ios") {
|
|
311
312
|
RNSEventEmitter.addListener(SelligentConstants.BroadcastEventType.UNIVERSAL_LINK_EXECUTED, eventCallback);
|
package/ios/RNSelligentMapper.m
CHANGED
|
@@ -148,7 +148,8 @@ RCT_EXPORT_METHOD(subscribeToEvents:(NSArray<NSString *> *)events) {
|
|
|
148
148
|
@"ReceivedRemoteNotification",
|
|
149
149
|
@"ReceivedDeviceId",
|
|
150
150
|
@"UniversalLinkExecuted",
|
|
151
|
-
@"TriggeredCustomEvent"
|
|
151
|
+
@"TriggeredCustomEvent",
|
|
152
|
+
@"DisplayingInAppMessage"
|
|
152
153
|
];
|
|
153
154
|
}
|
|
154
155
|
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
},
|
|
5
5
|
"name": "@selligent-marketing-cloud/selligent-react-native",
|
|
6
6
|
"title": "Marigold Engage React Native",
|
|
7
|
-
"version": "3.
|
|
7
|
+
"version": "3.6.0",
|
|
8
8
|
"description": "React Native wrapper for the Marigold Engage Android and iOS SDKs",
|
|
9
9
|
"main": "index.js",
|
|
10
10
|
"repository": {
|