@selligent-marketing-cloud/selligent-react-native 3.2.7 → 3.3.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 +21 -17
- package/RNSelligentMapper.podspec +22 -0
- package/android/build.gradle +1 -1
- package/android/src/main/java/com/selligent/RNSelligent.java +5 -1
- package/android/src/main/java/com/selligent/Settings.java +13 -1
- package/documentation/README.md +94 -20
- package/package.json +2 -3
- package/RNSelligent.podspec +0 -21
- package/ios/RNSelligentMobileSDK.xcframework/Info.plist +0 -40
- package/ios/RNSelligentMobileSDK.xcframework/ios-arm64/RNSelligentMobileSDK.framework/Headers/RNSelligentMobileSDK-Swift.h +0 -352
- package/ios/RNSelligentMobileSDK.xcframework/ios-arm64/RNSelligentMobileSDK.framework/Info.plist +0 -0
- package/ios/RNSelligentMobileSDK.xcframework/ios-arm64/RNSelligentMobileSDK.framework/Modules/RNSelligentMobileSDK.swiftmodule/arm64-apple-ios.abi.json +0 -2634
- package/ios/RNSelligentMobileSDK.xcframework/ios-arm64/RNSelligentMobileSDK.framework/Modules/RNSelligentMobileSDK.swiftmodule/arm64-apple-ios.private.swiftinterface +0 -60
- package/ios/RNSelligentMobileSDK.xcframework/ios-arm64/RNSelligentMobileSDK.framework/Modules/RNSelligentMobileSDK.swiftmodule/arm64-apple-ios.swiftdoc +0 -0
- package/ios/RNSelligentMobileSDK.xcframework/ios-arm64/RNSelligentMobileSDK.framework/Modules/RNSelligentMobileSDK.swiftmodule/arm64-apple-ios.swiftinterface +0 -60
- package/ios/RNSelligentMobileSDK.xcframework/ios-arm64/RNSelligentMobileSDK.framework/Modules/module.modulemap +0 -4
- package/ios/RNSelligentMobileSDK.xcframework/ios-arm64/RNSelligentMobileSDK.framework/RNSelligentMobileSDK +0 -0
- package/ios/RNSelligentMobileSDK.xcframework/ios-arm64/RNSelligentMobileSDK.framework/_CodeSignature/CodeResources +0 -179
- package/ios/RNSelligentMobileSDK.xcframework/ios-arm64_x86_64-simulator/RNSelligentMobileSDK.framework/Headers/RNSelligentMobileSDK-Swift.h +0 -700
- package/ios/RNSelligentMobileSDK.xcframework/ios-arm64_x86_64-simulator/RNSelligentMobileSDK.framework/Info.plist +0 -0
- package/ios/RNSelligentMobileSDK.xcframework/ios-arm64_x86_64-simulator/RNSelligentMobileSDK.framework/Modules/RNSelligentMobileSDK.swiftmodule/arm64-apple-ios-simulator.abi.json +0 -2634
- package/ios/RNSelligentMobileSDK.xcframework/ios-arm64_x86_64-simulator/RNSelligentMobileSDK.framework/Modules/RNSelligentMobileSDK.swiftmodule/arm64-apple-ios-simulator.private.swiftinterface +0 -60
- package/ios/RNSelligentMobileSDK.xcframework/ios-arm64_x86_64-simulator/RNSelligentMobileSDK.framework/Modules/RNSelligentMobileSDK.swiftmodule/arm64-apple-ios-simulator.swiftdoc +0 -0
- package/ios/RNSelligentMobileSDK.xcframework/ios-arm64_x86_64-simulator/RNSelligentMobileSDK.framework/Modules/RNSelligentMobileSDK.swiftmodule/arm64-apple-ios-simulator.swiftinterface +0 -60
- package/ios/RNSelligentMobileSDK.xcframework/ios-arm64_x86_64-simulator/RNSelligentMobileSDK.framework/Modules/RNSelligentMobileSDK.swiftmodule/x86_64-apple-ios-simulator.abi.json +0 -2634
- package/ios/RNSelligentMobileSDK.xcframework/ios-arm64_x86_64-simulator/RNSelligentMobileSDK.framework/Modules/RNSelligentMobileSDK.swiftmodule/x86_64-apple-ios-simulator.private.swiftinterface +0 -60
- package/ios/RNSelligentMobileSDK.xcframework/ios-arm64_x86_64-simulator/RNSelligentMobileSDK.framework/Modules/RNSelligentMobileSDK.swiftmodule/x86_64-apple-ios-simulator.swiftdoc +0 -0
- package/ios/RNSelligentMobileSDK.xcframework/ios-arm64_x86_64-simulator/RNSelligentMobileSDK.framework/Modules/RNSelligentMobileSDK.swiftmodule/x86_64-apple-ios-simulator.swiftinterface +0 -60
- package/ios/RNSelligentMobileSDK.xcframework/ios-arm64_x86_64-simulator/RNSelligentMobileSDK.framework/Modules/module.modulemap +0 -4
- package/ios/RNSelligentMobileSDK.xcframework/ios-arm64_x86_64-simulator/RNSelligentMobileSDK.framework/RNSelligentMobileSDK +0 -0
- package/ios/RNSelligentMobileSDK.xcframework/ios-arm64_x86_64-simulator/RNSelligentMobileSDK.framework/_CodeSignature/CodeResources +0 -234
package/README.md
CHANGED
|
@@ -2,21 +2,22 @@
|
|
|
2
2
|
|
|
3
3
|
This module provides an API for the usage of the Selligent Mobile SDKs in React Native.
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
This module uses the native Selligent SDKs:
|
|
5
|
+
## SelligentMobileSDK-ReactNative Integration
|
|
7
6
|
|
|
8
|
-
|
|
9
|
-
| ----------------------------------------------------------------------- | ------- |
|
|
10
|
-
| [Android](https://github.com/SelligentMarketingCloud/MobileSDK-Android) | 4.2.0 |
|
|
11
|
-
| [iOS](https://github.com/SelligentMarketingCloud/MobileSDK-iOS) | 3.5.1 |
|
|
7
|
+
This module supports the following SDK and tools:
|
|
12
8
|
|
|
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
|
-
|
|
16
|
-
|
|
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 |
|
|
17
17
|
|
|
18
18
|
## Installation
|
|
19
|
-
|
|
19
|
+
|
|
20
|
+
> Please refer to our [SDK full documentation](documentation/#reactnative--using-the-sdk) for a step-by-step guide on how to use the SDK, after installation.
|
|
20
21
|
|
|
21
22
|
1. Install the module
|
|
22
23
|
|
|
@@ -36,10 +37,12 @@ This module uses the native Selligent SDKs:
|
|
|
36
37
|
}
|
|
37
38
|
```
|
|
38
39
|
|
|
39
|
-
> Check all the options that can be used in our
|
|
40
|
+
> Check all the options that can be used in our [SDK full documentation](documentation/#working-with-the-selligentjson)
|
|
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:
|
|
@@ -153,7 +156,7 @@ This module uses the native Selligent SDKs:
|
|
|
153
156
|
```
|
|
154
157
|
|
|
155
158
|
</details>
|
|
156
|
-
|
|
159
|
+
|
|
157
160
|
<details open>
|
|
158
161
|
<summary>With autolinking (RN 0.60 and above)</summary>
|
|
159
162
|
|
|
@@ -172,14 +175,14 @@ This module uses the native Selligent SDKs:
|
|
|
172
175
|
}
|
|
173
176
|
```
|
|
174
177
|
|
|
175
|
-
|
|
178
|
+
3. Add the following in the `android/app/build.gradle` file (at the bottom):
|
|
176
179
|
|
|
177
180
|
```groovy
|
|
178
181
|
// Add the following:
|
|
179
182
|
apply plugin: 'com.google.gms.google-services'
|
|
180
183
|
```
|
|
181
184
|
|
|
182
|
-
|
|
185
|
+
4. Add the following in the `android/app/src/../MainApplication.java` file:
|
|
183
186
|
|
|
184
187
|
```java
|
|
185
188
|
// Add the following import statements:
|
|
@@ -196,6 +199,7 @@ This module uses the native Selligent SDKs:
|
|
|
196
199
|
}
|
|
197
200
|
}
|
|
198
201
|
```
|
|
202
|
+
|
|
199
203
|
</details>
|
|
200
204
|
|
|
201
205
|
### iOS Specific installation
|
|
@@ -209,7 +213,7 @@ This module uses the native Selligent SDKs:
|
|
|
209
213
|
|
|
210
214
|
> Do not check the "copy if needed" option to make sure you only have to manage one selligent.json file
|
|
211
215
|
|
|
212
|
-
3. Add the native iOS SDK dependency in your Podfile: `s.dependency "SelligentMobileSDK/Framework", "3.
|
|
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**.
|
|
213
217
|
|
|
214
218
|
4. Execute `pod install` in the `/ios` folder
|
|
215
219
|
|
|
@@ -230,7 +234,7 @@ This module uses the native Selligent SDKs:
|
|
|
230
234
|
```
|
|
231
235
|
|
|
232
236
|
</details>
|
|
233
|
-
|
|
237
|
+
|
|
234
238
|
<details open>
|
|
235
239
|
<summary>With autolinking (RN 0.60 and above)</summary>
|
|
236
240
|
|
|
@@ -251,4 +255,4 @@ This module uses the native Selligent SDKs:
|
|
|
251
255
|
[RNSelligent configureWithLaunchOptions:launchOptions];
|
|
252
256
|
```
|
|
253
257
|
|
|
254
|
-
</details>
|
|
258
|
+
</details>
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
require "json"
|
|
2
|
+
|
|
3
|
+
package = JSON.parse(File.read(File.join(__dir__, "package.json")))
|
|
4
|
+
|
|
5
|
+
Pod::Spec.new do |s|
|
|
6
|
+
s.name = "RNSelligentMapper"
|
|
7
|
+
s.authors = package['author']
|
|
8
|
+
s.version = package["version"]
|
|
9
|
+
s.summary = package["description"]
|
|
10
|
+
s.description = "React Native wrapper mapper for the Selligent Marketing Cloud Android and iOS SDKs"
|
|
11
|
+
s.homepage = package['homepage']
|
|
12
|
+
s.license = "MIT"
|
|
13
|
+
s.platform = :ios, "12.0"
|
|
14
|
+
s.source = { :git => "https://github.com/SelligentMarketingCloud/MobileSDK-ReactNative.git", :tag => "v" + s.version.to_s }
|
|
15
|
+
s.swift_version = "5.0"
|
|
16
|
+
|
|
17
|
+
s.source_files = "ios/*.{h,m}"
|
|
18
|
+
|
|
19
|
+
s.dependency "React-Core"
|
|
20
|
+
s.dependency "RNSelligent"
|
|
21
|
+
end
|
|
22
|
+
|
package/android/build.gradle
CHANGED
|
@@ -53,7 +53,7 @@ dependencies {
|
|
|
53
53
|
exclude group:'com.facebook.fbjni'
|
|
54
54
|
exclude group:'com.facebook.yoga'
|
|
55
55
|
}
|
|
56
|
-
implementation 'com.selligent.sdk:selligent_mobile_sdk:4.
|
|
56
|
+
implementation 'com.selligent.sdk:selligent_mobile_sdk:4.3.0'
|
|
57
57
|
implementation 'com.google.code.gson:gson:2.9.0'
|
|
58
58
|
implementation 'com.google.firebase:firebase-messaging:23.0.8'
|
|
59
59
|
implementation 'androidx.work:work-runtime:2.8.1'
|
|
@@ -101,7 +101,7 @@ public class RNSelligent extends ReactContextBaseJavaModule implements Lifecycle
|
|
|
101
101
|
inAppMessageRefreshType = settings.getInAppMessageRefreshType().getSmInAppRefreshType();
|
|
102
102
|
|
|
103
103
|
final SMManager smManager = getSMManager();
|
|
104
|
-
SMManager.DEBUG = BuildConfig.BUILD_TYPE.equals("debug");
|
|
104
|
+
SMManager.DEBUG = BuildConfig.BUILD_TYPE.equals("debug") || settings.getEnableAndroidLogging();
|
|
105
105
|
smManager.start(smSettings, application);
|
|
106
106
|
|
|
107
107
|
final Resources resources = application.getResources();
|
|
@@ -346,6 +346,10 @@ public class RNSelligent extends ReactContextBaseJavaModule implements Lifecycle
|
|
|
346
346
|
}
|
|
347
347
|
}
|
|
348
348
|
|
|
349
|
+
public static void enableNotifications() {
|
|
350
|
+
SMManager.getInstance().enableNotifications();
|
|
351
|
+
}
|
|
352
|
+
|
|
349
353
|
@ReactMethod
|
|
350
354
|
public void displayLastReceivedRemotePushNotification(String templateId) {
|
|
351
355
|
final Activity currentActivity = getCurrentActivity();
|
|
@@ -22,6 +22,7 @@ class Settings {
|
|
|
22
22
|
private String notificationChannelId = "SMChannel001";
|
|
23
23
|
private String notificationChannelName = "SMDefaultChannel";
|
|
24
24
|
private String notificationChannelDescription = "";
|
|
25
|
+
private Boolean enableAndroidLogging = false;
|
|
25
26
|
|
|
26
27
|
private Settings() { }
|
|
27
28
|
|
|
@@ -85,6 +86,8 @@ class Settings {
|
|
|
85
86
|
return notificationChannelDescription;
|
|
86
87
|
}
|
|
87
88
|
|
|
89
|
+
public Boolean getEnableAndroidLogging() { return enableAndroidLogging; }
|
|
90
|
+
|
|
88
91
|
public static Settings fromHashMap(Map<String, Object> settingsHashMap) {
|
|
89
92
|
final Settings settings = new Settings();
|
|
90
93
|
|
|
@@ -101,7 +104,7 @@ class Settings {
|
|
|
101
104
|
settings.notificationLargeIcon = (String) settingsHashMap.get("notificationLargeIcon");
|
|
102
105
|
}
|
|
103
106
|
|
|
104
|
-
if(settingsHashMap.containsKey("notificationIconColor")) {
|
|
107
|
+
if (settingsHashMap.containsKey("notificationIconColor")) {
|
|
105
108
|
settings.notificationIconColor = (String) settingsHashMap.get("notificationIconColor");
|
|
106
109
|
}
|
|
107
110
|
|
|
@@ -120,24 +123,33 @@ class Settings {
|
|
|
120
123
|
if (settingsHashMap.containsKey("loadCacheAsynchronously")) {
|
|
121
124
|
settings.loadCacheAsynchronously = (Boolean) settingsHashMap.get("loadCacheAsynchronously");
|
|
122
125
|
}
|
|
126
|
+
|
|
123
127
|
if (settingsHashMap.containsKey("notificationChannelId")) {
|
|
124
128
|
settings.notificationChannelId = (String) settingsHashMap.get("notificationChannelId");
|
|
125
129
|
}
|
|
130
|
+
|
|
126
131
|
if (settingsHashMap.containsKey("notificationChannelName")) {
|
|
127
132
|
settings.notificationChannelName = (String) settingsHashMap.get("notificationChannelName");
|
|
128
133
|
}
|
|
134
|
+
|
|
129
135
|
if (settingsHashMap.containsKey("notificationChannelDescription")) {
|
|
130
136
|
settings.notificationChannelDescription = (String) settingsHashMap.get("notificationChannelDescription");
|
|
131
137
|
}
|
|
132
138
|
|
|
139
|
+
if (settingsHashMap.containsKey("enableAndroidLogging")) {
|
|
140
|
+
settings.enableAndroidLogging = (Boolean) settingsHashMap.get("enableAndroidLogging");
|
|
141
|
+
}
|
|
142
|
+
|
|
133
143
|
final Double clearCacheIndex = (Double) settingsHashMap.get("clearCacheIntervalValue");
|
|
134
144
|
if (clearCacheIndex != null) {
|
|
135
145
|
settings.clearCacheIntervalValue = ClearCacheIntervalValue.valueOf(clearCacheIndex.intValue());
|
|
136
146
|
}
|
|
147
|
+
|
|
137
148
|
final Double inAppMsgRefreshIndex = (Double) settingsHashMap.get("inAppMessageRefreshType");
|
|
138
149
|
if (inAppMsgRefreshIndex != null) {
|
|
139
150
|
settings.inAppMessageRefreshType = InAppMessageRefreshType.valueOf(inAppMsgRefreshIndex.intValue());
|
|
140
151
|
}
|
|
152
|
+
|
|
141
153
|
final Double remoteMsgRefreshIndex = (Double) settingsHashMap.get("remoteMessageDisplayType");
|
|
142
154
|
if (remoteMsgRefreshIndex != null) {
|
|
143
155
|
settings.remoteMessageDisplayType = RemoteMessageDisplayType.valueOf(remoteMsgRefreshIndex.intValue());
|
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)
|
|
@@ -73,7 +74,9 @@ The following properties can be used in the `selligent.json` to further configur
|
|
|
73
74
|
| remoteMessageDisplayType | [enum](#remotemessagesdisplaytype) | The behaviour when receiving a push notification with the app in foreground |
|
|
74
75
|
| appGroupId | string |(iOS Only) The appgroup id necessary for the correct communication between the app and the app extensions |
|
|
75
76
|
| shouldClearBadge | boolean | (iOS Only) Whether or not, clicking a push notification should reset the badge number |
|
|
76
|
-
| shouldDisplayRemoteNotification | boolean | (iOS Only) Whether or not, the SDK should try to display the content linked to a push message (usually, inapp messages) or it will be handled customly
|
|
77
|
+
| shouldDisplayRemoteNotification | boolean | (iOS Only) Whether or not, the SDK should try to display the content linked to a push message (usually, inapp messages) or it will be handled customly
|
|
78
|
+
| enableiOSLogging | [enum](#iosloglevel) | Log level used since the app launch |
|
|
79
|
+
| enableAndroidLogging | boolean | (Android Only) Whether or not, the SDK logging will be enabled since the app launch |
|
|
77
80
|
| doNotListenToThePush | boolean | (Android Only) Whether or not, the SDK will listen for pushs from google |
|
|
78
81
|
| doNotFetchTheToken | boolean | (Android Only) Whether or not, the SDK will listen for push tokens from google |
|
|
79
82
|
| loadCacheAsynchronously | boolean | (Android Only) Whether or not, the SDK load the cache asynchronously |
|
|
@@ -89,7 +92,44 @@ The following properties can be used in the `selligent.json` to further configur
|
|
|
89
92
|
|
|
90
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.
|
|
91
94
|
|
|
92
|
-
**For
|
|
95
|
+
**For Android**, if targeting API level 33 and above:
|
|
96
|
+
1. Add this to request the push permission and let the SDK know when it is accepted, in the activity where you want to:
|
|
97
|
+
```java
|
|
98
|
+
import com.selligent.RNSelligent;
|
|
99
|
+
|
|
100
|
+
public class MainActivity extends ReactActivity {
|
|
101
|
+
final int NOTIFICATION_PERMISSION_REQUEST_CODE = 1111;
|
|
102
|
+
|
|
103
|
+
@Override
|
|
104
|
+
public void onStart()
|
|
105
|
+
{
|
|
106
|
+
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.S_V2)
|
|
107
|
+
{
|
|
108
|
+
if (ContextCompat.checkSelfPermission(this, Manifest.permission.POST_NOTIFICATIONS) != PackageManager.PERMISSION_GRANTED)
|
|
109
|
+
{
|
|
110
|
+
ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.POST_NOTIFICATIONS}, NOTIFICATION_PERMISSION_REQUEST_CODE);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
super.onStart();
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
@Override
|
|
118
|
+
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults)
|
|
119
|
+
{
|
|
120
|
+
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
|
|
121
|
+
|
|
122
|
+
if (requestCode == NOTIFICATION_PERMISSION_REQUEST_CODE)
|
|
123
|
+
{
|
|
124
|
+
if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED)
|
|
125
|
+
{
|
|
126
|
+
RNSelligent.enableNotifications();
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
**For iOS**:
|
|
93
133
|
|
|
94
134
|
1. For push notifications you need to delegate some of the `AppDelegate.m` methods to the SDK:
|
|
95
135
|
|
|
@@ -158,14 +198,16 @@ Follow the [iOS](https://github.com/SelligentMarketingCloud/MobileSDK-iOS/tree/m
|
|
|
158
198
|
```javascript
|
|
159
199
|
import Selligent from "@selligent-marketing-cloud/selligent-react-native"; // Add Selligent import
|
|
160
200
|
|
|
161
|
-
|
|
162
|
-
(
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
201
|
+
if (Platform.OS === 'ios') {
|
|
202
|
+
Selligent.enableNotifications(
|
|
203
|
+
(response) => { // success callback
|
|
204
|
+
},
|
|
205
|
+
(error) => { // error callback
|
|
206
|
+
},
|
|
207
|
+
true
|
|
208
|
+
)
|
|
209
|
+
}
|
|
210
|
+
|
|
169
211
|
Selligent.registerForProvisionalRemoteNotification(
|
|
170
212
|
() => { // success callback
|
|
171
213
|
}
|
|
@@ -197,8 +239,8 @@ This is because the JS layer is loaded **after** the native iOS SDK executes the
|
|
|
197
239
|
|
|
198
240
|
```javascript
|
|
199
241
|
// In DeeplinkHook.js
|
|
200
|
-
import { useEffect } from "react"
|
|
201
|
-
import { Alert, Linking } from "react-native"
|
|
242
|
+
import { useEffect } from "react"
|
|
243
|
+
import { Alert, Linking } from "react-native"
|
|
202
244
|
|
|
203
245
|
const useHandleDeepLink = () => {
|
|
204
246
|
useEffect(() => {
|
|
@@ -207,22 +249,22 @@ This is because the JS layer is loaded **after** the native iOS SDK executes the
|
|
|
207
249
|
Alert.alert('Deep Link', link || 'No link')
|
|
208
250
|
}
|
|
209
251
|
}).catch(err => {
|
|
210
|
-
console.warn('An error occurred', err)
|
|
211
|
-
})
|
|
252
|
+
console.warn('An error occurred', err)
|
|
253
|
+
})
|
|
212
254
|
|
|
213
|
-
const urlListener = Linking.addEventListener('url', ({url}) => Alert.alert('Deep Link', url || 'No link'))
|
|
255
|
+
const urlListener = Linking.addEventListener('url', ({url}) => Alert.alert('Deep Link', url || 'No link'))
|
|
214
256
|
|
|
215
|
-
return () => urlListener.remove()
|
|
257
|
+
return () => urlListener.remove()
|
|
216
258
|
}, [])
|
|
217
|
-
}
|
|
259
|
+
}
|
|
218
260
|
|
|
219
|
-
export default useHandleDeepLink
|
|
261
|
+
export default useHandleDeepLink
|
|
220
262
|
```
|
|
221
263
|
|
|
222
264
|
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)
|
|
223
265
|
|
|
224
266
|
```javascript
|
|
225
|
-
import Selligent from "@selligent-marketing-cloud/selligent-react-native"
|
|
267
|
+
import Selligent from "@selligent-marketing-cloud/selligent-react-native" // Add Selligent import
|
|
226
268
|
|
|
227
269
|
const App = () => {
|
|
228
270
|
// Deeplinking handling library (i.e Linking.getInitialURL() & Linking.addEventListener...)
|
|
@@ -237,6 +279,38 @@ This is because the JS layer is loaded **after** the native iOS SDK executes the
|
|
|
237
279
|
}
|
|
238
280
|
```
|
|
239
281
|
|
|
282
|
+
#### Background Modes
|
|
283
|
+
|
|
284
|
+
**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.
|
|
285
|
+
|
|
286
|
+
```objective-c
|
|
287
|
+
static BOOL launchedFromBackground = false;
|
|
288
|
+
|
|
289
|
+
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
|
|
290
|
+
if ([[UIApplication sharedApplication] applicationState] == UIApplicationStateBackground) {
|
|
291
|
+
launchedFromBackground = true;
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
// Other setup code
|
|
295
|
+
|
|
296
|
+
return [super application:application didFinishLaunchingWithOptions:launchOptions];
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url options:(NSDictionary<UIApplicationOpenURLOptionsKey,id> *)options {
|
|
300
|
+
if (launchedFromBackground) {
|
|
301
|
+
launchedFromBackground = false;
|
|
302
|
+
|
|
303
|
+
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 0.5 * NSEC_PER_SEC), dispatch_get_main_queue(), ^{
|
|
304
|
+
[RCTLinkingManager application:application openURL:url options:options];
|
|
305
|
+
});
|
|
306
|
+
|
|
307
|
+
return [super application:application openURL:url options:options];
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
return [super application:application openURL:url options:options] || [RCTLinkingManager application:application openURL:url options:options];
|
|
311
|
+
}
|
|
312
|
+
```
|
|
313
|
+
|
|
240
314
|
#### Universal Linking - iOS
|
|
241
315
|
|
|
242
316
|
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.
|
|
@@ -714,7 +788,7 @@ The `data` property is an object itself containing more information specific to
|
|
|
714
788
|
Add the following import to work with the constants:
|
|
715
789
|
|
|
716
790
|
```javascript
|
|
717
|
-
import SelligentConstants from "@selligent-marketing-cloud/selligent-react-native/constants"
|
|
791
|
+
import SelligentConstants from "@selligent-marketing-cloud/selligent-react-native/constants"
|
|
718
792
|
```
|
|
719
793
|
|
|
720
794
|
### 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.
|
|
7
|
+
"version": "3.3.1",
|
|
8
8
|
"description": "React Native wrapper for the Selligent Marketing Cloud Android and iOS SDKs",
|
|
9
9
|
"main": "index.js",
|
|
10
10
|
"repository": {
|
|
@@ -38,10 +38,9 @@
|
|
|
38
38
|
"test": "jest"
|
|
39
39
|
},
|
|
40
40
|
"files": [
|
|
41
|
-
"/
|
|
41
|
+
"/RNSelligentMapper.podspec",
|
|
42
42
|
"/*.js",
|
|
43
43
|
"/*.ts",
|
|
44
|
-
"/ios/RNSelligentMobileSDK.xcframework",
|
|
45
44
|
"/ios/*.h",
|
|
46
45
|
"/ios/*.m",
|
|
47
46
|
"/android/src/main",
|
package/RNSelligent.podspec
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
require "json"
|
|
2
|
-
|
|
3
|
-
package = JSON.parse(File.read(File.join(__dir__, "package.json")))
|
|
4
|
-
|
|
5
|
-
Pod::Spec.new do |s|
|
|
6
|
-
s.name = "RNSelligent"
|
|
7
|
-
s.authors = package['author']
|
|
8
|
-
s.version = package["version"]
|
|
9
|
-
s.summary = package["description"]
|
|
10
|
-
s.description = "React Native wrapper for the Selligent Marketing Cloud Android and iOS SDKs"
|
|
11
|
-
s.homepage = package['homepage']
|
|
12
|
-
s.license = "MIT"
|
|
13
|
-
s.platform = :ios, "11.0"
|
|
14
|
-
s.source = { :git => "https://github.com/SelligentMarketingCloud/MobileSDK-ReactNative.git", :tag => "#{s.version}" }
|
|
15
|
-
|
|
16
|
-
s.vendored_frameworks = "ios/RNSelligentMobileSDK.xcframework"
|
|
17
|
-
s.source_files = "ios/*.{h,m}"
|
|
18
|
-
|
|
19
|
-
s.dependency "React-Core"
|
|
20
|
-
s.dependency "SelligentMobileSDK/Framework", "3.5.1"
|
|
21
|
-
end
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
-
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
3
|
-
<plist version="1.0">
|
|
4
|
-
<dict>
|
|
5
|
-
<key>AvailableLibraries</key>
|
|
6
|
-
<array>
|
|
7
|
-
<dict>
|
|
8
|
-
<key>LibraryIdentifier</key>
|
|
9
|
-
<string>ios-arm64</string>
|
|
10
|
-
<key>LibraryPath</key>
|
|
11
|
-
<string>RNSelligentMobileSDK.framework</string>
|
|
12
|
-
<key>SupportedArchitectures</key>
|
|
13
|
-
<array>
|
|
14
|
-
<string>arm64</string>
|
|
15
|
-
</array>
|
|
16
|
-
<key>SupportedPlatform</key>
|
|
17
|
-
<string>ios</string>
|
|
18
|
-
</dict>
|
|
19
|
-
<dict>
|
|
20
|
-
<key>LibraryIdentifier</key>
|
|
21
|
-
<string>ios-arm64_x86_64-simulator</string>
|
|
22
|
-
<key>LibraryPath</key>
|
|
23
|
-
<string>RNSelligentMobileSDK.framework</string>
|
|
24
|
-
<key>SupportedArchitectures</key>
|
|
25
|
-
<array>
|
|
26
|
-
<string>arm64</string>
|
|
27
|
-
<string>x86_64</string>
|
|
28
|
-
</array>
|
|
29
|
-
<key>SupportedPlatform</key>
|
|
30
|
-
<string>ios</string>
|
|
31
|
-
<key>SupportedPlatformVariant</key>
|
|
32
|
-
<string>simulator</string>
|
|
33
|
-
</dict>
|
|
34
|
-
</array>
|
|
35
|
-
<key>CFBundlePackageType</key>
|
|
36
|
-
<string>XFWK</string>
|
|
37
|
-
<key>XCFrameworkFormatVersion</key>
|
|
38
|
-
<string>1.0</string>
|
|
39
|
-
</dict>
|
|
40
|
-
</plist>
|