@selligent-marketing-cloud/selligent-react-native 3.9.2 → 4.0.1
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 +2 -2
- package/android/build.gradle +1 -1
- package/android/src/main/java/com/selligent/RNHelpers.java +3 -0
- package/android/src/main/java/com/selligent/RNSelligent.java +48 -5
- package/documentation/README.md +9 -44
- package/index.d.ts +1 -1
- package/index.ios.js +0 -7
- package/index.js +7 -0
- package/ios/CustomEvent.h +11 -0
- package/ios/CustomEvent.m +18 -0
- package/ios/RNSelligentMapper.h +0 -8
- package/ios/RNSelligentMapper.m +22 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -11,7 +11,7 @@ This module supports the following SDK and tools:
|
|
|
11
11
|
| SDK | Version |
|
|
12
12
|
| ------------------------------------------------------------------------------ |---------|
|
|
13
13
|
| [Android SDK](https://github.com/SelligentMarketingCloud/MobileSDK-Android) | 4.5.0 |
|
|
14
|
-
| [iOS SDK](https://github.com/SelligentMarketingCloud/MobileSDK-iOS) | 3.8.
|
|
14
|
+
| [iOS SDK](https://github.com/SelligentMarketingCloud/MobileSDK-iOS) | 3.8.5 |
|
|
15
15
|
| ReactNative | 0.73.4 |
|
|
16
16
|
| Expo SDK | 50 |
|
|
17
17
|
|
|
@@ -174,7 +174,7 @@ This module supports the following SDK and tools:
|
|
|
174
174
|
|
|
175
175
|
> Do not check the "copy if needed" option to make sure you only have to manage one selligent.json file
|
|
176
176
|
|
|
177
|
-
3. Add the native iOS SDK dependency in your Podfile: `s.dependency "SelligentMobileSDK/Framework", "3.8.
|
|
177
|
+
3. Add the native iOS SDK dependency in your Podfile: `s.dependency "SelligentMobileSDK/Framework", "3.8.5"` or download it manually from [here](https://github.com/SelligentMarketingCloud/MobileSDK-iOS/tree/master/Framework) and drag and drop it into you **Xcode project**.
|
|
178
178
|
|
|
179
179
|
4. Add the RNSelligentMapper pod in your Podfile: `pod 'RNSelligentMapper', :path => '../node_modules/@selligent-marketing-cloud/selligent-react-native/RNSelligentMapper.podspec'`.
|
|
180
180
|
|
package/android/build.gradle
CHANGED
|
@@ -64,7 +64,7 @@ dependencies {
|
|
|
64
64
|
implementation 'androidx.cardview:cardview:1.0.0'
|
|
65
65
|
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.7.1'
|
|
66
66
|
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.7.3'
|
|
67
|
-
implementation 'com.selligent.sdk:selligent_mobile_reactnative_sdk:3.8.
|
|
67
|
+
implementation 'com.selligent.sdk:selligent_mobile_reactnative_sdk:3.8.2'
|
|
68
68
|
}
|
|
69
69
|
|
|
70
70
|
def loadSelligentSettings(variant) {
|
|
@@ -20,9 +20,11 @@ import com.facebook.react.bridge.ReadableArray;
|
|
|
20
20
|
import com.facebook.react.bridge.ReadableMap;
|
|
21
21
|
import com.facebook.react.bridge.ReadableType;
|
|
22
22
|
import com.facebook.react.modules.core.DeviceEventManagerModule;
|
|
23
|
+
import com.selligent.rnmobilesdk.DelayedEvent;
|
|
23
24
|
import com.selligent.rnmobilesdk.Manager;
|
|
24
25
|
import com.selligent.sdk.SMForegroundGcmBroadcastReceiver;
|
|
25
26
|
|
|
27
|
+
import java.util.ArrayList;
|
|
26
28
|
import java.util.Map;
|
|
27
29
|
|
|
28
30
|
public class RNSelligent extends ReactContextBaseJavaModule implements LifecycleEventListener, ActivityEventListener {
|
|
@@ -39,6 +41,11 @@ public class RNSelligent extends ReactContextBaseJavaModule implements Lifecycle
|
|
|
39
41
|
return BuildConfig.SELLIGENT_SETTINGS;
|
|
40
42
|
}
|
|
41
43
|
|
|
44
|
+
Activity getActivity()
|
|
45
|
+
{
|
|
46
|
+
return this.getCurrentActivity();
|
|
47
|
+
}
|
|
48
|
+
|
|
42
49
|
public RNSelligent(ReactApplicationContext reactContext) {
|
|
43
50
|
super(reactContext);
|
|
44
51
|
|
|
@@ -116,7 +123,7 @@ public class RNSelligent extends ReactContextBaseJavaModule implements Lifecycle
|
|
|
116
123
|
|
|
117
124
|
@ReactMethod
|
|
118
125
|
public void executeButtonAction(String buttonId, String messageId, Callback successCallback, Callback errorCallback) {
|
|
119
|
-
this.manager.executeButtonAction(this.
|
|
126
|
+
this.manager.executeButtonAction(this.getCurrentActivity(), buttonId, messageId, error ->
|
|
120
127
|
processErrorStringToCallback(error, successCallback, errorCallback)
|
|
121
128
|
);
|
|
122
129
|
}
|
|
@@ -239,6 +246,34 @@ public class RNSelligent extends ReactContextBaseJavaModule implements Lifecycle
|
|
|
239
246
|
);
|
|
240
247
|
}
|
|
241
248
|
|
|
249
|
+
@ReactMethod
|
|
250
|
+
public void executePushAction() {
|
|
251
|
+
this.emitDelayedEvents();
|
|
252
|
+
|
|
253
|
+
Activity currentActivity = this.getActivity();
|
|
254
|
+
|
|
255
|
+
if (currentActivity == null) { return; }
|
|
256
|
+
|
|
257
|
+
this.manager.executePushAction(currentActivity);
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
void emitDelayedEvents()
|
|
261
|
+
{
|
|
262
|
+
ArrayList<DelayedEvent> delayedEvents = this.manager.getStoredEvents();
|
|
263
|
+
|
|
264
|
+
if (delayedEvents.size() > 0)
|
|
265
|
+
{
|
|
266
|
+
for (DelayedEvent delayedEvent: delayedEvents)
|
|
267
|
+
{
|
|
268
|
+
this.reactContext.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class).emit(
|
|
269
|
+
delayedEvent.Name,
|
|
270
|
+
RNHelpers.convertMapToWritableMap(delayedEvent.Data)
|
|
271
|
+
);
|
|
272
|
+
}
|
|
273
|
+
delayedEvents.clear();
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
|
|
242
277
|
@ReactMethod
|
|
243
278
|
public void setFirebaseToken(String token) {
|
|
244
279
|
this.manager.setFirebaseToken(token);
|
|
@@ -291,12 +326,20 @@ public class RNSelligent extends ReactContextBaseJavaModule implements Lifecycle
|
|
|
291
326
|
public void onActivityResult(Activity activity, int requestCode, int resultCode, Intent data) { }
|
|
292
327
|
|
|
293
328
|
private void broadcastEvent(String eventName, Map<String, Object> data) {
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
329
|
+
if (RNSelligent.getManager().canEmitEvent())
|
|
330
|
+
{
|
|
331
|
+
this.reactContext.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class).emit(
|
|
332
|
+
eventName,
|
|
333
|
+
RNHelpers.convertMapToWritableMap(data)
|
|
334
|
+
);
|
|
335
|
+
}
|
|
336
|
+
else
|
|
337
|
+
{
|
|
338
|
+
RNSelligent.getManager().storeEvent(eventName, data);
|
|
339
|
+
}
|
|
298
340
|
}
|
|
299
341
|
|
|
342
|
+
|
|
300
343
|
private void processErrorStringToCallback(String error, Callback successCallback, Callback errorCallback) {
|
|
301
344
|
if (error == null) {
|
|
302
345
|
successCallback.invoke();
|
package/documentation/README.md
CHANGED
|
@@ -67,7 +67,7 @@ The following properties can be used in the `selligent.json` to further configur
|
|
|
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
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 |
|
|
70
|
-
| delayedPushAction | boolean|
|
|
70
|
+
| delayedPushAction | boolean| 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 |
|
|
71
71
|
| interceptSelligentUniversalLinks | boolean| (iOS Only) Optin to customly handle the execution of universal links coming from a Push/IAM [more information](#universal-linking---ios) |
|
|
72
72
|
| clearCacheIntervalValue | [enum](#clearcacheintervalvalue) | How much time the SDK will keep things in cache |
|
|
73
73
|
| inAppMessageRefreshType | [enum](#inappmessagerefreshtype) | How often the SDK will check for new inapp messages |
|
|
@@ -230,46 +230,13 @@ Then, follow the [native iOS SDK documentation](https://github.com/SelligentMark
|
|
|
230
230
|
|
|
231
231
|
### Deep Linking
|
|
232
232
|
|
|
233
|
-
|
|
234
|
-
This is because the JS layer is loaded **after** the native
|
|
233
|
+
Depending on your React version, it might be that deeplinks behind push notifications do not work when the App is killed.
|
|
234
|
+
This is because the JS layer is loaded **after** the native SDK executes the deeplink, so the JS event listeners are not there yet. If you want to fix this, follow the below steps (make sure to build for Release when testing this).
|
|
235
235
|
|
|
236
236
|
1. Add the `delayedPushAction` property in `selligent.json` file and set it to `true`
|
|
237
237
|
|
|
238
238
|
2. Implement (if not there yet) a linking handler in your ReactNative codebase (i.e <https://facebook.github.io/react-native/docs/linking>)
|
|
239
239
|
|
|
240
|
-
Example:
|
|
241
|
-
|
|
242
|
-
```objc
|
|
243
|
-
// In Appdelegate.m
|
|
244
|
-
- (BOOL) application:(UIApplication *)application openURL:(NSURL *)url options:(NSDictionary<UIApplicationOpenURLOptionsKey,id> *)options {
|
|
245
|
-
return [RCTLinkingManager application:application openURL:url options:options];
|
|
246
|
-
}
|
|
247
|
-
```
|
|
248
|
-
|
|
249
|
-
```javascript
|
|
250
|
-
// In DeeplinkHook.js
|
|
251
|
-
import { useEffect } from "react"
|
|
252
|
-
import { Alert, Linking } from "react-native"
|
|
253
|
-
|
|
254
|
-
const useHandleDeepLink = () => {
|
|
255
|
-
useEffect(() => {
|
|
256
|
-
Linking.getInitialURL().then((link) => {
|
|
257
|
-
if (link) {
|
|
258
|
-
Alert.alert('Deep Link', link || 'No link')
|
|
259
|
-
}
|
|
260
|
-
}).catch(err => {
|
|
261
|
-
console.warn('An error occurred', err)
|
|
262
|
-
})
|
|
263
|
-
|
|
264
|
-
const urlListener = Linking.addEventListener('url', ({url}) => Alert.alert('Deep Link', url || 'No link'))
|
|
265
|
-
|
|
266
|
-
return () => urlListener.remove()
|
|
267
|
-
}, [])
|
|
268
|
-
}
|
|
269
|
-
|
|
270
|
-
export default useHandleDeepLink
|
|
271
|
-
```
|
|
272
|
-
|
|
273
240
|
3. Add a call to `Selligent.executePushAction()` in your main `App.js` file, after adding the ReactNative linking handler (and after calling `Selligent.subscribeToEvents`, if being used)
|
|
274
241
|
|
|
275
242
|
```javascript
|
|
@@ -277,15 +244,13 @@ This is because the JS layer is loaded **after** the native iOS SDK executes the
|
|
|
277
244
|
|
|
278
245
|
const App = () => {
|
|
279
246
|
// Deeplinking handling library (i.e Linking.getInitialURL() & Linking.addEventListener...)
|
|
280
|
-
useHandleDeepLink()
|
|
247
|
+
// useHandleDeepLink()
|
|
281
248
|
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
Selligent.executePushAction()
|
|
288
|
-
}
|
|
249
|
+
/* Tells the Marigold Engage SDK to execute the action associated to the last push clicked, when using `delayedPushAction` feature.
|
|
250
|
+
If you are having problems with deeplinks or 'Push + InApp Message' where the splash screen gets stuck or the push action not visible,
|
|
251
|
+
make sure you control when the splash screen is dismissed (i.e https://docs.expo.dev/versions/latest/sdk/splash-screen/) and call this method afterwards (if the dismiss is async, call this method once the async process is completely finished)
|
|
252
|
+
*/
|
|
253
|
+
Selligent.executePushAction()
|
|
289
254
|
```
|
|
290
255
|
|
|
291
256
|
#### Background Modes
|
package/index.d.ts
CHANGED
|
@@ -65,6 +65,7 @@ export function displayMessage(
|
|
|
65
65
|
messageId: string,
|
|
66
66
|
templateId?: string
|
|
67
67
|
): void;
|
|
68
|
+
export function executePushAction(): void;
|
|
68
69
|
|
|
69
70
|
// IOS
|
|
70
71
|
export function enableiOSLogging(
|
|
@@ -75,7 +76,6 @@ export function enableiOSLogging(
|
|
|
75
76
|
export function registerForProvisionalRemoteNotification(
|
|
76
77
|
successCallback: Function
|
|
77
78
|
): void;
|
|
78
|
-
export function executePushAction(): void;
|
|
79
79
|
|
|
80
80
|
// ANDROID
|
|
81
81
|
export function areInAppMessagesEnabled(successCallback: Function): any;
|
package/index.ios.js
CHANGED
|
@@ -83,12 +83,5 @@ export default {
|
|
|
83
83
|
registerForProvisionalRemoteNotification: function (successCallback) {
|
|
84
84
|
successCallback(SelligentHelpers.SUCCESS)
|
|
85
85
|
RNSelligent.registerForProvisionalRemoteNotification()
|
|
86
|
-
},
|
|
87
|
-
|
|
88
|
-
/**
|
|
89
|
-
* Tells the Marigold Engage SDK to execute the action associated to the last push clicked, when using `delayedPushAction` feature
|
|
90
|
-
*/
|
|
91
|
-
executePushAction: function () {
|
|
92
|
-
RNSelligent.executePushAction()
|
|
93
86
|
}
|
|
94
87
|
}
|
package/index.js
CHANGED
|
@@ -184,6 +184,13 @@ export default Object.assign(
|
|
|
184
184
|
}
|
|
185
185
|
},
|
|
186
186
|
|
|
187
|
+
/**
|
|
188
|
+
* Tells the Marigold Engage SDK to execute the action associated to the last push clicked, when using `delayedPushAction` feature
|
|
189
|
+
*/
|
|
190
|
+
executePushAction: function () {
|
|
191
|
+
RNSelligent.executePushAction()
|
|
192
|
+
},
|
|
193
|
+
|
|
187
194
|
// Event
|
|
188
195
|
|
|
189
196
|
/**
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
#import <Foundation/Foundation.h>
|
|
2
|
+
|
|
3
|
+
@interface CustomEvent : NSObject
|
|
4
|
+
|
|
5
|
+
@property(nonatomic) NSString *_Nonnull name;
|
|
6
|
+
@property(nonatomic) NSString *_Nonnull type;
|
|
7
|
+
@property(nonatomic) NSDictionary *_Nullable data;
|
|
8
|
+
|
|
9
|
+
+ (instancetype _Nonnull) eventWithData:(NSDictionary*_Nullable)data AndName:(NSString*_Nonnull)name AndType:(NSString*_Nonnull)type;
|
|
10
|
+
|
|
11
|
+
@end
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
#import "CustomEvent.h"
|
|
2
|
+
|
|
3
|
+
@implementation CustomEvent
|
|
4
|
+
|
|
5
|
+
+ (instancetype) eventWithData:(NSDictionary*)data AndName:(NSString*)name AndType:(NSString*)type {
|
|
6
|
+
return [[self alloc] initWithData:data AndName:name AndType: type];
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
- (instancetype) initWithData:(NSDictionary*)data AndName:(NSString*)name AndType:(NSString*)type {
|
|
10
|
+
self = [super init];
|
|
11
|
+
self.data = data;
|
|
12
|
+
self.type = type;
|
|
13
|
+
self.name = name;
|
|
14
|
+
|
|
15
|
+
return self;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
@end
|
package/ios/RNSelligentMapper.h
CHANGED
|
@@ -1,11 +1,3 @@
|
|
|
1
|
-
//
|
|
2
|
-
// RNSelligentMapper.h
|
|
3
|
-
// SelligentDevAppRN
|
|
4
|
-
//
|
|
5
|
-
// Created by Marc Biosca on 16/5/23.
|
|
6
|
-
// Copyright © 2023 Facebook. All rights reserved.
|
|
7
|
-
//
|
|
8
|
-
|
|
9
1
|
#if __has_include(<React/RCTBridgeModule.h>)
|
|
10
2
|
#import <React/RCTBridgeModule.h>
|
|
11
3
|
#import <React/RCTEventEmitter.h>
|
package/ios/RNSelligentMapper.m
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
#import "RNSelligentMapper.h"
|
|
2
|
+
#import "CustomEvent.h"
|
|
2
3
|
|
|
3
4
|
@implementation RNSelligentMapper
|
|
4
5
|
|
|
@@ -8,6 +9,8 @@ RCT_EXPORT_MODULE(RNSelligent)
|
|
|
8
9
|
self = [super init];
|
|
9
10
|
|
|
10
11
|
RNSelligent.eventDelegate = self;
|
|
12
|
+
self.pendingEvents = [NSMutableArray new];
|
|
13
|
+
[RNSelligent subscribeToEvents:@[]];
|
|
11
14
|
|
|
12
15
|
return self;
|
|
13
16
|
}
|
|
@@ -133,10 +136,27 @@ RCT_EXPORT_METHOD(sendEvent:(NSDictionary *)data successCallback:(RCTResponseSen
|
|
|
133
136
|
|
|
134
137
|
RCT_EXPORT_METHOD(subscribeToEvents:(NSArray<NSString *> *)events) {
|
|
135
138
|
[RNSelligent subscribeToEvents:events];
|
|
139
|
+
self.listeningEvents = true;
|
|
140
|
+
[self sendPendingEvents];
|
|
136
141
|
}
|
|
137
142
|
|
|
138
143
|
- (void) sendBroadcastEventWithName:(NSString * _Nonnull)name type:(NSString * _Nonnull)type data:(NSDictionary * _Nullable)data {
|
|
139
|
-
|
|
144
|
+
if (self.listeningEvents) {
|
|
145
|
+
[self sendEventWithName:name body:@{@"data": data ?: [NSNull null], @"broadcastEventType": type}];
|
|
146
|
+
}
|
|
147
|
+
else {
|
|
148
|
+
[self.pendingEvents addObject:[CustomEvent eventWithData:data AndName:name AndType:type]];
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
- (void) sendPendingEvents {
|
|
153
|
+
if (self.pendingEvents.count == 0) { return; }
|
|
154
|
+
|
|
155
|
+
for (CustomEvent* event in self.pendingEvents) {
|
|
156
|
+
[self sendEventWithName:event.name body:@{@"data": event.data ?: [NSNull null], @"broadcastEventType": event.type}];
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
self.pendingEvents = [NSMutableArray new];
|
|
140
160
|
}
|
|
141
161
|
|
|
142
162
|
- (NSArray<NSString *> *) supportedEvents {
|
|
@@ -153,4 +173,4 @@ RCT_EXPORT_METHOD(subscribeToEvents:(NSArray<NSString *> *)events) {
|
|
|
153
173
|
];
|
|
154
174
|
}
|
|
155
175
|
|
|
156
|
-
@end
|
|
176
|
+
@end
|
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": "
|
|
7
|
+
"version": "4.0.1",
|
|
8
8
|
"description": "React Native wrapper for the Marigold Engage Android and iOS SDKs",
|
|
9
9
|
"main": "index.js",
|
|
10
10
|
"repository": {
|