@selligent-marketing-cloud/selligent-react-native 3.9.2 → 4.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.
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.3 |
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.3"` or download it manually from [here](https://github.com/SelligentMarketingCloud/MobileSDK-iOS/tree/master/Framework) and drag and drop it into you **Xcode project**.
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
 
@@ -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.0'
67
+ implementation 'com.selligent.sdk:selligent_mobile_reactnative_sdk:3.8.1'
68
68
  }
69
69
 
70
70
  def loadSelligentSettings(variant) {
@@ -49,6 +49,9 @@ final class RNHelpers {
49
49
  else if (value instanceof String) {
50
50
  writableMap.putString(key, (String) value);
51
51
  }
52
+ else if (value instanceof Long) {
53
+ writableMap.putDouble(key, (Long) value);
54
+ }
52
55
  else {
53
56
  writableMap.putNull(key);
54
57
  }
@@ -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.reactContext, buttonId, messageId, error ->
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
- this.reactContext.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class).emit(
295
- eventName,
296
- RNHelpers.convertMapToWritableMap(data)
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();
@@ -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| (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
+ | 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
- **For iOS**, (and 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 iOS 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).
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
- if (Platform.OS === 'ios') {
283
- /* Tells the Marigold Engage SDK to execute the action associated to the last push clicked, when using `delayedPushAction` feature.
284
- If you are having problems with deeplinks or 'Push + InApp Message' where the splash screen gets stuck or the push action not visible,
285
- 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)
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
  /**
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.9.2",
7
+ "version": "4.0.0",
8
8
  "description": "React Native wrapper for the Marigold Engage Android and iOS SDKs",
9
9
  "main": "index.js",
10
10
  "repository": {