@selligent-marketing-cloud/selligent-react-native 3.3.0 → 3.3.2
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
|
@@ -4,15 +4,16 @@ This module provides an API for the usage of the Selligent Mobile SDKs in React
|
|
|
4
4
|
|
|
5
5
|
## SelligentMobileSDK-ReactNative Integration
|
|
6
6
|
|
|
7
|
-
This module
|
|
7
|
+
This module supports the following SDK and tools:
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
| ----------------------------------------------------------------------- | ------- |
|
|
11
|
-
| [Android](https://github.com/SelligentMarketingCloud/MobileSDK-Android) | 4.3.0 |
|
|
12
|
-
| [iOS](https://github.com/SelligentMarketingCloud/MobileSDK-iOS) | 3.6.0 |
|
|
9
|
+
> **IMPORTANT** This module doesn't currently support REACT NATIVE'S NEW ARCHITECTURE! The following library contains React native modules, that are tailored to and can only be used in React Native's legacy architecture, that will be deprecated in the future when the new architecture will be stable.
|
|
13
10
|
|
|
14
|
-
|
|
15
|
-
|
|
11
|
+
| SDK | Version |
|
|
12
|
+
| ------------------------------------------------------------------------------ | ------- |
|
|
13
|
+
| [Android SDK](https://github.com/SelligentMarketingCloud/MobileSDK-Android) | 4.3.0 |
|
|
14
|
+
| [iOS SDK](https://github.com/SelligentMarketingCloud/MobileSDK-iOS) | 3.6.1 |
|
|
15
|
+
| ReactNative | 0.71.8 |
|
|
16
|
+
| Expo SDK | 48 |
|
|
16
17
|
|
|
17
18
|
## Installation
|
|
18
19
|
|
|
@@ -40,6 +41,8 @@ This module uses the native Selligent SDKs:
|
|
|
40
41
|
|
|
41
42
|
### Android Specific Installation
|
|
42
43
|
|
|
44
|
+
> **IMPORTANT:** Since version 2.6.0 of this module we require your app to use the Android Gradle Plugin version 4.2.0 or higher in order to build on Android. This is the default Android Gradle Plugin version since React Native version 0.64.0 but can be manually increased in older versions of React Native.
|
|
45
|
+
|
|
43
46
|
> ### **Attention for Huawei developers!**
|
|
44
47
|
>
|
|
45
48
|
> In order to use this module on Huawei devices (without Goggle Play services), you should add the following dependencies in the `build.gradle` files of the Android project in your React Native project:
|
|
@@ -210,7 +213,7 @@ This module uses the native Selligent SDKs:
|
|
|
210
213
|
|
|
211
214
|
> Do not check the "copy if needed" option to make sure you only have to manage one selligent.json file
|
|
212
215
|
|
|
213
|
-
3. Add the native iOS SDK dependency in your Podfile: `s.dependency "SelligentMobileSDK/Framework", "3.6.
|
|
216
|
+
3. Add the native iOS SDK dependency in your Podfile: `s.dependency "SelligentMobileSDK/Framework", "3.6.1"` or download it manually from [here](https://github.com/SelligentMarketingCloud/MobileSDK-iOS/tree/master/Framework) and drag and drop it into you **Xcode project**.
|
|
214
217
|
|
|
215
218
|
4. Execute `pod install` in the `/ios` folder
|
|
216
219
|
|
|
@@ -17,7 +17,7 @@ class Settings {
|
|
|
17
17
|
private Boolean doNotListenToThePush = false;
|
|
18
18
|
private Boolean loadCacheAsynchronously = false;
|
|
19
19
|
private ClearCacheIntervalValue clearCacheIntervalValue;
|
|
20
|
-
private InAppMessageRefreshType inAppMessageRefreshType;
|
|
20
|
+
private InAppMessageRefreshType inAppMessageRefreshType = InAppMessageRefreshType.NONE;
|
|
21
21
|
private RemoteMessageDisplayType remoteMessageDisplayType;
|
|
22
22
|
private String notificationChannelId = "SMChannel001";
|
|
23
23
|
private String notificationChannelName = "SMDefaultChannel";
|
package/documentation/README.md
CHANGED
|
@@ -25,6 +25,7 @@ Selligent welcomes any recommendations or suggestions regarding the manual, as i
|
|
|
25
25
|
- [Push notifications](#push-notifications)
|
|
26
26
|
- [Rich Push Notifications](#rich-push-notifications)
|
|
27
27
|
- [Deep Linking](#deep-linking)
|
|
28
|
+
- [Background Modes](#background-modes)
|
|
28
29
|
- [Universal Linking - iOS](#universal-linking---ios)
|
|
29
30
|
- [Notification helper methods](#notification-helper-methods)
|
|
30
31
|
- [Disable Selligent Push Notifications](#disable-selligent-push-notifications)
|
|
@@ -92,41 +93,46 @@ The following properties can be used in the `selligent.json` to further configur
|
|
|
92
93
|
Follow the [iOS](https://github.com/SelligentMarketingCloud/MobileSDK-iOS/tree/master/Documentation#create-an-apns-key) & [Android](https://github.com/SelligentMarketingCloud/MobileSDK-Android/tree/master/Documentation#creating-an-application) native SDKs guides in order to optin for push notifications in Apple & Google.
|
|
93
94
|
|
|
94
95
|
**For Android**, if targeting API level 33 and above:
|
|
95
|
-
1. Add
|
|
96
|
-
```
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
public class MainActivity extends ReactActivity {
|
|
100
|
-
final int NOTIFICATION_PERMISSION_REQUEST_CODE = 1111;
|
|
96
|
+
1. Add the following line to AndroidManifest.xml:
|
|
97
|
+
```xml
|
|
98
|
+
<uses-permission android:name="android.permission.POST_NOTIFICATIONS"/>
|
|
99
|
+
```
|
|
101
100
|
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
{
|
|
107
|
-
|
|
101
|
+
2. Add this native code to request the push permission and let the SDK know when it is accepted, in the activity where you want to:
|
|
102
|
+
```java
|
|
103
|
+
import com.selligent.RNSelligent;
|
|
104
|
+
|
|
105
|
+
public class MainActivity extends ReactActivity {
|
|
106
|
+
final int NOTIFICATION_PERMISSION_REQUEST_CODE = 1111;
|
|
107
|
+
|
|
108
|
+
@Override
|
|
109
|
+
public void onStart()
|
|
108
110
|
{
|
|
109
|
-
|
|
111
|
+
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.S_V2)
|
|
112
|
+
{
|
|
113
|
+
if (ContextCompat.checkSelfPermission(this, Manifest.permission.POST_NOTIFICATIONS) != PackageManager.PERMISSION_GRANTED)
|
|
114
|
+
{
|
|
115
|
+
ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.POST_NOTIFICATIONS}, NOTIFICATION_PERMISSION_REQUEST_CODE);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
super.onStart();
|
|
110
120
|
}
|
|
111
|
-
}
|
|
112
121
|
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
@Override
|
|
117
|
-
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults)
|
|
118
|
-
{
|
|
119
|
-
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
|
|
120
|
-
|
|
121
|
-
if (requestCode == NOTIFICATION_PERMISSION_REQUEST_CODE)
|
|
122
|
+
@Override
|
|
123
|
+
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults)
|
|
122
124
|
{
|
|
123
|
-
|
|
125
|
+
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
|
|
126
|
+
|
|
127
|
+
if (requestCode == NOTIFICATION_PERMISSION_REQUEST_CODE)
|
|
124
128
|
{
|
|
125
|
-
|
|
129
|
+
if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED)
|
|
130
|
+
{
|
|
131
|
+
RNSelligent.enableNotifications();
|
|
132
|
+
}
|
|
126
133
|
}
|
|
127
134
|
}
|
|
128
|
-
|
|
129
|
-
```
|
|
135
|
+
```
|
|
130
136
|
|
|
131
137
|
**For iOS**:
|
|
132
138
|
|
|
@@ -238,8 +244,8 @@ This is because the JS layer is loaded **after** the native iOS SDK executes the
|
|
|
238
244
|
|
|
239
245
|
```javascript
|
|
240
246
|
// In DeeplinkHook.js
|
|
241
|
-
import { useEffect } from "react"
|
|
242
|
-
import { Alert, Linking } from "react-native"
|
|
247
|
+
import { useEffect } from "react"
|
|
248
|
+
import { Alert, Linking } from "react-native"
|
|
243
249
|
|
|
244
250
|
const useHandleDeepLink = () => {
|
|
245
251
|
useEffect(() => {
|
|
@@ -248,22 +254,22 @@ This is because the JS layer is loaded **after** the native iOS SDK executes the
|
|
|
248
254
|
Alert.alert('Deep Link', link || 'No link')
|
|
249
255
|
}
|
|
250
256
|
}).catch(err => {
|
|
251
|
-
console.warn('An error occurred', err)
|
|
252
|
-
})
|
|
257
|
+
console.warn('An error occurred', err)
|
|
258
|
+
})
|
|
253
259
|
|
|
254
|
-
const urlListener = Linking.addEventListener('url', ({url}) => Alert.alert('Deep Link', url || 'No link'))
|
|
260
|
+
const urlListener = Linking.addEventListener('url', ({url}) => Alert.alert('Deep Link', url || 'No link'))
|
|
255
261
|
|
|
256
|
-
return () => urlListener.remove()
|
|
262
|
+
return () => urlListener.remove()
|
|
257
263
|
}, [])
|
|
258
|
-
}
|
|
264
|
+
}
|
|
259
265
|
|
|
260
|
-
export default useHandleDeepLink
|
|
266
|
+
export default useHandleDeepLink
|
|
261
267
|
```
|
|
262
268
|
|
|
263
269
|
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)
|
|
264
270
|
|
|
265
271
|
```javascript
|
|
266
|
-
import Selligent from "@selligent-marketing-cloud/selligent-react-native"
|
|
272
|
+
import Selligent from "@selligent-marketing-cloud/selligent-react-native" // Add Selligent import
|
|
267
273
|
|
|
268
274
|
const App = () => {
|
|
269
275
|
// Deeplinking handling library (i.e Linking.getInitialURL() & Linking.addEventListener...)
|
|
@@ -278,6 +284,38 @@ This is because the JS layer is loaded **after** the native iOS SDK executes the
|
|
|
278
284
|
}
|
|
279
285
|
```
|
|
280
286
|
|
|
287
|
+
#### Background Modes
|
|
288
|
+
|
|
289
|
+
**For iOS**, (if your app supports Background Modes) it is possible that after the app is launched from the background (location update, background push notification...) if the next action the user performs is executing a deeplink (via safari, push notification click...) the deeplink won't do anything. This is because the communication between the native part and the RN layer is not ready yet when the deeplink is executed from the native side. To workaround this, you can catch when the app is launched from the background and add a bit of delay before the `RCTLinkingManager openUrl` gets executed.
|
|
290
|
+
|
|
291
|
+
```objective-c
|
|
292
|
+
static BOOL launchedFromBackground = false;
|
|
293
|
+
|
|
294
|
+
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
|
|
295
|
+
if ([[UIApplication sharedApplication] applicationState] == UIApplicationStateBackground) {
|
|
296
|
+
launchedFromBackground = true;
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
// Other setup code
|
|
300
|
+
|
|
301
|
+
return [super application:application didFinishLaunchingWithOptions:launchOptions];
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url options:(NSDictionary<UIApplicationOpenURLOptionsKey,id> *)options {
|
|
305
|
+
if (launchedFromBackground) {
|
|
306
|
+
launchedFromBackground = false;
|
|
307
|
+
|
|
308
|
+
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 0.5 * NSEC_PER_SEC), dispatch_get_main_queue(), ^{
|
|
309
|
+
[RCTLinkingManager application:application openURL:url options:options];
|
|
310
|
+
});
|
|
311
|
+
|
|
312
|
+
return [super application:application openURL:url options:options];
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
return [super application:application openURL:url options:options] || [RCTLinkingManager application:application openURL:url options:options];
|
|
316
|
+
}
|
|
317
|
+
```
|
|
318
|
+
|
|
281
319
|
#### Universal Linking - iOS
|
|
282
320
|
|
|
283
321
|
By default, universal links in a button from a Push/IAM will open the default browser, to avoid this and catch them on the App and apply any logic you want, you will need to add a property `interceptSelligentUniversalLinks` in the `selligent.json` with `true` as value.
|
|
@@ -755,7 +793,7 @@ The `data` property is an object itself containing more information specific to
|
|
|
755
793
|
Add the following import to work with the constants:
|
|
756
794
|
|
|
757
795
|
```javascript
|
|
758
|
-
import SelligentConstants from "@selligent-marketing-cloud/selligent-react-native/constants"
|
|
796
|
+
import SelligentConstants from "@selligent-marketing-cloud/selligent-react-native/constants"
|
|
759
797
|
```
|
|
760
798
|
|
|
761
799
|
### ClearCacheIntervalValue
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
},
|
|
5
5
|
"name": "@selligent-marketing-cloud/selligent-react-native",
|
|
6
6
|
"title": "Selligent React Native",
|
|
7
|
-
"version": "3.3.
|
|
7
|
+
"version": "3.3.2",
|
|
8
8
|
"description": "React Native wrapper for the Selligent Marketing Cloud Android and iOS SDKs",
|
|
9
9
|
"main": "index.js",
|
|
10
10
|
"repository": {
|