@selligent-marketing-cloud/selligent-react-native 2.2.0 → 2.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 +287 -236
- package/RNSelligent.podspec +4 -4
- package/android/build.gradle +34 -26
- package/android/libs/sdk-release.aar +0 -0
- package/android/src/main/java/com/selligent/RNSelligent.java +54 -11
- package/android/src/main/java/com/selligent/SMSettingsFactory.java +1 -0
- package/android/src/main/java/com/selligent/Settings.java +16 -0
- package/constants.d.ts +103 -0
- package/constants.js +29 -1
- package/index.android.js +132 -0
- package/index.d.ts +124 -0
- package/index.ios.js +59 -15
- package/index.js +84 -2
- package/ios/ClientSettings.h +2 -0
- package/ios/ClientSettings.m +4 -0
- package/ios/EnumMapper.h +3 -6
- package/ios/EnumMapper.m +8 -24
- package/ios/RNSelligent.m +25 -13
- package/ios/RemoteMessageDisplayType.h +5 -0
- package/ios/SMManagerSetting+ClientSettings.m +20 -5
- package/ios/SelligentReactNative.xcodeproj/project.pbxproj +4 -4
- package/ios/include/SMBaseMessage.h +8 -8
- package/ios/include/SMBlock.h +2 -2
- package/ios/include/SMClearCache.h +0 -2
- package/ios/include/SMContentAlignment.h +1 -2
- package/ios/include/SMDeviceInfos.h +10 -8
- package/ios/include/SMDisplayMode.h +1 -2
- package/ios/include/SMEvent.h +20 -16
- package/ios/include/SMEventUser.h +0 -1
- package/ios/include/SMEventUserLogin.h +11 -16
- package/ios/include/SMEventUserLogout.h +12 -16
- package/ios/include/SMEventUserRegistration.h +12 -17
- package/ios/include/SMEventUserUnregistration.h +12 -16
- package/ios/include/SMFailure.h +1 -6
- package/ios/include/SMHelper.h +12 -4
- package/ios/include/SMInAppContentHTMLViewController.h +11 -9
- package/ios/include/SMInAppContentImageViewController.h +6 -5
- package/ios/include/SMInAppContentMessage.h +12 -12
- package/ios/include/SMInAppContentStyleOptions.h +91 -79
- package/ios/include/SMInAppContentType.h +2 -3
- package/ios/include/SMInAppContentURLViewController.h +10 -9
- package/ios/include/SMInAppContentViewController.h +3 -5
- package/ios/include/SMInAppMessage.h +22 -14
- package/ios/include/SMInAppMessageType.h +1 -5
- package/ios/include/SMInAppRefreshType.h +1 -1
- package/ios/include/SMLink.h +7 -11
- package/ios/include/SMLog.h +1 -1
- package/ios/include/SMManager+DataTransaction.h +6 -13
- package/ios/include/SMManager+InAppContent.h +20 -23
- package/ios/include/SMManager+InAppMessage.h +68 -31
- package/ios/include/SMManager+Location.h +7 -63
- package/ios/include/SMManager+Log.h +3 -14
- package/ios/include/SMManager+RemoteNotification.h +38 -34
- package/ios/include/SMManager+SMEvent.h +10 -10
- package/ios/include/SMManager+SMLink.h +44 -0
- package/ios/include/SMManager+SilentPush.h +5 -22
- package/ios/include/SMManager+StyleOptions.h +5 -8
- package/ios/include/SMManager+UserNotification.h +44 -32
- package/ios/include/SMManager+ViewController.h +45 -0
- package/ios/include/SMManager.h +14 -23
- package/ios/include/SMManagerInAppMessageDelegate.h +24 -0
- package/ios/include/SMManagerSetting+Location.h +27 -0
- package/ios/include/SMManagerSetting.h +63 -34
- package/ios/include/SMManagerSettingIAC.h +6 -17
- package/ios/include/SMManagerSettingIAM.h +7 -16
- package/ios/include/SMManagerUniversalLinksDelegate.h +23 -0
- package/ios/include/SMMessage.h +1 -3
- package/ios/include/SMNSNotification.h +19 -5
- package/ios/include/SMNotificationAnnotationData.h +4 -8
- package/ios/include/SMNotificationButtonData.h +1 -6
- package/ios/include/SMNotificationButtonType.h +1 -2
- package/ios/include/SMNotificationMessage.h +31 -0
- package/ios/include/SMRemoteMessageDisplayType.h +32 -0
- package/ios/include/SMSuccess.h +1 -4
- package/ios/{libSelligentMobile2.5.a → libSelligentMobile2.7.a} +0 -0
- package/package.json +3 -3
- package/ios/include/SMLocationAuthorisationType.h +0 -57
package/index.d.ts
ADDED
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
export function getVersionLib(successCallback: Function): void;
|
|
2
|
+
export function getInAppMessages(successCallback: Function): void;
|
|
3
|
+
export function setInAppMessageAsSeen(
|
|
4
|
+
successCallback: Function,
|
|
5
|
+
errorCallback: Function,
|
|
6
|
+
messageId: string
|
|
7
|
+
): void;
|
|
8
|
+
export function executeButtonAction(
|
|
9
|
+
successCallback: Function,
|
|
10
|
+
errorCallback: Function,
|
|
11
|
+
buttonId: string,
|
|
12
|
+
messageId: string
|
|
13
|
+
): void;
|
|
14
|
+
export function enableGeolocation(
|
|
15
|
+
successCallback: Function,
|
|
16
|
+
errorCallback: Function,
|
|
17
|
+
enabled: boolean
|
|
18
|
+
): void;
|
|
19
|
+
export function isGeolocationEnabled(successCallback: Function): void;
|
|
20
|
+
export function sendEvent(
|
|
21
|
+
successCallback: Function,
|
|
22
|
+
errorCallback: Function,
|
|
23
|
+
event: any
|
|
24
|
+
): void;
|
|
25
|
+
export function getDeviceId(successCallback: Function): void;
|
|
26
|
+
export function enableNotifications(
|
|
27
|
+
successCallback: Function,
|
|
28
|
+
errorCallback: Function,
|
|
29
|
+
enabled: boolean
|
|
30
|
+
): void;
|
|
31
|
+
export function registerForProvisionalRemoteNotification(
|
|
32
|
+
successCallback: Function
|
|
33
|
+
): void;
|
|
34
|
+
export function displayLastReceivedRemotePushNotification(
|
|
35
|
+
successCallback: Function
|
|
36
|
+
): void;
|
|
37
|
+
export function getLastRemotePushNotification(successCallback: Function): void;
|
|
38
|
+
|
|
39
|
+
// IOS
|
|
40
|
+
export function enableInAppMessages(
|
|
41
|
+
successCallback: Function,
|
|
42
|
+
errorCallback: Function,
|
|
43
|
+
enabled: boolean
|
|
44
|
+
): void;
|
|
45
|
+
export function enableiOSLogging(
|
|
46
|
+
successCallback: Function,
|
|
47
|
+
errorCallback: Function,
|
|
48
|
+
logLevels: any[]
|
|
49
|
+
): void;
|
|
50
|
+
export function displayNotification(
|
|
51
|
+
successCallback: Function,
|
|
52
|
+
errorCallback: Function,
|
|
53
|
+
notificationId: string
|
|
54
|
+
): void;
|
|
55
|
+
export function registerRemoteNotificationFetchCompletionHandler(
|
|
56
|
+
successCallback: Function,
|
|
57
|
+
eventCallback: Function
|
|
58
|
+
): void;
|
|
59
|
+
export function forceRemoteNotificationBackgroundFetchResult(
|
|
60
|
+
successCallback: Function,
|
|
61
|
+
errorCallback: Function,
|
|
62
|
+
iOSBackgroundFetchResult: any
|
|
63
|
+
): void;
|
|
64
|
+
export function subscribeToEvents(
|
|
65
|
+
successCallback: Function,
|
|
66
|
+
errorCallback: Function,
|
|
67
|
+
eventCallback: Function
|
|
68
|
+
): void;
|
|
69
|
+
|
|
70
|
+
// ANDROID
|
|
71
|
+
export function enableInAppMessages(
|
|
72
|
+
successCallback: Function,
|
|
73
|
+
errorCallback: Function,
|
|
74
|
+
enabled: boolean | number
|
|
75
|
+
): void;
|
|
76
|
+
export function areInAppMessagesEnabled(successCallback: Function): any;
|
|
77
|
+
export function displayMessage(
|
|
78
|
+
successCallback: Function,
|
|
79
|
+
errorCallback: Function,
|
|
80
|
+
messageId: string
|
|
81
|
+
): void;
|
|
82
|
+
export function enableAndroidLogging(
|
|
83
|
+
successCallback: Function,
|
|
84
|
+
errorCallback: Function,
|
|
85
|
+
enabled: any
|
|
86
|
+
): void;
|
|
87
|
+
export function areNotificationsEnabled(successCallback: Function): void;
|
|
88
|
+
export function setNotificationSmallIcon(
|
|
89
|
+
successCallback: Function,
|
|
90
|
+
errorCallback: Function,
|
|
91
|
+
iconName: string
|
|
92
|
+
): void;
|
|
93
|
+
export function setNotificationLargeIcon(
|
|
94
|
+
successCallback: Function,
|
|
95
|
+
errorCallback: Function,
|
|
96
|
+
iconName: string
|
|
97
|
+
): void;
|
|
98
|
+
export function setNotificationIconColor(
|
|
99
|
+
successCallback: Function,
|
|
100
|
+
errorCallback: Function,
|
|
101
|
+
color: string
|
|
102
|
+
): void;
|
|
103
|
+
export function setNotificationActivity(
|
|
104
|
+
successCallback: Function,
|
|
105
|
+
errorCallback: Function,
|
|
106
|
+
activityName: string
|
|
107
|
+
): void;
|
|
108
|
+
export function getGCMToken(successCallback: Function): void;
|
|
109
|
+
export function getRemoteMessagesDisplayType(successCallback: Function): void;
|
|
110
|
+
export function subscribeToEvents(
|
|
111
|
+
successCallback: Function,
|
|
112
|
+
errorCallback: Function,
|
|
113
|
+
eventCallback: Function,
|
|
114
|
+
customEvents?: any[]
|
|
115
|
+
): void;
|
|
116
|
+
export function subscribeToEvent(
|
|
117
|
+
eventCallback: Function,
|
|
118
|
+
eventName: string
|
|
119
|
+
): void;
|
|
120
|
+
export function setFirebaseToken(
|
|
121
|
+
successCallback: Function,
|
|
122
|
+
errorCallback: Function,
|
|
123
|
+
token: string
|
|
124
|
+
): void;
|
package/index.ios.js
CHANGED
|
@@ -10,6 +10,14 @@ export default {
|
|
|
10
10
|
// Basic SMManager
|
|
11
11
|
|
|
12
12
|
// InAppMessage
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Enable/disable in-app messages on iOS.
|
|
16
|
+
*
|
|
17
|
+
* @param {function} successCallback Callback function on success.
|
|
18
|
+
* @param {function} errorCallback Callback function on error.
|
|
19
|
+
* @param {boolean} enabled Boolean to enable/disable in-app messages.
|
|
20
|
+
*/
|
|
13
21
|
enableInAppMessages: function (successCallback, errorCallback, enabled) {
|
|
14
22
|
if (!SelligentHelpers.typeMatches(enabled, 'boolean')) {
|
|
15
23
|
errorCallback(SelligentHelpers.wrongArgumentError('Expected a boolean.'))
|
|
@@ -21,6 +29,14 @@ export default {
|
|
|
21
29
|
return
|
|
22
30
|
},
|
|
23
31
|
// Log
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Enable logging messages on iOS.
|
|
35
|
+
*
|
|
36
|
+
* @param {function} successCallback Callback function on success.
|
|
37
|
+
* @param {function} errorCallback Callback function on error.
|
|
38
|
+
* @param {array} logLevels Array of logging levels that should be enabled.
|
|
39
|
+
*/
|
|
24
40
|
enableiOSLogging: function (successCallback, errorCallback, logLevels) {
|
|
25
41
|
if (!SelligentHelpers.typeMatches(logLevels, 'array')) {
|
|
26
42
|
errorCallback(SelligentHelpers.wrongArgumentError('Expected an array of numbers.'))
|
|
@@ -46,22 +62,15 @@ export default {
|
|
|
46
62
|
RNSelligent.applyLogLevel(logLevels)
|
|
47
63
|
return
|
|
48
64
|
},
|
|
49
|
-
// Location
|
|
50
|
-
currentAuthorisationStatus: function (successCallback) {
|
|
51
|
-
RNSelligent.currentAuthorisationStatus(successCallback)
|
|
52
|
-
return
|
|
53
|
-
},
|
|
54
|
-
requestLocationAuthorisation: function (successCallback, errorCallback, iOSLocationAuthorisationType) {
|
|
55
|
-
if (!SelligentHelpers.constantIsValid(SelligentConstants.iOSLocationAuthorisationType, iOSLocationAuthorisationType)) {
|
|
56
|
-
errorCallback(SelligentHelpers.createTypeErrorMessage('iOSLocationAuthorisationType', iOSLocationAuthorisationType, 'number'))
|
|
57
|
-
return
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
successCallback(SelligentHelpers.SUCCESS)
|
|
61
|
-
RNSelligent.requestLocationAuthorisation(iOSLocationAuthorisationType)
|
|
62
|
-
return
|
|
63
|
-
},
|
|
64
65
|
// Remote Notification
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Display notification by id on iOS.
|
|
69
|
+
*
|
|
70
|
+
* @param {function} successCallback Callback function on success.
|
|
71
|
+
* @param {function} errorCallback Callback function on error.
|
|
72
|
+
* @param {string} notificationId Id of the notification.
|
|
73
|
+
*/
|
|
65
74
|
displayNotification: function (successCallback, errorCallback, notificationId) {
|
|
66
75
|
if (!SelligentHelpers.typeMatches(notificationId, 'string') || notificationId.length === 0) {
|
|
67
76
|
errorCallback(SelligentHelpers.wrongArgumentError('Expected a string (not empty).'))
|
|
@@ -72,11 +81,26 @@ export default {
|
|
|
72
81
|
RNSelligent.displayNotification(notificationId)
|
|
73
82
|
return
|
|
74
83
|
},
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Register a completion handler for successfully fetching remote notifications.
|
|
87
|
+
*
|
|
88
|
+
* @param {function} successCallback Completion handler.
|
|
89
|
+
* @param {function} eventCallback Callback function on event.
|
|
90
|
+
*/
|
|
75
91
|
registerRemoteNotificationFetchCompletionHandler: function (successCallback, eventCallback) {
|
|
76
92
|
RNSEventEmitter.addListener(SelligentConstants.RemoteNotification.FETCHED_REMOTE_NOTIFICATION, eventCallback);
|
|
77
93
|
successCallback(SelligentHelpers.SUCCESS)
|
|
78
94
|
return
|
|
79
95
|
},
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Force the result of a remote notification fetch to be a specific value.
|
|
99
|
+
*
|
|
100
|
+
* @param {function} successCallback Callback function on success.
|
|
101
|
+
* @param {function} errorCallback Callback function on error.
|
|
102
|
+
* @param {iOSBackgroundFetchResult} iOSBackgroundFetchResult Type of result to force, when fetching remote notifications.
|
|
103
|
+
*/
|
|
80
104
|
forceRemoteNotificationBackgroundFetchResult: function (successCallback, errorCallback, iOSBackgroundFetchResult) {
|
|
81
105
|
if (!SelligentHelpers.typeMatches(iOSBackgroundFetchResult, 'number') || !SelligentHelpers.constantIsValid(SelligentConstants.iOSBackgroundFetchResult, iOSBackgroundFetchResult)) {
|
|
82
106
|
errorCallback(SelligentHelpers.wrongArgumentError('Expected a value of Selligent constant enum "iOSBackgroundFetchResult".'))
|
|
@@ -87,7 +111,27 @@ export default {
|
|
|
87
111
|
RNSelligent.forceRemoteNotificationBackgroundFetchResult(iOSBackgroundFetchResult)
|
|
88
112
|
return
|
|
89
113
|
},
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* Register for Provisional Push Notifications.
|
|
117
|
+
*
|
|
118
|
+
* @param {function} successCallback Callback function on success.
|
|
119
|
+
*/
|
|
120
|
+
registerForProvisionalRemoteNotification: function (successCallback) {
|
|
121
|
+
successCallback(SelligentHelpers.SUCCESS)
|
|
122
|
+
RNSelligent.registerForProvisionalRemoteNotification()
|
|
123
|
+
return
|
|
124
|
+
},
|
|
125
|
+
|
|
90
126
|
// Broadcasts Events
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* Subscribe to events.
|
|
130
|
+
*
|
|
131
|
+
* @param {function} successCallback Callback function on success.
|
|
132
|
+
* @param {function} errorCallback Callback function on error.
|
|
133
|
+
* @param {function} eventCallback Callback function on event.
|
|
134
|
+
*/
|
|
91
135
|
subscribeToEvents: function (successCallback, errorCallback, eventCallback) {
|
|
92
136
|
RNSEventEmitter.addListener(SelligentConstants.BroadcastEventType.RECEIVED_IN_APP_MESSAGE, eventCallback);
|
|
93
137
|
RNSEventEmitter.addListener(SelligentConstants.BroadcastEventType.WILL_DISPLAY_NOTIFICATION, eventCallback);
|
package/index.js
CHANGED
|
@@ -25,6 +25,12 @@ export default Object.assign(
|
|
|
25
25
|
// Check if the Selligent Module is loaded
|
|
26
26
|
_selligentLoaded: Boolean(RNSelligent),
|
|
27
27
|
// Basic SMManager
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Returns the version of the underlying Selligent SDK.
|
|
31
|
+
*
|
|
32
|
+
* @param {function} successCallback Callback function on success.
|
|
33
|
+
*/
|
|
28
34
|
getVersionLib: function (successCallback) {
|
|
29
35
|
RNSelligent.getVersionLib(successCallback)
|
|
30
36
|
return
|
|
@@ -32,17 +38,31 @@ export default Object.assign(
|
|
|
32
38
|
// DataTransaction
|
|
33
39
|
|
|
34
40
|
// InAppMessage
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Get in app messages.
|
|
44
|
+
*
|
|
45
|
+
* @param {function} successCallback Callback function on success.
|
|
46
|
+
*/
|
|
35
47
|
getInAppMessages: function (successCallback) {
|
|
36
48
|
RNSelligent.getInAppMessages(successCallback)
|
|
37
49
|
return
|
|
38
50
|
},
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Set in app message as seen
|
|
54
|
+
*
|
|
55
|
+
* @param {function} successCallback Callback function on success.
|
|
56
|
+
* @param {function} errorCallback Callback function on error.
|
|
57
|
+
* @param {string} messageId Message id to identify the message which has been seen.
|
|
58
|
+
*/
|
|
39
59
|
setInAppMessageAsSeen: function (successCallback, errorCallback, messageId) {
|
|
40
60
|
// check if required options are valid
|
|
41
61
|
if (!SelligentHelpers.typeMatches(messageId, 'string')) {
|
|
42
62
|
errorCallback(SelligentHelpers.wrongArgumentError('Expected a string.'))
|
|
43
63
|
return
|
|
44
64
|
}
|
|
45
|
-
|
|
65
|
+
|
|
46
66
|
// continue if options are valid
|
|
47
67
|
const _successCallback = () => {
|
|
48
68
|
successCallback(SelligentHelpers.SUCCESS)
|
|
@@ -51,6 +71,15 @@ export default Object.assign(
|
|
|
51
71
|
RNSelligent.setInAppMessageAsSeen(messageId, _successCallback, errorCallback)
|
|
52
72
|
return
|
|
53
73
|
},
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Execute action on button
|
|
77
|
+
*
|
|
78
|
+
* @param {function} successCallback Callback function on success.
|
|
79
|
+
* @param {function} errorCallback Callback function on error.
|
|
80
|
+
* @param {string} buttonId Button id to identify the message.
|
|
81
|
+
* @param {string} messageId Message id to identify the message.
|
|
82
|
+
*/
|
|
54
83
|
executeButtonAction: function (successCallback, errorCallback, buttonId, messageId) {
|
|
55
84
|
if (!SelligentHelpers.typeMatches(buttonId, 'string')) {
|
|
56
85
|
errorCallback(SelligentHelpers.wrongArgumentError('Expected buttonId to be a string.'))
|
|
@@ -64,12 +93,20 @@ export default Object.assign(
|
|
|
64
93
|
const _successCallback = () => {
|
|
65
94
|
successCallback(SelligentHelpers.SUCCESS)
|
|
66
95
|
}
|
|
67
|
-
|
|
96
|
+
|
|
68
97
|
RNSelligent.executeButtonAction(buttonId, messageId, _successCallback, errorCallback)
|
|
69
98
|
return
|
|
70
99
|
},
|
|
71
100
|
|
|
72
101
|
// Location
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* Enable/disable geolocation.
|
|
105
|
+
*
|
|
106
|
+
* @param {function} successCallback Callback function on success.
|
|
107
|
+
* @param {function} errorCallback Callback function on error.
|
|
108
|
+
* @param {boolean} enabled Boolean to enable or disable geolocation.
|
|
109
|
+
*/
|
|
73
110
|
enableGeolocation: function (successCallback, errorCallback, enabled) {
|
|
74
111
|
// check if required options are valid
|
|
75
112
|
if (!SelligentHelpers.typeMatches(enabled, 'boolean')) {
|
|
@@ -82,11 +119,25 @@ export default Object.assign(
|
|
|
82
119
|
RNSelligent.enableGeolocation(enabled)
|
|
83
120
|
return
|
|
84
121
|
},
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* Check if geolocation is enabled or disabled.
|
|
125
|
+
*
|
|
126
|
+
* @param {function} successCallback Callback function on success.
|
|
127
|
+
*/
|
|
85
128
|
isGeolocationEnabled: function (successCallback) {
|
|
86
129
|
RNSelligent.isGeolocationEnabled(successCallback)
|
|
87
130
|
return
|
|
88
131
|
},
|
|
89
132
|
// Event
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* Send event.
|
|
136
|
+
*
|
|
137
|
+
* @param {function} successCallback Callback function on success.
|
|
138
|
+
* @param {function} errorCallback Callback function on error.
|
|
139
|
+
* @param {object} event Event to send.
|
|
140
|
+
*/
|
|
90
141
|
sendEvent: function (successCallback, errorCallback, event) {
|
|
91
142
|
// check if required options are valid
|
|
92
143
|
if (!SelligentHelpers.hasRequiredParameterAndMatchesType(event, 'type', 'number')) {
|
|
@@ -123,7 +174,26 @@ export default Object.assign(
|
|
|
123
174
|
RNSelligent.sendEvent(event, successCallback, errorCallback)
|
|
124
175
|
return
|
|
125
176
|
},
|
|
177
|
+
// Device Id
|
|
178
|
+
/**
|
|
179
|
+
* Returns the device id.
|
|
180
|
+
*
|
|
181
|
+
* @param {function} successCallback Callback function on success.
|
|
182
|
+
*/
|
|
183
|
+
getDeviceId: function (successCallback) {
|
|
184
|
+
RNSelligent.getDeviceId(successCallback)
|
|
185
|
+
return
|
|
186
|
+
},
|
|
187
|
+
|
|
126
188
|
// Remote Notifications
|
|
189
|
+
|
|
190
|
+
/**
|
|
191
|
+
* Enable/disable notification.
|
|
192
|
+
*
|
|
193
|
+
* @param {function} successCallback Callback function on success.
|
|
194
|
+
* @param {function} errorCallback Callback function on error.
|
|
195
|
+
* @param {boolean} enabled Boolean to enable or disable notifications.
|
|
196
|
+
*/
|
|
127
197
|
enableNotifications: function (successCallback, errorCallback, enabled) {
|
|
128
198
|
// check if required options are valid
|
|
129
199
|
if (!SelligentHelpers.typeMatches(enabled, 'boolean')) {
|
|
@@ -136,11 +206,23 @@ export default Object.assign(
|
|
|
136
206
|
RNSelligent.enableNotifications(enabled)
|
|
137
207
|
return
|
|
138
208
|
},
|
|
209
|
+
|
|
210
|
+
/**
|
|
211
|
+
* Display the last received remote push notification
|
|
212
|
+
*
|
|
213
|
+
* @param {function} successCallback Callback function on success.
|
|
214
|
+
*/
|
|
139
215
|
displayLastReceivedRemotePushNotification: function (successCallback) {
|
|
140
216
|
successCallback(SelligentHelpers.SUCCESS)
|
|
141
217
|
RNSelligent.displayLastReceivedRemotePushNotification()
|
|
142
218
|
return
|
|
143
219
|
},
|
|
220
|
+
|
|
221
|
+
/**
|
|
222
|
+
* Get last remote push notification
|
|
223
|
+
*
|
|
224
|
+
* @param {function} successCallback Callback function on success.
|
|
225
|
+
*/
|
|
144
226
|
getLastRemotePushNotification: function (successCallback) {
|
|
145
227
|
RNSelligent.getLastRemotePushNotification(successCallback)
|
|
146
228
|
return
|
package/ios/ClientSettings.h
CHANGED
|
@@ -8,10 +8,12 @@
|
|
|
8
8
|
@property (nonatomic, strong, readonly) NSString *clientId;
|
|
9
9
|
@property (nonatomic, strong, readonly) NSString *privateKey;
|
|
10
10
|
@property (nonatomic, strong, readonly) NSString *appGroupId;
|
|
11
|
+
@property (nonatomic, strong, readonly) NSNumber *shouldAddInAppMessageFromPushToInAppMessageList;
|
|
11
12
|
@property (nonatomic, strong, readonly) NSNumber *shouldClearBadge;
|
|
12
13
|
@property (nonatomic, strong, readonly) NSNumber *shouldDisplayRemoteNotification;
|
|
13
14
|
@property (nonatomic, strong, readonly) NSNumber *configureLocationServices;
|
|
14
15
|
@property (nonatomic, strong, readonly) NSNumber *clearCacheIntervalValue;
|
|
16
|
+
@property (nonatomic, strong, readonly) NSNumber *remoteMessageDisplayType;
|
|
15
17
|
@property (nonatomic, strong, readonly) InAppMessageSettings *inAppMessageSettings;
|
|
16
18
|
|
|
17
19
|
@end
|
package/ios/ClientSettings.m
CHANGED
|
@@ -8,10 +8,12 @@
|
|
|
8
8
|
@property (nonatomic, strong) NSString *clientId;
|
|
9
9
|
@property (nonatomic, strong) NSString *privateKey;
|
|
10
10
|
@property (nonatomic, strong) NSString *appGroupId;
|
|
11
|
+
@property (nonatomic, strong) NSNumber *shouldAddInAppMessageFromPushToInAppMessageList;
|
|
11
12
|
@property (nonatomic, strong) NSNumber *shouldClearBadge;
|
|
12
13
|
@property (nonatomic, strong) NSNumber *shouldDisplayRemoteNotification;
|
|
13
14
|
@property (nonatomic, strong) NSNumber *configureLocationServices;
|
|
14
15
|
@property (nonatomic, strong) NSNumber *clearCacheIntervalValue;
|
|
16
|
+
@property (nonatomic, strong) NSNumber *remoteMessageDisplayType;
|
|
15
17
|
@property (nonatomic, strong) InAppMessageSettings *inAppMessageSettings;
|
|
16
18
|
|
|
17
19
|
@end
|
|
@@ -24,10 +26,12 @@
|
|
|
24
26
|
clientSettings.clientId = dictionary[@"clientId"];
|
|
25
27
|
clientSettings.privateKey = dictionary[@"privateKey"];
|
|
26
28
|
clientSettings.appGroupId = dictionary[@"appGroupId"];
|
|
29
|
+
clientSettings.shouldAddInAppMessageFromPushToInAppMessageList = dictionary[@"addInAppMessageFromPushToInAppMessageList"];
|
|
27
30
|
clientSettings.shouldClearBadge = dictionary[@"shouldClearBadge"];
|
|
28
31
|
clientSettings.shouldDisplayRemoteNotification = dictionary[@"shouldDisplayRemoteNotification"];
|
|
29
32
|
clientSettings.configureLocationServices = dictionary[@"configureLocationServices"];
|
|
30
33
|
clientSettings.clearCacheIntervalValue = dictionary[@"clearCacheIntervalValue"];
|
|
34
|
+
clientSettings.remoteMessageDisplayType = dictionary[@"remoteMessageDisplayType"];
|
|
31
35
|
clientSettings.inAppMessageSettings = [InAppMessageSettings fromDictionary:dictionary];
|
|
32
36
|
return clientSettings;
|
|
33
37
|
}
|
package/ios/EnumMapper.h
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
#import <UIKit/UIKit.h>
|
|
2
2
|
#import "LogLevel.h"
|
|
3
3
|
#import "InAppMessageRefreshType.h"
|
|
4
|
+
#import "RemoteMessageDisplayType.h"
|
|
4
5
|
#import "LocationAuthorisationStatus.h"
|
|
5
6
|
#import "LocationAuthorisationType.h"
|
|
6
7
|
#import "ClearCacheInterval.h"
|
|
7
|
-
#import "SMLocationAuthorisationType.h"
|
|
8
8
|
#import "SMLog.h"
|
|
9
9
|
#import "SMClearCache.h"
|
|
10
10
|
#import "SMInAppRefreshType.h"
|
|
11
|
+
#import "SMRemoteMessageDisplayType.h"
|
|
11
12
|
#import "BackgroundFetchResult.h"
|
|
12
13
|
#import "SMNotificationButtonType.h"
|
|
13
14
|
#import "NotificationButtonType.h"
|
|
@@ -24,11 +25,7 @@
|
|
|
24
25
|
- (SMInAppRefreshType)smInAppRefreshTypeForInAppMessageRefreshType:(InAppMessageRefreshType)inAppMessageRefreshType;
|
|
25
26
|
- (InAppMessageRefreshType)inAppMessageRefreshTypeForSMInAppRefreshType:(SMInAppRefreshType)smInAppRefreshType;
|
|
26
27
|
|
|
27
|
-
- (
|
|
28
|
-
- (LocationAuthorisationStatus)locationAuthorisationStatusForSMLocationAuthorisationStatus:(SMLocationAuthorisationStatus)smLocationAuthorisationType;
|
|
29
|
-
|
|
30
|
-
- (SMLocationAuthorisationType)smLocationAuthorisationTypeForLocationAuthorisationType:(LocationAuthorisationType)locationAuthorisationType;
|
|
31
|
-
- (LocationAuthorisationType)locationAuthorisationTypeForSMLocationAuthorisationType:(SMLocationAuthorisationType)smLocationAuthorisationType;
|
|
28
|
+
- (SMRemoteMessageDisplayType)smRemoteMessageDisplayTypeForRemoteMessageDisplayType: (RemoteMessageDisplayType)remoteMessageDisplayType;
|
|
32
29
|
|
|
33
30
|
- (UIBackgroundFetchResult)uiBackgroundFetchResultForBackgroundFetchResult:(BackgroundFetchResult)backgroundFetchResult;
|
|
34
31
|
- (BackgroundFetchResult)backgroundFetchResultForUIBackgroundFetchResult:(UIBackgroundFetchResult)uiBackgroundFetchResult;
|
package/ios/EnumMapper.m
CHANGED
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
NSDictionary *_logLevelEnumMapping;
|
|
5
5
|
NSDictionary *_clearCacheIntervalEnumMapping;
|
|
6
6
|
NSDictionary *_inAppRefreshTypeEnumMapping;
|
|
7
|
+
NSDictionary *_remoteMessageDisplayTypeEnumMapping;
|
|
7
8
|
NSDictionary *_locationAuthorisationStatusMapping;
|
|
8
9
|
NSDictionary *_locationAuthorisationTypeMapping;
|
|
9
10
|
NSDictionary *_backgroundFetchResult;
|
|
@@ -43,16 +44,11 @@
|
|
|
43
44
|
@(iamrtHour) : @(kSMIA_RefreshType_Hourly),
|
|
44
45
|
@(iamryDay ) : @(kSMIA_RefreshType_Daily),
|
|
45
46
|
};
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
};
|
|
52
|
-
_locationAuthorisationTypeMapping = @{
|
|
53
|
-
@(ilatInUse) : @(kSMLocationAuthorisationType_InUse),
|
|
54
|
-
@(ilatAlways) : @(kSMLocationAuthorisationType_Always),
|
|
55
|
-
};
|
|
47
|
+
_remoteMessageDisplayTypeEnumMapping = @{
|
|
48
|
+
@(rmdtAutomatic) : @(kSMRemoteMessageDisplayType_Automatic),
|
|
49
|
+
@(rmdtNone) : @(kSMRemoteMessageDisplayType_None),
|
|
50
|
+
@(rmdtNotification) : @(kSMRemoteMessageDisplayType_Notification),
|
|
51
|
+
};
|
|
56
52
|
_backgroundFetchResult = @{
|
|
57
53
|
@(bfrNewData) : @(UIBackgroundFetchResultNewData),
|
|
58
54
|
@(bfrNoData) : @(UIBackgroundFetchResultNoData),
|
|
@@ -101,20 +97,8 @@
|
|
|
101
97
|
return (InAppMessageRefreshType) ((NSNumber *)[_inAppRefreshTypeEnumMapping allKeysForObject:@(smInAppRefreshType)].firstObject).integerValue;
|
|
102
98
|
}
|
|
103
99
|
|
|
104
|
-
-
|
|
105
|
-
return (
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
- (LocationAuthorisationStatus)locationAuthorisationStatusForSMLocationAuthorisationStatus:(SMLocationAuthorisationStatus)smLocationAuthorisationType {
|
|
109
|
-
return (LocationAuthorisationStatus) ((NSNumber *)[_locationAuthorisationStatusMapping allKeysForObject:@(smLocationAuthorisationType)].firstObject).integerValue;
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
- (SMLocationAuthorisationType)smLocationAuthorisationTypeForLocationAuthorisationType:(LocationAuthorisationType)locationAuthorisationType {
|
|
113
|
-
return (SMLocationAuthorisationType) ((NSNumber *)_locationAuthorisationTypeMapping[@(locationAuthorisationType)]).integerValue;
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
- (LocationAuthorisationType)locationAuthorisationTypeForSMLocationAuthorisationType:(SMLocationAuthorisationType)smLocationAuthorisationType {
|
|
117
|
-
return (LocationAuthorisationType) ((NSNumber *)[_locationAuthorisationTypeMapping allKeysForObject:@(smLocationAuthorisationType)].firstObject).integerValue;
|
|
100
|
+
-(SMRemoteMessageDisplayType)smRemoteMessageDisplayTypeForRemoteMessageDisplayType:(RemoteMessageDisplayType)remoteMessageDisplayType {
|
|
101
|
+
return (SMRemoteMessageDisplayType) ((NSNumber *)_remoteMessageDisplayTypeEnumMapping[@(remoteMessageDisplayType)]).integerValue;
|
|
118
102
|
}
|
|
119
103
|
|
|
120
104
|
- (UIBackgroundFetchResult)uiBackgroundFetchResultForBackgroundFetchResult:(BackgroundFetchResult)backgroundFetchResult {
|
package/ios/RNSelligent.m
CHANGED
|
@@ -25,6 +25,7 @@ static NSString * const BROADCAST_BUTTON_CLICKED = @"ButtonClicked";
|
|
|
25
25
|
static NSString * const BROADCAST_RECEIVED_IN_APP_MSG = @"ReceivedInAppMessage";
|
|
26
26
|
static NSString * const BROADCAST_WILL_DISPLAY_NOTIFICATION = @"WillDisplayNotification";
|
|
27
27
|
static NSString * const BROADCAST_WILL_DISMISS_NOTIFICATION = @"WillDismissNotification";
|
|
28
|
+
static NSString * const BROADCAST_RECEIVED_DEVICE_ID = @"ReceivedDeviceId";
|
|
28
29
|
static NSString * const BROADCAST_RECEIVED_REMOTENOTIFICATION = @"ReceivedRemoteNotification";
|
|
29
30
|
static NSString * const FETCHED_REMOTE_NOTIFICATION = @"FetchedRemoteNotification";
|
|
30
31
|
|
|
@@ -107,7 +108,7 @@ RCT_EXPORT_MODULE(RNSelligent)
|
|
|
107
108
|
[[SMManager sharedInstance] willPresentNotification:notification withCompletionHandler:completionHandler];
|
|
108
109
|
}
|
|
109
110
|
|
|
110
|
-
+ (void)didReceiveNotificationResponse:(UNNotificationResponse *)response withCompletionHandler:(void(^)(
|
|
111
|
+
+ (void)didReceiveNotificationResponse:(UNNotificationResponse *)response withCompletionHandler:(void(^)(UNNotificationContentExtensionResponseOption options))completionHandler {
|
|
111
112
|
[[SMManager sharedInstance] didReceiveNotificationResponse:response withCompletionHandler:completionHandler];
|
|
112
113
|
}
|
|
113
114
|
|
|
@@ -141,7 +142,8 @@ RCT_EXPORT_METHOD(getInAppMessages:(RCTResponseSenderBlock)callback) {
|
|
|
141
142
|
@"creationDate" : @([[inAppMessage creationDate] timeIntervalSince1970]),
|
|
142
143
|
@"expirationDate" : [inAppMessage expirationDate] ? @([[inAppMessage expirationDate] timeIntervalSince1970]) : [NSNull null],
|
|
143
144
|
@"hasBeenSeen" : @([inAppMessage isViewed]),
|
|
144
|
-
@"buttons" : mappedLinks
|
|
145
|
+
@"buttons" : mappedLinks,
|
|
146
|
+
@"type" : @([inAppMessage iamType])
|
|
145
147
|
}];
|
|
146
148
|
}
|
|
147
149
|
callback(@[mappedMessages ?: [NSNull null], [NSNull null]]);
|
|
@@ -187,17 +189,6 @@ RCT_EXPORT_METHOD(applyLogLevel:(NSArray<NSNumber *> *)logLevels) {
|
|
|
187
189
|
[[SMManager sharedInstance] applyLogLevel:(SMLogLevel) requestedBitShiftedLogLevel];
|
|
188
190
|
}
|
|
189
191
|
|
|
190
|
-
RCT_EXPORT_METHOD(currentAuthorisationStatus:(RCTResponseSenderBlock)callback) {
|
|
191
|
-
SMLocationAuthorisationStatus smLocationAuthStatus = [[SMManager sharedInstance] currentAuthorisationStatus];
|
|
192
|
-
LocationAuthorisationStatus status = [[EnumMapper sharedEnumMapper] locationAuthorisationStatusForSMLocationAuthorisationStatus:smLocationAuthStatus];
|
|
193
|
-
callback(@[@(status), [NSNull null]]);
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
RCT_EXPORT_METHOD(requestLocationAuthorisation:(NSInteger)authorisationType) {
|
|
197
|
-
SMLocationAuthorisationType smAuthType = [[EnumMapper sharedEnumMapper] smLocationAuthorisationTypeForLocationAuthorisationType:authorisationType];
|
|
198
|
-
[[SMManager sharedInstance] requestLocationAuthorisation:smAuthType];
|
|
199
|
-
}
|
|
200
|
-
|
|
201
192
|
RCT_EXPORT_METHOD(isGeolocationEnabled:(RCTResponseSenderBlock)callback) {
|
|
202
193
|
BOOL enabled = [[SMManager sharedInstance] isGeoLocationEnabled];
|
|
203
194
|
callback(@[@(enabled), [NSNull null]]);
|
|
@@ -225,6 +216,11 @@ RCT_EXPORT_METHOD(forceRemoteNotificationBackgroundFetchResult:(nonnull NSNumber
|
|
|
225
216
|
self.requestedForcedRemoteNotificationBackgroundFetchResult = @([[EnumMapper sharedEnumMapper] uiBackgroundFetchResultForBackgroundFetchResult:remoteNotificationBackgroundFetchResult.integerValue]);
|
|
226
217
|
}
|
|
227
218
|
|
|
219
|
+
RCT_EXPORT_METHOD(getDeviceId:(RCTResponseSenderBlock)callback) {
|
|
220
|
+
NSString *deviceId = [[SMManager sharedInstance] deviceID];
|
|
221
|
+
callback(@[deviceId, [NSNull null]]);
|
|
222
|
+
}
|
|
223
|
+
|
|
228
224
|
RCT_EXPORT_METHOD(enableNotifications:(BOOL)enable) {
|
|
229
225
|
if (enable) {
|
|
230
226
|
[[SMManager sharedInstance] registerForRemoteNotification];
|
|
@@ -233,6 +229,12 @@ RCT_EXPORT_METHOD(enableNotifications:(BOOL)enable) {
|
|
|
233
229
|
}
|
|
234
230
|
}
|
|
235
231
|
|
|
232
|
+
RCT_EXPORT_METHOD(registerForProvisionalRemoteNotification) {
|
|
233
|
+
if (@available(iOS 12.0, *)) {
|
|
234
|
+
[[SMManager sharedInstance] registerForProvisionalRemoteNotification];
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
|
|
236
238
|
RCT_EXPORT_METHOD(displayLastReceivedRemotePushNotification) {
|
|
237
239
|
[[SMManager sharedInstance] displayLastReceivedRemotePushNotification];
|
|
238
240
|
}
|
|
@@ -258,6 +260,7 @@ RCT_EXPORT_METHOD(subscribeToEvents) {
|
|
|
258
260
|
[self _addOrReplaceObserverForSelector:@selector(_handleButtonClicked:) forName:kSMNotification_Event_ButtonClicked];
|
|
259
261
|
[self _addOrReplaceObserverForSelector:@selector(_handleWillDisplayNotification:) forName:kSMNotification_Event_WillDisplayNotification];
|
|
260
262
|
[self _addOrReplaceObserverForSelector:@selector(_handleWillDismissNotification:) forName:kSMNotification_Event_WillDismissNotification];
|
|
263
|
+
[self _addOrReplaceObserverForSelector:@selector(_handleReceivedDeviceId:) forName:kSMNotification_Data_DeviceId];
|
|
261
264
|
[self _addOrReplaceObserverForSelector:@selector(_handleDidReceiveRemoteNotification:) forName:kSMNotification_Event_DidReceiveRemoteNotification];
|
|
262
265
|
}
|
|
263
266
|
|
|
@@ -307,6 +310,15 @@ RCT_EXPORT_METHOD(subscribeToEvents) {
|
|
|
307
310
|
[self _sendBroadcastEventResultWithData:nil andType:BROADCAST_WILL_DISMISS_NOTIFICATION];
|
|
308
311
|
}
|
|
309
312
|
|
|
313
|
+
- (void)_handleReceivedDeviceId:(NSNotification*)notification {
|
|
314
|
+
NSDictionary *dict = [notification userInfo];
|
|
315
|
+
NSString *deviceId = [dict objectForKey:kSMNotification_Data_DeviceId];
|
|
316
|
+
NSDictionary *data = @{
|
|
317
|
+
@"deviceId": deviceId
|
|
318
|
+
};
|
|
319
|
+
[self _sendBroadcastEventResultWithData:data andType:BROADCAST_RECEIVED_DEVICE_ID];
|
|
320
|
+
}
|
|
321
|
+
|
|
310
322
|
- (void)_sendBroadcastEventResultWithData:(NSDictionary *)data andType:(NSString *)type {
|
|
311
323
|
[self sendEventWithName:type body:@{@"data": data ?: [NSNull null], @"broadcastEventType": type}];
|
|
312
324
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
#import "SMManagerSetting+ClientSettings.h"
|
|
2
|
+
#import "SMManagerSetting+Location.h"
|
|
2
3
|
#import "SMManagerSettingIAM.h"
|
|
3
4
|
#import "ClientSettings.h"
|
|
4
5
|
#import "EnumMapper.h"
|
|
@@ -18,7 +19,16 @@
|
|
|
18
19
|
+ (void)_configureManagerSettings:(SMManagerSetting *)settings withClientSettings:(ClientSettings *)clientSettings {
|
|
19
20
|
NSString *appGroupId = clientSettings.appGroupId;
|
|
20
21
|
if(appGroupId) {
|
|
21
|
-
|
|
22
|
+
if([appGroupId hasPrefix:@"group."]) {
|
|
23
|
+
settings.appGroupId = appGroupId;
|
|
24
|
+
} else {
|
|
25
|
+
settings.appGroupId = [NSString stringWithFormat:@"group.%@", appGroupId];
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
NSNumber *shouldAddInAppMessageFromPushToInAppMessageList = clientSettings.shouldAddInAppMessageFromPushToInAppMessageList;
|
|
30
|
+
if(shouldAddInAppMessageFromPushToInAppMessageList) {
|
|
31
|
+
settings.shouldAddInAppMessageFromPushToInAppMessageList = shouldAddInAppMessageFromPushToInAppMessageList.boolValue;
|
|
22
32
|
}
|
|
23
33
|
|
|
24
34
|
NSNumber *shouldClearBadgeAsNumber = clientSettings.shouldClearBadge;
|
|
@@ -26,19 +36,24 @@
|
|
|
26
36
|
settings.shouldClearBadge = shouldClearBadgeAsNumber.boolValue;
|
|
27
37
|
}
|
|
28
38
|
|
|
39
|
+
if(clientSettings.configureLocationServices.boolValue) {
|
|
40
|
+
[settings configureLocationService];
|
|
41
|
+
}
|
|
42
|
+
|
|
29
43
|
NSNumber *shouldDisplayRemoteNotificationAsNumber = clientSettings.shouldDisplayRemoteNotification;
|
|
30
44
|
if(shouldDisplayRemoteNotificationAsNumber) {
|
|
31
45
|
settings.shouldDisplayRemoteNotification = shouldDisplayRemoteNotificationAsNumber.boolValue;
|
|
32
46
|
}
|
|
33
47
|
|
|
34
|
-
if(clientSettings.configureLocationServices.boolValue) {
|
|
35
|
-
[settings configureLocationService];
|
|
36
|
-
}
|
|
37
|
-
|
|
38
48
|
NSNumber *clearCacheIntervalValueAsNumber = clientSettings.clearCacheIntervalValue;
|
|
39
49
|
if(clearCacheIntervalValueAsNumber) {
|
|
40
50
|
settings.clearCacheIntervalValue = [[EnumMapper sharedEnumMapper] smClearCacheForClearCacheInterval:clearCacheIntervalValueAsNumber.integerValue]; //((SMClearCache) );
|
|
41
51
|
}
|
|
52
|
+
|
|
53
|
+
NSNumber *remoteMessageDisplayType = clientSettings.remoteMessageDisplayType;
|
|
54
|
+
if(remoteMessageDisplayType) {
|
|
55
|
+
settings.remoteMessageDisplayType = [[EnumMapper sharedEnumMapper] smRemoteMessageDisplayTypeForRemoteMessageDisplayType:remoteMessageDisplayType.integerValue];
|
|
56
|
+
}
|
|
42
57
|
}
|
|
43
58
|
|
|
44
59
|
+ (SMManagerSettingIAM *)_iamManagerSettingsFor:(ClientSettings *)clientSettings {
|