@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.
Files changed (77) hide show
  1. package/README.md +287 -236
  2. package/RNSelligent.podspec +4 -4
  3. package/android/build.gradle +34 -26
  4. package/android/libs/sdk-release.aar +0 -0
  5. package/android/src/main/java/com/selligent/RNSelligent.java +54 -11
  6. package/android/src/main/java/com/selligent/SMSettingsFactory.java +1 -0
  7. package/android/src/main/java/com/selligent/Settings.java +16 -0
  8. package/constants.d.ts +103 -0
  9. package/constants.js +29 -1
  10. package/index.android.js +132 -0
  11. package/index.d.ts +124 -0
  12. package/index.ios.js +59 -15
  13. package/index.js +84 -2
  14. package/ios/ClientSettings.h +2 -0
  15. package/ios/ClientSettings.m +4 -0
  16. package/ios/EnumMapper.h +3 -6
  17. package/ios/EnumMapper.m +8 -24
  18. package/ios/RNSelligent.m +25 -13
  19. package/ios/RemoteMessageDisplayType.h +5 -0
  20. package/ios/SMManagerSetting+ClientSettings.m +20 -5
  21. package/ios/SelligentReactNative.xcodeproj/project.pbxproj +4 -4
  22. package/ios/include/SMBaseMessage.h +8 -8
  23. package/ios/include/SMBlock.h +2 -2
  24. package/ios/include/SMClearCache.h +0 -2
  25. package/ios/include/SMContentAlignment.h +1 -2
  26. package/ios/include/SMDeviceInfos.h +10 -8
  27. package/ios/include/SMDisplayMode.h +1 -2
  28. package/ios/include/SMEvent.h +20 -16
  29. package/ios/include/SMEventUser.h +0 -1
  30. package/ios/include/SMEventUserLogin.h +11 -16
  31. package/ios/include/SMEventUserLogout.h +12 -16
  32. package/ios/include/SMEventUserRegistration.h +12 -17
  33. package/ios/include/SMEventUserUnregistration.h +12 -16
  34. package/ios/include/SMFailure.h +1 -6
  35. package/ios/include/SMHelper.h +12 -4
  36. package/ios/include/SMInAppContentHTMLViewController.h +11 -9
  37. package/ios/include/SMInAppContentImageViewController.h +6 -5
  38. package/ios/include/SMInAppContentMessage.h +12 -12
  39. package/ios/include/SMInAppContentStyleOptions.h +91 -79
  40. package/ios/include/SMInAppContentType.h +2 -3
  41. package/ios/include/SMInAppContentURLViewController.h +10 -9
  42. package/ios/include/SMInAppContentViewController.h +3 -5
  43. package/ios/include/SMInAppMessage.h +22 -14
  44. package/ios/include/SMInAppMessageType.h +1 -5
  45. package/ios/include/SMInAppRefreshType.h +1 -1
  46. package/ios/include/SMLink.h +7 -11
  47. package/ios/include/SMLog.h +1 -1
  48. package/ios/include/SMManager+DataTransaction.h +6 -13
  49. package/ios/include/SMManager+InAppContent.h +20 -23
  50. package/ios/include/SMManager+InAppMessage.h +68 -31
  51. package/ios/include/SMManager+Location.h +7 -63
  52. package/ios/include/SMManager+Log.h +3 -14
  53. package/ios/include/SMManager+RemoteNotification.h +38 -34
  54. package/ios/include/SMManager+SMEvent.h +10 -10
  55. package/ios/include/SMManager+SMLink.h +44 -0
  56. package/ios/include/SMManager+SilentPush.h +5 -22
  57. package/ios/include/SMManager+StyleOptions.h +5 -8
  58. package/ios/include/SMManager+UserNotification.h +44 -32
  59. package/ios/include/SMManager+ViewController.h +45 -0
  60. package/ios/include/SMManager.h +14 -23
  61. package/ios/include/SMManagerInAppMessageDelegate.h +24 -0
  62. package/ios/include/SMManagerSetting+Location.h +27 -0
  63. package/ios/include/SMManagerSetting.h +63 -34
  64. package/ios/include/SMManagerSettingIAC.h +6 -17
  65. package/ios/include/SMManagerSettingIAM.h +7 -16
  66. package/ios/include/SMManagerUniversalLinksDelegate.h +23 -0
  67. package/ios/include/SMMessage.h +1 -3
  68. package/ios/include/SMNSNotification.h +19 -5
  69. package/ios/include/SMNotificationAnnotationData.h +4 -8
  70. package/ios/include/SMNotificationButtonData.h +1 -6
  71. package/ios/include/SMNotificationButtonType.h +1 -2
  72. package/ios/include/SMNotificationMessage.h +31 -0
  73. package/ios/include/SMRemoteMessageDisplayType.h +32 -0
  74. package/ios/include/SMSuccess.h +1 -4
  75. package/ios/{libSelligentMobile2.5.a → libSelligentMobile2.7.a} +0 -0
  76. package/package.json +3 -3
  77. package/ios/include/SMLocationAuthorisationType.h +0 -57
@@ -18,11 +18,11 @@ Pod::Spec.new do |s|
18
18
  s.source_files = "ios/**/*.{h,m}"
19
19
  s.requires_arc = true
20
20
 
21
- s.vendored_libraries = "ios/libSelligentMobile2.5.a"
22
- s.libraries = "SelligentMobile2.5"
21
+ s.vendored_libraries = "ios/libSelligentMobile2.7.a"
22
+ s.libraries = "SelligentMobile2.7"
23
23
 
24
24
  s.dependency "React"
25
- s.dependency 'PlotPlugin', '3.3.2'
25
+ s.dependency 'PlotPlugin'
26
26
  end
27
27
 
28
-
28
+
@@ -1,4 +1,3 @@
1
-
2
1
  buildscript {
3
2
  repositories {
4
3
  jcenter()
@@ -6,7 +5,7 @@ buildscript {
6
5
  }
7
6
 
8
7
  dependencies {
9
- classpath 'com.android.tools.build:gradle:3.5.3'
8
+ classpath 'com.android.tools.build:gradle:4.2.2'
10
9
  }
11
10
  }
12
11
 
@@ -23,11 +22,25 @@ android {
23
22
  versionCode 1
24
23
  versionName "1.0"
25
24
  }
25
+
26
26
  lintOptions {
27
27
  abortOnError false
28
28
  }
29
29
  }
30
30
 
31
+ androidComponents {
32
+ onVariants(selector(), { variant ->
33
+ def selligentSettings = loadSelligentSettings(variant)
34
+ if (selligentSettings != null) {
35
+ try {
36
+ variant.addBuildConfigField("SELLIGENT_SETTINGS", "\"" + selligentSettings + "\"", "Selligent settings")
37
+ } catch (MissingMethodException ignored) {
38
+ throw new Exception("Selligent requires Android Gradle plugin version 4.2.0 or higher.")
39
+ }
40
+ }
41
+ })
42
+ }
43
+
31
44
  repositories {
32
45
  maven {
33
46
  url "$projectDir/../node_modules/react-native/android"
@@ -36,13 +49,12 @@ repositories {
36
49
  }
37
50
 
38
51
  dependencies {
39
- implementation(name:'sdk-release', ext:'aar')
52
+ implementation(name: 'sdk-release', ext: 'aar')
40
53
 
41
54
  implementation 'com.facebook.react:react-native:+'
42
55
  implementation 'com.android.support:cardview-v7:27.1.1'
43
- implementation 'com.plotprojects:plot-android:3.12.1'
56
+ implementation 'com.plotprojects:plot-android:3.13.1'
44
57
  implementation 'com.google.code.gson:gson:2.8.5'
45
- implementation 'com.firebase:firebase-jobdispatcher:0.8.5'
46
58
  implementation 'com.google.firebase:firebase-messaging:21.0.0'
47
59
  implementation 'androidx.work:work-runtime:2.4.0'
48
60
  implementation 'androidx.concurrent:concurrent-futures:1.1.0'
@@ -112,16 +124,26 @@ afterEvaluate { project ->
112
124
  }
113
125
  }
114
126
 
115
- def loadSelligentSettings() {
116
- def selligentFileName = "selligent.json"
117
- println("Reading Selligent settings from: $selligentFileName")
127
+ def loadSelligentSettings(variant) {
128
+ println(variant.flavorName)
129
+
130
+ def defaultSelligentFileName = "selligent.json"
131
+ File defaultFile = new File("$project.rootDir/../$defaultSelligentFileName")
118
132
 
119
- File f = new File("$project.rootDir/../$selligentFileName");
133
+ def variantSelligentFileName = "selligent.${variant.getName()}.json"
134
+ File variantFile = new File("$project.rootDir/../$variantSelligentFileName");
120
135
 
121
136
  def resultingSettings = null
122
- if (f.exists()) {
137
+ if (variantFile.exists()) {
138
+ println("Reading Selligent properties for variant ${variant.getName()} using $variantSelligentFileName")
123
139
  resultingSettings = ""
124
- f.eachLine { String line ->
140
+ variantFile.eachLine { String line ->
141
+ resultingSettings += line.replace("\"", "\\\"").replaceAll("\\s", "")
142
+ }
143
+ } else if (defaultFile.exists()) {
144
+ println("Reading Selligent properties from default $defaultSelligentFileName (no variant specific $variantSelligentFileName was found)")
145
+ resultingSettings = ""
146
+ defaultFile.eachLine { String line ->
125
147
  resultingSettings += line.replace("\"", "\\\"").replaceAll("\\s", "")
126
148
  }
127
149
  } else {
@@ -129,18 +151,4 @@ def loadSelligentSettings() {
129
151
  }
130
152
 
131
153
  return resultingSettings
132
- }
133
-
134
- tasks.whenTaskAdded { task ->
135
- task.doFirst() {
136
- android.libraryVariants.all { variant ->
137
- if (task.name.toLowerCase() == "pre${variant.name}build") {
138
- def selligentSettings = loadSelligentSettings()
139
- if (selligentSettings != null) {
140
- variant.buildConfigField "String", "SELLIGENT_SETTINGS", "\"$selligentSettings\""
141
- }
142
- }
143
-
144
- }
145
- }
146
- }
154
+ }
Binary file
@@ -7,6 +7,8 @@ import android.content.Intent;
7
7
  import android.content.IntentFilter;
8
8
  import android.content.res.Resources;
9
9
  import androidx.localbroadcastmanager.content.LocalBroadcastManager;
10
+
11
+ import android.graphics.Color;
10
12
  import android.util.Log;
11
13
 
12
14
  import com.facebook.react.bridge.ActivityEventListener;
@@ -72,7 +74,7 @@ public class RNSelligent extends ReactContextBaseJavaModule implements Lifecycle
72
74
  final SMSettings smSettings = SMSettingsFactory.getSMSettings(settings);
73
75
  final String notificationActivityName = settings.getActivityName();
74
76
 
75
- SMManager.NOTIFICATION_ACTIVITY = Class.forName(notificationActivityName);
77
+ SMManager.NOTIFICATION_ACTIVITY = (Class<? extends Activity>) Class.forName(notificationActivityName);
76
78
 
77
79
  final SMManager smManager = SMManager.getInstance();
78
80
  smManager.start(smSettings, application);
@@ -93,6 +95,15 @@ public class RNSelligent extends ReactContextBaseJavaModule implements Lifecycle
93
95
  }
94
96
  }
95
97
 
98
+ if (settings.getNotificationIconColor() != null && !settings.getNotificationIconColor().isEmpty()) {
99
+ try {
100
+ final int color = Color.parseColor(settings.getNotificationIconColor());
101
+ smManager.setNotificationIconColor(color);
102
+ } catch (IllegalArgumentException e) {
103
+ Log.e("RNSelligent", "notificationIconColor must be a color hex string.");
104
+ }
105
+ }
106
+
96
107
  } catch (ClassNotFoundException e) {
97
108
  Log.e("RNSelligent", "SMManager start failed: an error occurred while setting the NotificationActivity", e);
98
109
  }
@@ -163,20 +174,26 @@ public class RNSelligent extends ReactContextBaseJavaModule implements Lifecycle
163
174
  messageMap.putDouble("expirationDate", message.getExpirationDate());
164
175
  messageMap.putDouble("receptionDate", message.getReceptionDate());
165
176
  messageMap.putBoolean("hasBeenSeen", message.hasBeenSeen());
177
+ messageMap.putDouble("type", message.getType().getValue());
166
178
 
167
179
  WritableArray buttonsArray = new WritableNativeArray();
168
180
 
169
- for(SMNotificationButton button : message.getButtons()) {
170
- WritableMap buttonMap = new WritableNativeMap();
181
+ SMNotificationButton buttons[] = message.getButtons();
182
+
183
+ if(buttons != null) {
184
+ for(SMNotificationButton button : buttons) {
185
+ WritableMap buttonMap = new WritableNativeMap();
171
186
 
172
- buttonMap.putString("id", button.id);
173
- buttonMap.putString("value", button.value);
174
- buttonMap.putString("label", button.label);
175
- buttonMap.putInt("action", button.action);
176
- buttonMap.putInt("type", button.type);
187
+ buttonMap.putString("id", button.id);
188
+ buttonMap.putString("value", button.value);
189
+ buttonMap.putString("label", button.label);
190
+ buttonMap.putInt("action", button.action);
191
+ buttonMap.putInt("type", button.type);
177
192
 
178
- buttonsArray.pushMap(buttonMap);
193
+ buttonsArray.pushMap(buttonMap);
194
+ }
179
195
  }
196
+
180
197
  messageMap.putArray("buttons", buttonsArray);
181
198
 
182
199
  resultingMessagesArray.pushMap(messageMap);
@@ -265,6 +282,12 @@ public class RNSelligent extends ReactContextBaseJavaModule implements Lifecycle
265
282
  smManager.sendSMEvent(smEvent);
266
283
  }
267
284
 
285
+ @ReactMethod
286
+ public void getDeviceId(Callback successCallback) {
287
+ final String deviceId = smManager.getDeviceId();
288
+ successCallback.invoke(deviceId);
289
+ }
290
+
268
291
  @ReactMethod
269
292
  public void enableNotifications(Boolean enable) {
270
293
  if (enable) {
@@ -323,6 +346,27 @@ public class RNSelligent extends ReactContextBaseJavaModule implements Lifecycle
323
346
  return resourceId;
324
347
  }
325
348
 
349
+ @ReactMethod
350
+ public void setNotificationIconColor(final String colorString, final Callback successCallback, final Callback errorCallback) {
351
+ try {
352
+ final int color = Color.parseColor(colorString);
353
+ smManager.setNotificationIconColor(color);
354
+ successCallback.invoke();
355
+ } catch (IllegalArgumentException e) {
356
+ errorCallback.invoke("color must be a color hex string.");
357
+ }
358
+ }
359
+
360
+ @ReactMethod
361
+ public void setNotificationActivity(final String activityName, final Callback successCallback, final Callback errorCallback) {
362
+ try {
363
+ SMManager.NOTIFICATION_ACTIVITY = (Class<? extends Activity>) Class.forName(activityName);
364
+ successCallback.invoke();
365
+ } catch (ClassNotFoundException e) {
366
+ errorCallback.invoke(String.format("Activity %s not found.", activityName));
367
+ }
368
+ }
369
+
326
370
  @ReactMethod
327
371
  public void getGCMToken(Callback callback) {
328
372
  final String gcmToken = smManager.getGCMToken();
@@ -390,8 +434,6 @@ public class RNSelligent extends ReactContextBaseJavaModule implements Lifecycle
390
434
  }
391
435
  currentActivity.registerReceiver(receiver, receiver.getIntentFilter());
392
436
 
393
- smManager.registerDevice(currentActivity);
394
-
395
437
  smManager.checkAndDisplayMessage(currentActivity.getIntent(), currentActivity);
396
438
  }
397
439
  }
@@ -413,6 +455,7 @@ public class RNSelligent extends ReactContextBaseJavaModule implements Lifecycle
413
455
  final Activity currentActivity = getCurrentActivity();
414
456
 
415
457
  if (currentActivity != null) {
458
+ currentActivity.setIntent(intent);
416
459
  smManager.checkAndDisplayMessage(intent, currentActivity);
417
460
  }
418
461
  }
@@ -11,6 +11,7 @@ class SMSettingsFactory {
11
11
  smSettings.PrivateKey = settings.getPrivateKey();
12
12
  smSettings.GoogleApplicationId = settings.getGoogleApplicationId();
13
13
  smSettings.ConfigureGeolocation = settings.getConfigureLocationServices();
14
+ smSettings.AddInAppMessageFromPushToInAppMessageList = settings.getAddInAppMessageFromPushToInAppMessageList();
14
15
  smSettings.DoNotFetchTheToken = settings.getDoNotFetchTheToken();
15
16
  smSettings.DoNotListenToThePush = settings.getDoNotListenToThePush();
16
17
  smSettings.LoadCacheAsynchronously = settings.getLoadCacheAsynchronously();
@@ -12,6 +12,8 @@ class Settings {
12
12
  private String activityName;
13
13
  private String notificationSmallIcon;
14
14
  private String notificationLargeIcon;
15
+ private String notificationIconColor;
16
+ private boolean addInAppMessageFromPushToInAppMessageList = false;
15
17
  private Boolean doNotFetchTheToken = false;
16
18
  private Boolean doNotListenToThePush = false;
17
19
  private Boolean loadCacheAsynchronously = false;
@@ -50,12 +52,18 @@ class Settings {
50
52
  return notificationLargeIcon;
51
53
  }
52
54
 
55
+ public String getNotificationIconColor() {
56
+ return notificationIconColor;
57
+ }
58
+
53
59
  public Boolean getConfigureLocationServices() {
54
60
  return configureLocationServices;
55
61
  }
56
62
 
57
63
  public Boolean getDoNotListenToThePush() { return doNotListenToThePush; }
58
64
 
65
+ public Boolean getAddInAppMessageFromPushToInAppMessageList() { return addInAppMessageFromPushToInAppMessageList; }
66
+
59
67
  public Boolean getDoNotFetchTheToken() { return doNotFetchTheToken; }
60
68
 
61
69
  public Boolean getLoadCacheAsynchronously() { return loadCacheAsynchronously; }
@@ -95,6 +103,14 @@ class Settings {
95
103
  settings.notificationLargeIcon = (String) settingsHashMap.get("notificationLargeIcon");
96
104
  }
97
105
 
106
+ if(settingsHashMap.containsKey("notificationIconColor")) {
107
+ settings.notificationIconColor = (String) settingsHashMap.get("notificationIconColor");
108
+ }
109
+
110
+ if (settingsHashMap.containsKey("addInAppMessageFromPushToInAppMessageList")) {
111
+ settings.addInAppMessageFromPushToInAppMessageList = (Boolean) settingsHashMap.get("addInAppMessageFromPushToInAppMessageList");
112
+ }
113
+
98
114
  if (settingsHashMap.containsKey("doNotFetchTheToken")) {
99
115
  settings.doNotFetchTheToken = (Boolean) settingsHashMap.get("doNotFetchTheToken");
100
116
  }
package/constants.d.ts ADDED
@@ -0,0 +1,103 @@
1
+ export namespace ClearCacheIntervalValue {
2
+ const AUTO = 1;
3
+ const NONE = 2;
4
+ const DAY = 3;
5
+ const WEEK = 4;
6
+ const MONTH = 5;
7
+ const QUARTER = 6;
8
+ }
9
+
10
+ export namespace InAppMessageRefreshType {
11
+ const NONE = 10;
12
+ const MINUTE = 11;
13
+ const HOUR = 12;
14
+ const DAY = 13;
15
+ }
16
+
17
+ export namespace InAppMessageType {
18
+ const UNKNOWN: -2;
19
+ const HIDDEN: -1;
20
+ const ALERT: 0;
21
+ const HTML: 1;
22
+ const URL: 2;
23
+ const IMAGE: 3;
24
+ const MAP: 4;
25
+ const PASSBOOK: 5;
26
+ }
27
+
28
+ export namespace RemoteMessagesDisplayType {
29
+ const AUTOMATIC = 20;
30
+ const NONE = 21;
31
+ const NOTIFICATION = 22;
32
+ }
33
+
34
+ export namespace AndroidRemoteMessagesDisplayType {
35
+ const AUTOMATIC = 20;
36
+ const NONE = 21;
37
+ const NOTIFICATION = 22;
38
+ }
39
+
40
+ export namespace iOSLogLevel {
41
+ const NONE = 50;
42
+ const INFO = 51;
43
+ const WARNING = 52;
44
+ const ERROR = 53;
45
+ const HTTP_CALL = 54;
46
+ const LOCATION = 55;
47
+ const ALL = 56;
48
+ }
49
+
50
+ export namespace iOSBackgroundFetchResult {
51
+ const NEW_DATA = 60;
52
+ const NO_DATA = 61;
53
+ const FAILED = 62;
54
+ }
55
+
56
+ export namespace iOSLocationAuthorisationStatus {
57
+ const UNKNOWN = 70;
58
+ const REFUSED = 71;
59
+ const GRANTED_IN_USE = 72;
60
+ const GRANTED_ALWAYS = 73;
61
+ }
62
+
63
+ export namespace iOSLocationAuthorisationType {
64
+ const IN_USE = 80;
65
+ const ALWAYS = 81;
66
+ }
67
+
68
+ export namespace EventType {
69
+ const USER_REGISTER = 90;
70
+ const USER_UNREGISTER = 91;
71
+ const USER_LOGIN = 92;
72
+ const USER_LOGOUT = 93;
73
+ const CUSTOM = 94;
74
+ }
75
+
76
+ export namespace iOSNotificationButtonType {
77
+ const UNKNOWN = 100;
78
+ const SIMPLE_OPEN_PHONE_CALL = 101;
79
+ const OPEN_SMS = 102;
80
+ const OPEN_MAIL = 103;
81
+ const OPEN_BROWSER = 104;
82
+ const OPEN_APPLICATION = 105;
83
+ const RATE_APPLICATION = 106;
84
+ const CUSTOM_ACTION_BROADCAST_EVENT = 107;
85
+ const RETURN_TEXT = 108;
86
+ const RETURN_PHOTO = 109;
87
+ const RETURN_TEXT_AND_PHOTO = 110;
88
+ const PASSBOOK = 111;
89
+ }
90
+
91
+ export namespace BroadcastEventType {
92
+ const BUTTON_CLICKED = "ButtonClicked";
93
+ const RECEIVED_IN_APP_MESSAGE = "ReceivedInAppMessage";
94
+ const WILL_DISPLAY_NOTIFICATION = "WillDisplayNotification";
95
+ const WILL_DISMISS_NOTIFICATION = "WillDismissNotification";
96
+ const RECEIVED_GCM_TOKEN = "ReceivedGCMToken";
97
+ const RECEIVED_DEVICE_ID = "ReceivedDeviceId";
98
+ const RECEIVED_REMOTE_NOTIFICATION = "ReceivedRemoteNotification";
99
+ }
100
+
101
+ export namespace RemoteNotification {
102
+ const FETCHED_REMOTE_NOTIFICATION = "FetchedRemoteNotification";
103
+ }
package/constants.js CHANGED
@@ -1,4 +1,4 @@
1
- import {Platform} from 'react-native'
1
+ import { Platform } from 'react-native'
2
2
 
3
3
  /**
4
4
  * @module SelligentConstants
@@ -32,6 +32,32 @@ var SelligentConstants = {
32
32
  /** Refresh in-app messages daily */
33
33
  DAY: 13,
34
34
  },
35
+ /**
36
+ * @description
37
+ * Defines the in-app messages type.
38
+ */
39
+ InAppMessageType: {
40
+ UNKNOWN: -2,
41
+ HIDDEN: -1,
42
+ ALERT: 0,
43
+ HTML: 1,
44
+ URL: 2,
45
+ IMAGE: 3,
46
+ MAP: 4,
47
+ PASSBOOK: 5,
48
+ },
49
+ /**
50
+ * @description
51
+ * Defines if and how remote messages can be displayed.
52
+ */
53
+ RemoteMessagesDisplayType: {
54
+ /** Display remote messages automatically */
55
+ AUTOMATIC: 20,
56
+ /** Don't display remote messages */
57
+ NONE: 21,
58
+ /** Display remote messages as notification */
59
+ NOTIFICATION: 22
60
+ },
35
61
  /**
36
62
  * @description
37
63
  * Defines if and how remote messages can be displayed on Android.
@@ -159,6 +185,8 @@ var SelligentConstants = {
159
185
  WILL_DISPLAY_NOTIFICATION: "WillDisplayNotification",
160
186
  /** A notification will be dismissed */
161
187
  WILL_DISMISS_NOTIFICATION: "WillDismissNotification",
188
+ /** A device id has been received */
189
+ RECEIVED_DEVICE_ID: "ReceivedDeviceId"
162
190
  },
163
191
  /**
164
192
  * @description
package/index.android.js CHANGED
@@ -10,6 +10,16 @@ export default {
10
10
  // Basic SMManager
11
11
 
12
12
  // InAppMessage
13
+
14
+ /**
15
+ * Enable/disable in-app messages on Android.
16
+ *
17
+ * Android specific: if args is a boolean set to "true", the in-app messages will be enabled with a default refresh type "DAY".
18
+ *
19
+ * @param {function} successCallback Callback function on success.
20
+ * @param {function} errorCallback Callback function on error.
21
+ * @param {(boolean|InAppMessageRefreshType)} options Boolean to enable/disable in-app messages or an enum InAppMessageRefreshType to enable and set which in-app messages should be enabled.
22
+ */
13
23
  enableInAppMessages: function (successCallback, errorCallback, enabled) {
14
24
  if (!SelligentHelpers.typeMatches(enabled, 'number') && !SelligentHelpers.typeMatches(enabled, 'boolean')) {
15
25
  errorCallback(SelligentHelpers.wrongArgumentError('Expected a boolean or a number.'))
@@ -20,9 +30,23 @@ export default {
20
30
  RNSelligent.enableInAppMessages({ enabled })
21
31
  return
22
32
  },
33
+
34
+ /**
35
+ * To check if in app messages are enabled on Android.
36
+ *
37
+ * @param {function} successCallback Callback function on success.
38
+ */
23
39
  areInAppMessagesEnabled: function (successCallback) {
24
40
  return RNSelligent.areInAppMessagesEnabled(successCallback)
25
41
  },
42
+
43
+ /**
44
+ * Display message on Android.
45
+ *
46
+ * @param {function} successCallback Callback function on success.
47
+ * @param {function} errorCallback Callback function on error.
48
+ * @param {string} messageId Id of the message.
49
+ */
26
50
  displayMessage: function (successCallback, errorCallback, messageId) {
27
51
  if (!SelligentHelpers.typeMatches(messageId, 'string')) {
28
52
  errorCallback(SelligentHelpers.wrongArgumentError('Expected a string.'))
@@ -35,6 +59,13 @@ export default {
35
59
  },
36
60
 
37
61
  // Log
62
+ /**
63
+ * Enable logging messages on Android.
64
+ *
65
+ * @param {function} successCallback Callback function on success.
66
+ * @param {function} errorCallback Callback function on error.
67
+ * @param {boolean} shouldEnableLoggingMessages Boolean to enable/disable logging messages on Android.
68
+ */
38
69
  enableAndroidLogging: function (successCallback, errorCallback, enabled) {
39
70
  if (!SelligentHelpers.typeMatches(enabled, 'boolean')) {
40
71
  errorCallback(SelligentHelpers.wrongArgumentError('Expected a boolean.'))
@@ -46,10 +77,24 @@ export default {
46
77
  return
47
78
  },
48
79
  // Remote Notification
80
+
81
+ /**
82
+ * Check if notifications are enabled or disabled.
83
+ *
84
+ * @param {function} successCallback Callback function on success.
85
+ */
49
86
  areNotificationsEnabled: function (successCallback) {
50
87
  RNSelligent.areNotificationsEnabled(successCallback)
51
88
  return
52
89
  },
90
+
91
+ /**
92
+ * Set the resource for the small icon for notifications on Android.
93
+ *
94
+ * @param {function} successCallback Callback function on success.
95
+ * @param {function} errorCallback Callback function on error.
96
+ * @param {string} iconName Name of the icon.
97
+ */
53
98
  setNotificationSmallIcon: function (successCallback, errorCallback, iconName) {
54
99
  if (!SelligentHelpers.typeMatches(iconName, 'string') || iconName.length === 0) {
55
100
  errorCallback(SelligentHelpers.wrongArgumentError('Expected a string (not empty).'))
@@ -60,6 +105,14 @@ export default {
60
105
  RNSelligent.setNotificationSmallIcon(iconName)
61
106
  return
62
107
  },
108
+
109
+ /**
110
+ * Set the resource for the large icon for notifications on Android.
111
+ *
112
+ * @param {function} successCallback Callback function on success.
113
+ * @param {function} errorCallback Callback function on error.
114
+ * @param {string} iconName Name of the icon.
115
+ */
63
116
  setNotificationLargeIcon: function (successCallback, errorCallback, iconName) {
64
117
  if (!SelligentHelpers.typeMatches(iconName, 'string') || iconName.length === 0) {
65
118
  errorCallback(SelligentHelpers.wrongArgumentError('Expected a string (not empty).'))
@@ -70,15 +123,79 @@ export default {
70
123
  RNSelligent.setNotificationLargeIcon(iconName)
71
124
  return
72
125
  },
126
+
127
+ /**
128
+ * Set the color for the icon for notifications on Android.
129
+ *
130
+ * @param {function} successCallback Callback function on success.
131
+ * @param {function} errorCallback Callback function on error.
132
+ * @param {string} color The color for the notification.
133
+ */
134
+ setNotificationIconColor: function (successCallback, errorCallback, color) {
135
+ if (!SelligentHelpers.typeMatches(color, 'string') || color.length === 0) {
136
+ errorCallback(SelligentHelpers.wrongArgumentError('Expected a string (not empty).'))
137
+ return
138
+ }
139
+
140
+ const _successCallback = () => {
141
+ successCallback(SelligentHelpers.SUCCESS)
142
+ }
143
+
144
+ RNSelligent.setNotificationIconColor(color, _successCallback, errorCallback)
145
+ return
146
+ },
147
+
148
+ /**
149
+ * Set the notification activity on Android.
150
+ *
151
+ * @param {function} successCallback Callback function on success.
152
+ * @param {function} errorCallback Callback function on error.
153
+ * @param {string} activityName The name of the activity.
154
+ */
155
+ setNotificationActivity: function (successCallback, errorCallback, activityName) {
156
+ if (!SelligentHelpers.typeMatches(activityName, 'string') || activityName.length === 0) {
157
+ errorCallback(SelligentHelpers.wrongArgumentError('Expected a string (not empty).'))
158
+ return
159
+ }
160
+
161
+ const _successCallback = () => {
162
+ successCallback(SelligentHelpers.SUCCESS)
163
+ }
164
+
165
+ RNSelligent.setNotificationActivity(activityName, _successCallback, errorCallback)
166
+ return
167
+ },
168
+
169
+ /**
170
+ * Get GCM Token
171
+ *
172
+ * @param {function} successCallback Callback function on success.
173
+ */
73
174
  getGCMToken: function (successCallback) {
74
175
  RNSelligent.getGCMToken(successCallback)
75
176
  return
76
177
  },
178
+
179
+ /**
180
+ * Get remote messages display type.
181
+ *
182
+ * @param {function} successCallback Callback function on success.
183
+ * @param {function} errorCallback Callback function on error.
184
+ */
77
185
  getRemoteMessagesDisplayType: function (successCallback) {
78
186
  RNSelligent.getRemoteMessagesDisplayType(successCallback)
79
187
  return
80
188
  },
81
189
  // Broadcasts Events
190
+
191
+ /**
192
+ * Subscribe to events.
193
+ *
194
+ * @param {function} successCallback Callback function on success.
195
+ * @param {function} errorCallback Callback function on error.
196
+ * @param {function} eventCallback Callback function on event.
197
+ * @param {array} customEvents Array of custom events to subscribe to.
198
+ */
82
199
  subscribeToEvents: function (successCallback, errorCallback, eventCallback, customEvents = []) {
83
200
 
84
201
  if (customEvents !== undefined) {
@@ -107,10 +224,25 @@ export default {
107
224
  RNSelligent.subscribeToEvents(customEvents)
108
225
  return
109
226
  },
227
+
228
+ /**
229
+ * Subscribe to event.
230
+ *
231
+ * @param {function} eventCallback Callback function on event.
232
+ * @param {string} eventName Name of the event to subscribe to.
233
+ */
110
234
  subscribeToEvent: function (eventCallback, eventName) {
111
235
  RNSEventEmitter.addListener(eventName, eventCallback);
112
236
  return
113
237
  },
238
+
239
+ /**
240
+ * Set the firebase (GCM) token
241
+ *
242
+ * @param {function} successCallback Callback function on success.
243
+ * @param {function} errorCallback Callback function on error.
244
+ * @param {string} token the firebase token.
245
+ */
114
246
  setFirebaseToken: function (successCallback, errorCallback, token) {
115
247
  if (!SelligentHelpers.typeMatches(token, 'string') || token.length === 0) {
116
248
  errorCallback(SelligentHelpers.wrongArgumentError('Expected a string (not empty).'))