@selligent-marketing-cloud/selligent-react-native 3.0.0 → 3.2.6
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 +43 -1550
- package/RNSelligent.podspec +8 -15
- package/android/build.gradle +48 -81
- package/android/src/main/java/com/selligent/BroadcastEventType.java +4 -1
- package/android/src/main/java/com/selligent/ButtonAction.java +81 -0
- package/android/src/main/java/com/selligent/ButtonBroadcastEventDataParser.java +9 -3
- package/android/src/main/java/com/selligent/DeviceIdBroadcastEventDataParser.java +15 -0
- package/android/src/main/java/com/selligent/EventType.java +1 -1
- package/android/src/main/java/com/selligent/GCMTokenBroadcastEventDataParser.java +6 -1
- package/android/src/main/java/com/selligent/InAppMessageBroadcastEventDataParser.java +7 -1
- package/android/src/main/java/com/selligent/NotificationMessageBroadcastEventDataParser.java +19 -0
- package/android/src/main/java/com/selligent/RNSelligent.java +195 -56
- package/android/src/main/java/com/selligent/SMSettingsFactory.java +0 -1
- package/android/src/main/java/com/selligent/Settings.java +0 -9
- package/constants.d.ts +7 -33
- package/constants.js +51 -85
- package/documentation/README.md +826 -0
- package/helpers.js +5 -6
- package/index.android.js +8 -83
- package/index.d.ts +33 -43
- package/index.ios.js +25 -76
- package/index.js +153 -45
- package/ios/RNSelligentMapper.h +21 -0
- package/ios/RNSelligentMapper.m +151 -0
- package/ios/RNSelligentMobileSDK.xcframework/Info.plist +40 -0
- package/ios/RNSelligentMobileSDK.xcframework/ios-arm64/RNSelligentMobileSDK.framework/Headers/RNSelligentMobileSDK-Swift.h +350 -0
- 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 +2603 -0
- package/ios/RNSelligentMobileSDK.xcframework/ios-arm64/RNSelligentMobileSDK.framework/Modules/RNSelligentMobileSDK.swiftmodule/arm64-apple-ios.private.swiftinterface +59 -0
- 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 +59 -0
- package/ios/RNSelligentMobileSDK.xcframework/ios-arm64/RNSelligentMobileSDK.framework/Modules/module.modulemap +4 -0
- package/ios/RNSelligentMobileSDK.xcframework/ios-arm64/RNSelligentMobileSDK.framework/RNSelligentMobileSDK +0 -0
- package/ios/RNSelligentMobileSDK.xcframework/ios-arm64/RNSelligentMobileSDK.framework/_CodeSignature/CodeResources +179 -0
- package/ios/RNSelligentMobileSDK.xcframework/ios-arm64_x86_64-simulator/RNSelligentMobileSDK.framework/Headers/RNSelligentMobileSDK-Swift.h +696 -0
- 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 +2603 -0
- package/ios/RNSelligentMobileSDK.xcframework/ios-arm64_x86_64-simulator/RNSelligentMobileSDK.framework/Modules/RNSelligentMobileSDK.swiftmodule/arm64-apple-ios-simulator.private.swiftinterface +59 -0
- 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 +59 -0
- package/ios/RNSelligentMobileSDK.xcframework/ios-arm64_x86_64-simulator/RNSelligentMobileSDK.framework/Modules/RNSelligentMobileSDK.swiftmodule/x86_64-apple-ios-simulator.abi.json +2603 -0
- package/ios/RNSelligentMobileSDK.xcframework/ios-arm64_x86_64-simulator/RNSelligentMobileSDK.framework/Modules/RNSelligentMobileSDK.swiftmodule/x86_64-apple-ios-simulator.private.swiftinterface +59 -0
- 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 +59 -0
- package/ios/RNSelligentMobileSDK.xcframework/ios-arm64_x86_64-simulator/RNSelligentMobileSDK.framework/Modules/module.modulemap +4 -0
- 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 +234 -0
- package/package.json +30 -11
- package/.gitattributes +0 -1
- package/CHANGELOG.md +0 -60
- package/android/README.md +0 -15
- package/android/build/generated/source/buildConfig/debug/com/selligent/BuildConfig.java +0 -12
- package/android/build/intermediates/aapt_friendly_merged_manifests/debug/aapt/AndroidManifest.xml +0 -9
- package/android/build/intermediates/aapt_friendly_merged_manifests/debug/aapt/output-metadata.json +0 -18
- package/android/build/intermediates/aar_metadata/debug/aar-metadata.properties +0 -4
- package/android/build/intermediates/annotation_processor_list/debug/annotationProcessors.json +0 -1
- package/android/build/intermediates/compile_library_classes_jar/debug/classes.jar +0 -0
- package/android/build/intermediates/compile_r_class_jar/debug/R.jar +0 -0
- package/android/build/intermediates/compile_symbol_list/debug/R.txt +0 -6548
- package/android/build/intermediates/incremental/debug/packageDebugResources/compile-file-map.properties +0 -1
- package/android/build/intermediates/incremental/debug/packageDebugResources/merger.xml +0 -2
- package/android/build/intermediates/incremental/mergeDebugJniLibFolders/merger.xml +0 -2
- package/android/build/intermediates/incremental/mergeDebugShaders/merger.xml +0 -2
- package/android/build/intermediates/incremental/packageDebugAssets/merger.xml +0 -2
- package/android/build/intermediates/javac/debug/classes/com/selligent/BroadcastDataFactory$1.class +0 -0
- package/android/build/intermediates/javac/debug/classes/com/selligent/BroadcastDataFactory.class +0 -0
- package/android/build/intermediates/javac/debug/classes/com/selligent/BroadcastEventDataParser.class +0 -0
- package/android/build/intermediates/javac/debug/classes/com/selligent/BroadcastEventType.class +0 -0
- package/android/build/intermediates/javac/debug/classes/com/selligent/BuildConfig.class +0 -0
- package/android/build/intermediates/javac/debug/classes/com/selligent/ButtonBroadcastEventDataParser.class +0 -0
- package/android/build/intermediates/javac/debug/classes/com/selligent/ClearCacheIntervalValue.class +0 -0
- package/android/build/intermediates/javac/debug/classes/com/selligent/Event.class +0 -0
- package/android/build/intermediates/javac/debug/classes/com/selligent/EventReceiver.class +0 -0
- package/android/build/intermediates/javac/debug/classes/com/selligent/EventType.class +0 -0
- package/android/build/intermediates/javac/debug/classes/com/selligent/GCMTokenBroadcastEventDataParser.class +0 -0
- package/android/build/intermediates/javac/debug/classes/com/selligent/InAppMessageBroadcastEventDataParser.class +0 -0
- package/android/build/intermediates/javac/debug/classes/com/selligent/InAppMessageRefreshType.class +0 -0
- package/android/build/intermediates/javac/debug/classes/com/selligent/RNSelligent$1.class +0 -0
- package/android/build/intermediates/javac/debug/classes/com/selligent/RNSelligent$2.class +0 -0
- package/android/build/intermediates/javac/debug/classes/com/selligent/RNSelligent$3.class +0 -0
- package/android/build/intermediates/javac/debug/classes/com/selligent/RNSelligent$4.class +0 -0
- package/android/build/intermediates/javac/debug/classes/com/selligent/RNSelligent$5.class +0 -0
- package/android/build/intermediates/javac/debug/classes/com/selligent/RNSelligent.class +0 -0
- package/android/build/intermediates/javac/debug/classes/com/selligent/RNSelligentPackage.class +0 -0
- package/android/build/intermediates/javac/debug/classes/com/selligent/RemoteMessageDisplayType.class +0 -0
- package/android/build/intermediates/javac/debug/classes/com/selligent/SMEventFactory$1.class +0 -0
- package/android/build/intermediates/javac/debug/classes/com/selligent/SMEventFactory.class +0 -0
- package/android/build/intermediates/javac/debug/classes/com/selligent/SMSettingsFactory.class +0 -0
- package/android/build/intermediates/javac/debug/classes/com/selligent/Settings.class +0 -0
- package/android/build/intermediates/local_only_symbol_list/debug/R-def.txt +0 -2
- package/android/build/intermediates/manifest_merge_blame_file/debug/manifest-merger-blame-debug-report.txt +0 -11
- package/android/build/intermediates/merged_manifest/debug/AndroidManifest.xml +0 -9
- package/android/build/intermediates/navigation_json/debug/navigation.json +0 -1
- package/android/build/intermediates/packaged_manifests/debug/output-metadata.json +0 -18
- package/android/build/intermediates/runtime_library_classes_jar/debug/classes.jar +0 -0
- package/android/build/intermediates/symbol_list_with_package_name/debug/package-aware-r.txt +0 -4894
- package/android/build/outputs/logs/manifest-merger-debug-report.txt +0 -25
- package/android/build/tmp/compileDebugJavaWithJavac/previous-compilation-data.bin +0 -0
- package/android/libs/sdk-release.aar +0 -0
- package/documentation/add_json_file.png +0 -0
- package/documentation/add_lib_file.png +0 -0
- package/ios/BackgroundFetchResult.h +0 -5
- package/ios/ClearCacheInterval.h +0 -7
- package/ios/ClientSettings.h +0 -22
- package/ios/ClientSettings.m +0 -39
- package/ios/EnumMapper.h +0 -36
- package/ios/EnumMapper.m +0 -121
- package/ios/Event+SMEvent.h +0 -13
- package/ios/Event+SMEvent.m +0 -41
- package/ios/Event.h +0 -12
- package/ios/Event.m +0 -24
- package/ios/EventType.h +0 -7
- package/ios/InAppMessageRefreshType.h +0 -6
- package/ios/InAppMessageSettings.h +0 -9
- package/ios/InAppMessageSettings.m +0 -19
- package/ios/LocationAuthorisationStatus.h +0 -6
- package/ios/LocationAuthorisationType.h +0 -4
- package/ios/LogLevel.h +0 -9
- package/ios/NotificationButtonType.h +0 -15
- package/ios/ParsableObject.h +0 -5
- package/ios/RNSelligent.h +0 -22
- package/ios/RNSelligent.m +0 -347
- package/ios/RemoteMessageDisplayType.h +0 -5
- package/ios/SMManagerSetting+ClientSettings.h +0 -9
- package/ios/SMManagerSetting+ClientSettings.m +0 -73
- package/ios/SelligentLogger.h +0 -7
- package/ios/SelligentLogger.m +0 -9
- package/ios/SelligentReactNative.xcodeproj/project.pbxproj +0 -446
- package/ios/include/SMBaseMessage.h +0 -48
- package/ios/include/SMBlock.h +0 -21
- package/ios/include/SMClearCache.h +0 -34
- package/ios/include/SMContentAlignment.h +0 -27
- package/ios/include/SMDeviceInfos.h +0 -38
- package/ios/include/SMDisplayMode.h +0 -27
- package/ios/include/SMEvent.h +0 -69
- package/ios/include/SMEventUser.h +0 -20
- package/ios/include/SMEventUserLogin.h +0 -42
- package/ios/include/SMEventUserLogout.h +0 -42
- package/ios/include/SMEventUserRegistration.h +0 -42
- package/ios/include/SMEventUserUnregistration.h +0 -42
- package/ios/include/SMFailure.h +0 -19
- package/ios/include/SMHelper.h +0 -51
- package/ios/include/SMInAppContentHTMLViewController.h +0 -59
- package/ios/include/SMInAppContentImageViewController.h +0 -36
- package/ios/include/SMInAppContentMessage.h +0 -56
- package/ios/include/SMInAppContentStyleOptions.h +0 -511
- package/ios/include/SMInAppContentType.h +0 -35
- package/ios/include/SMInAppContentURLViewController.h +0 -36
- package/ios/include/SMInAppContentViewController.h +0 -31
- package/ios/include/SMInAppMessage.h +0 -51
- package/ios/include/SMInAppMessageType.h +0 -50
- package/ios/include/SMInAppRefreshType.h +0 -29
- package/ios/include/SMLink.h +0 -39
- package/ios/include/SMLog.h +0 -54
- package/ios/include/SMManager+DataTransaction.h +0 -33
- package/ios/include/SMManager+InAppContent.h +0 -170
- package/ios/include/SMManager+InAppMessage.h +0 -172
- package/ios/include/SMManager+Location.h +0 -41
- package/ios/include/SMManager+Log.h +0 -31
- package/ios/include/SMManager+RemoteNotification.h +0 -171
- package/ios/include/SMManager+SMEvent.h +0 -67
- package/ios/include/SMManager+SMLink.h +0 -44
- package/ios/include/SMManager+SilentPush.h +0 -53
- package/ios/include/SMManager+StyleOptions.h +0 -36
- package/ios/include/SMManager+UserNotification.h +0 -180
- package/ios/include/SMManager+ViewController.h +0 -45
- package/ios/include/SMManager.h +0 -69
- package/ios/include/SMManagerHelper.h +0 -18
- package/ios/include/SMManagerInAppMessageDelegate.h +0 -24
- package/ios/include/SMManagerSetting+Location.h +0 -27
- package/ios/include/SMManagerSetting.h +0 -180
- package/ios/include/SMManagerSettingIAC.h +0 -48
- package/ios/include/SMManagerSettingIAM.h +0 -49
- package/ios/include/SMManagerUniversalLinksDelegate.h +0 -23
- package/ios/include/SMMessage.h +0 -21
- package/ios/include/SMNSNotification.h +0 -81
- package/ios/include/SMNotificationAnnotationData.h +0 -33
- package/ios/include/SMNotificationButtonData.h +0 -20
- package/ios/include/SMNotificationButtonType.h +0 -90
- package/ios/include/SMNotificationMessage.h +0 -31
- package/ios/include/SMRemoteMessageDisplayType.h +0 -32
- package/ios/include/SMSuccess.h +0 -16
- package/ios/libSelligentMobile.a +0 -0
- package/trigger.yml +0 -9
|
@@ -0,0 +1,826 @@
|
|
|
1
|
+
# ReactNative – Using the SDK
|
|
2
|
+
|
|
3
|
+
## Foreword
|
|
4
|
+
|
|
5
|
+
Copyright
|
|
6
|
+
|
|
7
|
+
The contents of this manual cover material copyrighted by Selligent. Selligent reserves all intellectual property rights on the manual, which should be treated as confidential information as defined under the agreed upon software licence/lease terms and conditions.
|
|
8
|
+
|
|
9
|
+
The use and distribution of this manual is strictly limited to authorised users of the Selligent Interactive Marketing Software (hereafter the "Software") and can only be used for the purpose of using the Software under the agreed upon software licence/lease terms and conditions. Upon termination of the right to use the Software, this manual and any copies made must either be returned to Selligent or be destroyed, at the latest two weeks after the right to use the Software has ended.
|
|
10
|
+
|
|
11
|
+
With the exception of the first sentence of the previous paragraph, no part of this manual may be reprinted or reproduced or distributed or utilised in any form or by any electronic, mechanical or other means, not known or hereafter invented, included photocopying and recording, or in any information storage or retrieval or distribution system, without the prior permission in writing from Selligent.
|
|
12
|
+
|
|
13
|
+
Selligent will not be responsible or liable for any accidental or inevitable damage that may result from unauthorised access or modifications.
|
|
14
|
+
|
|
15
|
+
User is aware that this manual may contain errors or inaccuracies and that it may be revised without advance notice. This manual is updated frequently.
|
|
16
|
+
|
|
17
|
+
Selligent welcomes any recommendations or suggestions regarding the manual, as it helps to continuously improve the quality of our products and manuals.
|
|
18
|
+
|
|
19
|
+
## Table of Contents
|
|
20
|
+
|
|
21
|
+
- [ReactNative – Using the SDK](#reactnative--using-the-sdk)
|
|
22
|
+
- [Foreword](#foreword)
|
|
23
|
+
- [Table of Contents](#table-of-contents)
|
|
24
|
+
- [Working with the `selligent.json`](#working-with-the-selligentjson)
|
|
25
|
+
- [Push notifications](#push-notifications)
|
|
26
|
+
- [Rich Push Notifications](#rich-push-notifications)
|
|
27
|
+
- [Deep Linking](#deep-linking)
|
|
28
|
+
- [Universal Linking - iOS](#universal-linking---ios)
|
|
29
|
+
- [Notification helper methods](#notification-helper-methods)
|
|
30
|
+
- [Disable Selligent Push Notifications](#disable-selligent-push-notifications)
|
|
31
|
+
- [Display last remote notification](#display-last-remote-notification)
|
|
32
|
+
- [Display last remote notification content](#display-last-remote-notification-content)
|
|
33
|
+
- [Retrieve last remote notification](#retrieve-last-remote-notification)
|
|
34
|
+
- [Broadcasts](#broadcasts)
|
|
35
|
+
- [In-App Messages](#in-app-messages)
|
|
36
|
+
- [Display IAM](#display-iam)
|
|
37
|
+
- [Selligent.displayMessage](#selligentdisplaymessage)
|
|
38
|
+
- [IAM Customization - Android](#iam-customization---android)
|
|
39
|
+
- [IAM Customization - iOS](#iam-customization---ios)
|
|
40
|
+
- [IAM Helper methods](#iam-helper-methods)
|
|
41
|
+
- [Events](#events)
|
|
42
|
+
- [Miscellaneous](#miscellaneous)
|
|
43
|
+
- [Get lib version](#get-lib-version)
|
|
44
|
+
- [Get device id](#get-device-id)
|
|
45
|
+
- [Logging](#logging)
|
|
46
|
+
- [GCM Token - Android](#gcm-token---android)
|
|
47
|
+
- [Constants](#constants)
|
|
48
|
+
- [ClearCacheIntervalValue](#clearcacheintervalvalue)
|
|
49
|
+
- [InAppMessageType](#inappmessagetype)
|
|
50
|
+
- [InAppMessageRefreshType](#inappmessagerefreshtype)
|
|
51
|
+
- [RemoteMessagesDisplayType](#remotemessagesdisplaytype)
|
|
52
|
+
- [iOSLogLevel](#iosloglevel)
|
|
53
|
+
- [EventType](#eventtype)
|
|
54
|
+
- [NotificationButtonType](#notificationbuttontype)
|
|
55
|
+
- [BroadcastEventType](#broadcasteventtype)
|
|
56
|
+
|
|
57
|
+
## Working with the `selligent.json`
|
|
58
|
+
|
|
59
|
+
The following properties can be used in the `selligent.json` to further configure the behaviour of the native SDKs.
|
|
60
|
+
|
|
61
|
+
> The values should be relevant to your configuration. There are parameters that can only be used on a specific platform, but can be set and will be ignored in the other platform.
|
|
62
|
+
|
|
63
|
+
| Property | Type | Description |
|
|
64
|
+
| ------------------------------------------- | ------ | ------- |
|
|
65
|
+
| url | string | The Selligent webservice url to be used to integrate with your Selligent platform |
|
|
66
|
+
| clientId | string | The Selligent client id to be used to integrate with your Selligent platform |
|
|
67
|
+
| privateKey | string | The Selligent private key to be used to integrate with your Selligent platform |
|
|
68
|
+
| delayedPushAction | boolean| (iOS Only) Optin for a specific push action handling (wait for React UI to be ready) when coming from a push message and having the app killed |
|
|
69
|
+
| interceptSelligentUniversalLinks | boolean| (iOS Only) Optin to customly handle the execution of universal links coming from a Push/IAM [more information](#universal-linking---ios) |
|
|
70
|
+
| clearCacheIntervalValue | [enum](#clearcacheintervalvalue) | How much time the SDK will keep things in cache |
|
|
71
|
+
| inAppMessageRefreshType | [enum](#inappmessagerefreshtype) | How often the SDK will check for new inapp messages |
|
|
72
|
+
| addInAppMessageFromPushToInAppMessageList | boolean| Adds inapp messages that are linked to push notifications in the internal inapp message list that can be later [retrieved](#display-iam) |
|
|
73
|
+
| remoteMessageDisplayType | [enum](#remotemessagesdisplaytype) | The behaviour when receiving a push notification with the app in foreground |
|
|
74
|
+
| appGroupId | string |(iOS Only) The appgroup id necessary for the correct communication between the app and the app extensions |
|
|
75
|
+
| 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
|
+
| doNotListenToThePush | boolean | (Android Only) Whether or not, the SDK will listen for pushs from google |
|
|
78
|
+
| doNotFetchTheToken | boolean | (Android Only) Whether or not, the SDK will listen for push tokens from google |
|
|
79
|
+
| loadCacheAsynchronously | boolean | (Android Only) Whether or not, the SDK load the cache asynchronously |
|
|
80
|
+
| fullyQualifiedNotificationActivityClassName | string | (Android Only) The activity that will be opened after clicking in any push notification |
|
|
81
|
+
| notificationSmallIcon | string | (Android Only) Icon name, for the [small icon of push notifications](https://developer.android.com/guide/topics/resources/drawable-resource#BitmapFile) |
|
|
82
|
+
| notificationLargeIcon | string | (Android Only) Icon name, for the [large icon of push notifications](https://developer.android.com/guide/topics/resources/drawable-resource#BitmapFile) |
|
|
83
|
+
| notificationIconColor | string | (Android Only) A hex color code to customize the notification icon in push notifications |
|
|
84
|
+
| notificationChannelId | string | (Android Only) The channel id used by the push notifications received |
|
|
85
|
+
| notificationChannelName | string | (Android Only) The channel name used by the push notifications received |
|
|
86
|
+
| notificationChannelDescription | string | (Android Only) The channel description used by the push notifications received |
|
|
87
|
+
|
|
88
|
+
## Push notifications
|
|
89
|
+
|
|
90
|
+
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
|
+
|
|
92
|
+
**For iOS**, there are some extra steps you need to follow in the native part of the ReactNative project:
|
|
93
|
+
|
|
94
|
+
1. For push notifications you need to delegate some of the `AppDelegate.m` methods to the SDK:
|
|
95
|
+
|
|
96
|
+
```objc
|
|
97
|
+
// In AppDelegate.h
|
|
98
|
+
#import <React/RCTBridgeDelegate.h>
|
|
99
|
+
#import <UIKit/UIKit.h>
|
|
100
|
+
|
|
101
|
+
@import UserNotifications;
|
|
102
|
+
|
|
103
|
+
@interface AppDelegate : UIResponder <UIApplicationDelegate, RCTBridgeDelegate, UNUserNotificationCenterDelegate>
|
|
104
|
+
|
|
105
|
+
@property (nonatomic, strong) UIWindow *window;
|
|
106
|
+
|
|
107
|
+
@end
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
```objc
|
|
111
|
+
// In AppDelegate.m
|
|
112
|
+
#import "AppDelegate.h"
|
|
113
|
+
#import <React/RCTBundleURLProvider.h>
|
|
114
|
+
#import <React/RCTRootView.h>
|
|
115
|
+
|
|
116
|
+
#import <React/RCTAppSetupUtils.h>
|
|
117
|
+
|
|
118
|
+
@import RNSelligentMobileSDK;
|
|
119
|
+
// OR
|
|
120
|
+
// #import <RNSelligentMobileSDK/RNSelligentMobileSDK-Swift.h>
|
|
121
|
+
|
|
122
|
+
@implementation AppDelegate
|
|
123
|
+
|
|
124
|
+
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
|
|
125
|
+
UNUserNotificationCenter *center = [UNUserNotificationCenter currentNotificationCenter];
|
|
126
|
+
center.delegate = self;
|
|
127
|
+
|
|
128
|
+
// RN Setup Code
|
|
129
|
+
|
|
130
|
+
[RNSelligent configureWithLaunchOptions:launchOptions];
|
|
131
|
+
|
|
132
|
+
return YES;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
- (void)application:(UIApplication*)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData*)deviceToken {
|
|
136
|
+
[RNSelligent didRegisterForRemoteNotificationsWithDeviceToken:deviceToken];
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
- (void)application:(UIApplication *)application didFailToRegisterForRemoteNotificationsWithError:(NSError *)error {
|
|
140
|
+
[RNSelligent didFailToRegisterForRemoteNotificationsWithError:error];
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
- (void)userNotificationCenter:(UNUserNotificationCenter *)center willPresentNotification:(UNNotification *)notification withCompletionHandler:(void (^)(UNNotificationPresentationOptions options))completionHandler {
|
|
144
|
+
[RNSelligent willPresentNotification:notification withCompletionHandler:completionHandler];
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
- (void)userNotificationCenter:(UNUserNotificationCenter *)center didReceiveNotificationResponse:(UNNotificationResponse *)response withCompletionHandler:(void(^)(void))completionHandler {
|
|
148
|
+
[RNSelligent didReceiveNotificationResponse:response withCompletionHandler:completionHandler];
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
@end
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
2. Follow section [**Create an APNS Key**](https://github.com/SelligentMarketingCloud/MobileSDK-iOS/tree/master/Documentation#apns_key), of the native documentation.
|
|
155
|
+
|
|
156
|
+
3. Somewhere in your ReactNative app (normally done as soon as possible but can also be done when certain page is reached), you will need to call `Selligent.enableNotifications` to prompt the user for the push notification permission or the `Selligent.registerForProvisionalRemoteNotification` (This option is only available for iOS 12+) if you want to get a provisional permission before asking the user for the normal one.
|
|
157
|
+
|
|
158
|
+
```javascript
|
|
159
|
+
import Selligent from "@selligent-marketing-cloud/selligent-react-native"; // Add Selligent import
|
|
160
|
+
|
|
161
|
+
Selligent.enableNotifications(
|
|
162
|
+
(response) => { // success callback
|
|
163
|
+
},
|
|
164
|
+
(error) => { // error callback
|
|
165
|
+
},
|
|
166
|
+
true
|
|
167
|
+
)
|
|
168
|
+
|
|
169
|
+
Selligent.registerForProvisionalRemoteNotification(
|
|
170
|
+
() => { // success callback
|
|
171
|
+
}
|
|
172
|
+
)
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
### Rich Push Notifications
|
|
176
|
+
|
|
177
|
+
**For iOS**, you will need to implement notification extensions and set the `appGroupId` in the `selligent.json` file.
|
|
178
|
+
Then, follow the [native iOS SDK documentation](https://github.com/SelligentMarketingCloud/MobileSDK-iOS/edit/master/Documentation/README.md#notification-extensions).
|
|
179
|
+
|
|
180
|
+
### Deep Linking
|
|
181
|
+
|
|
182
|
+
**For iOS**, (and depending on your React version) it might be that deeplinks behind push notifications do not work when the App is killed.
|
|
183
|
+
This is because the JS layer is loaded **after** the native iOS SDK executes the deeplink, so the JS event listeners are not there yet. If you want to fix this, follow the below steps (make sure to build for Release when testing this).
|
|
184
|
+
|
|
185
|
+
1. Add the `delayedPushAction` property in `selligent.json` file and set it to `true`
|
|
186
|
+
|
|
187
|
+
2. Implement (if not there yet) a linking handler in your ReactNative codebase (i.e <https://facebook.github.io/react-native/docs/linking>)
|
|
188
|
+
|
|
189
|
+
Example:
|
|
190
|
+
|
|
191
|
+
```objc
|
|
192
|
+
// In Appdelegate.m
|
|
193
|
+
- (BOOL) application:(UIApplication *)application openURL:(NSURL *)url options:(NSDictionary<UIApplicationOpenURLOptionsKey,id> *)options {
|
|
194
|
+
return [RCTLinkingManager application:application openURL:url options:options];
|
|
195
|
+
}
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
```javascript
|
|
199
|
+
// In DeeplinkHook.js
|
|
200
|
+
import { useEffect } from "react";
|
|
201
|
+
import { Alert, Linking } from "react-native";
|
|
202
|
+
|
|
203
|
+
const useHandleDeepLink = () => {
|
|
204
|
+
useEffect(() => {
|
|
205
|
+
Linking.getInitialURL().then((link) => {
|
|
206
|
+
if (link) {
|
|
207
|
+
Alert.alert('Deep Link', link || 'No link')
|
|
208
|
+
}
|
|
209
|
+
}).catch(err => {
|
|
210
|
+
console.warn('An error occurred', err);
|
|
211
|
+
});
|
|
212
|
+
|
|
213
|
+
const urlListener = Linking.addEventListener('url', ({url}) => Alert.alert('Deep Link', url || 'No link'));
|
|
214
|
+
|
|
215
|
+
return () => urlListener.remove();
|
|
216
|
+
}, [])
|
|
217
|
+
};
|
|
218
|
+
|
|
219
|
+
export default useHandleDeepLink;
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
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
|
+
|
|
224
|
+
```javascript
|
|
225
|
+
import Selligent from "@selligent-marketing-cloud/selligent-react-native"; // Add Selligent import
|
|
226
|
+
|
|
227
|
+
const App = () => {
|
|
228
|
+
// Deeplinking handling library (i.e Linking.getInitialURL() & Linking.addEventListener...)
|
|
229
|
+
useHandleDeepLink()
|
|
230
|
+
|
|
231
|
+
if (Platform.OS === 'ios') {
|
|
232
|
+
/* Tells the Selligent SDK to execute the action associated to the last push clicked, when using `delayedPushAction` feature.
|
|
233
|
+
If you are having problems with deeplinks or 'Push + InApp Message' where the splash screen gets stuck or the push action not visible,
|
|
234
|
+
make sure you control when the splash screen is dismissed and call this method afterwards (if the dismiss is async, call this method once the async process is completely finished)
|
|
235
|
+
*/
|
|
236
|
+
Selligent.executePushAction()
|
|
237
|
+
}
|
|
238
|
+
```
|
|
239
|
+
|
|
240
|
+
#### Universal Linking - iOS
|
|
241
|
+
|
|
242
|
+
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.
|
|
243
|
+
|
|
244
|
+
You can then subscribe to `SelligentConstants.BroadcastEventType.UNIVERSAL_LINK_EXECUTED` event through the `Selligent.subscribeToEvents` whose execution callback will get triggered when a `deeplink` button type is defined in Selligent Marketing Cloud (whose URL scheme is `http` or `https`).
|
|
245
|
+
The response of the success callback is an object which contains information on the type of broadcast event and the data attached to it.
|
|
246
|
+
|
|
247
|
+
| Property | Type | Description |
|
|
248
|
+
| ------------------ | ------------------------------------------------------- | ----------------------------------------------------------------- |
|
|
249
|
+
| data | object | Contains more information specific to the type of broadcast event |
|
|
250
|
+
| broadcastEventType | [enum](#broadcasteventtype) | The type of broadcast event |
|
|
251
|
+
|
|
252
|
+
The `data` property is an object itself containing more information specific to the type of the broadcast event:
|
|
253
|
+
|
|
254
|
+
- UNIVERSAL_LINK_EXECUTED:
|
|
255
|
+
|
|
256
|
+
| Property | Type | Description |
|
|
257
|
+
| -------- | ------ | ------------------------------------------ |
|
|
258
|
+
| url | string | The executed URL as a string |
|
|
259
|
+
|
|
260
|
+
```javascript
|
|
261
|
+
Selligent.subscribeToEvents(
|
|
262
|
+
() => {},
|
|
263
|
+
() => {},
|
|
264
|
+
(response) => {
|
|
265
|
+
if (response?.broadcastEventType === SelligentConstants.BroadcastEventType.UNIVERSAL_LINK_EXECUTED) {
|
|
266
|
+
Alert.alert(response.data.url)
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
)
|
|
270
|
+
```
|
|
271
|
+
|
|
272
|
+
### Notification helper methods
|
|
273
|
+
|
|
274
|
+
#### Disable Selligent Push Notifications
|
|
275
|
+
|
|
276
|
+
You can enable or disable Selligent push notifications (not all push notifications for your app) by calling `Selligent.enableNotifications` anytime you want (do note that for iOS, the first call to this method will prompt the user for the push permission).
|
|
277
|
+
|
|
278
|
+
```javascript
|
|
279
|
+
Selligent.enableNotifications(
|
|
280
|
+
(response) => { // success callback
|
|
281
|
+
},
|
|
282
|
+
(error) => { // error callback
|
|
283
|
+
},
|
|
284
|
+
true
|
|
285
|
+
)
|
|
286
|
+
```
|
|
287
|
+
|
|
288
|
+
#### Display last remote notification
|
|
289
|
+
|
|
290
|
+
If you want to display the last received push notification you can call `Selligent.displayLastReceivedNotification`.
|
|
291
|
+
|
|
292
|
+
```javascript
|
|
293
|
+
Selligent.displayLastReceivedRemotePushNotification()
|
|
294
|
+
```
|
|
295
|
+
|
|
296
|
+
#### Display last remote notification content
|
|
297
|
+
|
|
298
|
+
If you want to display the last received push notification content (usually an inapp message) you can call `Selligent.displayLastReceivedRemotePushNotification`. If the last push didn't have any content attached (just a simple push) then nothing will happen.
|
|
299
|
+
You can optionally pass a `templateId` parameter, which is a string, to specify which template should be used to personalize the styles of the inapp message (if any).
|
|
300
|
+
|
|
301
|
+
```javascript
|
|
302
|
+
Selligent.displayLastReceivedRemotePushNotification(
|
|
303
|
+
(response) => { // success callback
|
|
304
|
+
},
|
|
305
|
+
"some template id" // If you want to use any specific template
|
|
306
|
+
)
|
|
307
|
+
```
|
|
308
|
+
|
|
309
|
+
#### Retrieve last remote notification
|
|
310
|
+
|
|
311
|
+
You can get the last received push notification banner details by calling `Selligent.getLastRemotePushNotification`.
|
|
312
|
+
The response is an object containing the `id`(string) and `title`(string) properties (or `null` if there was nothing to be retrieved).
|
|
313
|
+
|
|
314
|
+
```javascript
|
|
315
|
+
Selligent.getLastRemotePushNotification(
|
|
316
|
+
(response) => { // success callback
|
|
317
|
+
}
|
|
318
|
+
)
|
|
319
|
+
```
|
|
320
|
+
|
|
321
|
+
### Broadcasts
|
|
322
|
+
|
|
323
|
+
You can subscribe to `SelligentConstants.BroadcastEventType.RECEIVED_REMOTE_NOTIFICATION`, `SelligentConstants.BroadcastEventType.WILL_DISPLAY_NOTIFICATION`, `SelligentConstants.BroadcastEventType.WILL_DISMISS_NOTIFICATION` and `SelligentConstants.BroadcastEventType.BUTTON_CLICKED` events through the `Selligent.subscribeToEvents`.
|
|
324
|
+
The response of the success callback is an object which contains information on the type of broadcast event and the data attached to it.
|
|
325
|
+
|
|
326
|
+
| Property | Type | Description |
|
|
327
|
+
| ------------------ | ------------------------------------------------------- | ----------------------------------------------------------------- |
|
|
328
|
+
| broadcastEventType | [enum](#broadcasteventtype) | The type of broadcast event |
|
|
329
|
+
| data | object | Contains more information specific to the type of broadcast event |
|
|
330
|
+
|
|
331
|
+
The `data` property is an object itself containing more information specific to the type of the broadcast event:
|
|
332
|
+
|
|
333
|
+
- RECEIVED_REMOTE_NOTIFICATION:
|
|
334
|
+
|
|
335
|
+
| Property | Type | Description |
|
|
336
|
+
| -------- | ------ | ------------------------------------------ |
|
|
337
|
+
| pushId | string | The id of the remote push notification |
|
|
338
|
+
| name | string | The title of the remote push notification |
|
|
339
|
+
|
|
340
|
+
- WILL_DISPLAY_NOTIFICATION and WILL_DISMISS_NOTIFICATION: the `data` prop is `null`.
|
|
341
|
+
|
|
342
|
+
- BUTTON_CLICKED:
|
|
343
|
+
|
|
344
|
+
| Property | Type | Description |
|
|
345
|
+
| -------- | -------------------------------------------------------------------------- | --------------------------------------- |
|
|
346
|
+
| type | iOS: [enum](#notificationbuttontype) | Tye type of the button (deeplink, url...) |
|
|
347
|
+
| value | string | The value of the button (url value, deeplink value...) |
|
|
348
|
+
| id | string | The internal id of the button |
|
|
349
|
+
| label | string | The label of the button |
|
|
350
|
+
| data | object | Additional data embedded to the button |
|
|
351
|
+
|
|
352
|
+
```javascript
|
|
353
|
+
Selligent.subscribeToEvents(
|
|
354
|
+
() => {},
|
|
355
|
+
() => {},
|
|
356
|
+
(response) => {
|
|
357
|
+
Alert.alert(response.broadcastEventType + ' - ' + JSON.stringify(response.data))
|
|
358
|
+
}
|
|
359
|
+
)
|
|
360
|
+
```
|
|
361
|
+
|
|
362
|
+
## In-App Messages
|
|
363
|
+
|
|
364
|
+
To enable them all you need to do is to set the proper [inAppMessageRefreshType](#inappmessagerefreshtype) value in the `selligent.json`.
|
|
365
|
+
|
|
366
|
+
You can later call the `Selligent.enableInAppMessages` function (if you want) to further optin/optout from the functionality; this function expects an `enabled` parameter that can either be a boolean or an [enum](#inappmessagerefreshtype) value.
|
|
367
|
+
|
|
368
|
+
> On iOS, if you are using the enum variant when calling the `Selligent.enableInAppMessages` method, it will not change the recurrency of the check for new messages but just enable/disable it. The source of truth for the recurrency is the `selligent.json`.
|
|
369
|
+
|
|
370
|
+
```javascript
|
|
371
|
+
// To enable in-app messages
|
|
372
|
+
Selligent.enableInAppMessages(
|
|
373
|
+
(response) => { // success callback
|
|
374
|
+
},
|
|
375
|
+
(error) => { // error callback
|
|
376
|
+
},
|
|
377
|
+
true
|
|
378
|
+
)
|
|
379
|
+
```
|
|
380
|
+
|
|
381
|
+
### Display IAM
|
|
382
|
+
|
|
383
|
+
You can subscribe to `SelligentConstants.BroadcastEventType.RECEIVED_IN_APP_MESSAGE` events through the `Selligent.subscribeToEvents`, to know when new messages are received.
|
|
384
|
+
The response of the success callback is an object which contains information on the type of broadcast event and the data attached to it.
|
|
385
|
+
|
|
386
|
+
| Property | Type | Description |
|
|
387
|
+
| ------------------ | ------------------------------------------------------- | ----------------------------------------------------------------- |
|
|
388
|
+
| broadcastEventType | [enum](#broadcasteventtype) | The type of broadcast event |
|
|
389
|
+
| data | object | Contains more information specific to the type of broadcast event |
|
|
390
|
+
|
|
391
|
+
The `data` property is an object itself containing more information specific to the type of the broadcast event:
|
|
392
|
+
|
|
393
|
+
- RECEIVED_IN_APP_MESSAGE
|
|
394
|
+
|
|
395
|
+
| Property | Type | Description |
|
|
396
|
+
| -------- | ----- | ---------------- |
|
|
397
|
+
| messages | array | List of messages |
|
|
398
|
+
|
|
399
|
+
And the detailed overview for items in the `messages` array is:
|
|
400
|
+
|
|
401
|
+
| Property | Type | Description |
|
|
402
|
+
| -------- | ------ | ------------------ |
|
|
403
|
+
| id | string | Internal id of the message |
|
|
404
|
+
| title | string | Title of the message |
|
|
405
|
+
|
|
406
|
+
```javascript
|
|
407
|
+
Selligent.subscribeToEvents(
|
|
408
|
+
() => {},
|
|
409
|
+
() => {},
|
|
410
|
+
(response) => {
|
|
411
|
+
if (response?.broadcastEventType === SelligentConstants.BroadcastEventType.RECEIVED_IN_APP_MESSAGE) {
|
|
412
|
+
}
|
|
413
|
+
}
|
|
414
|
+
)
|
|
415
|
+
```
|
|
416
|
+
|
|
417
|
+
You can also call `Selligent.getInAppMessages` anywhere in your App to get the list of the currently known IAM.
|
|
418
|
+
|
|
419
|
+
```javascript
|
|
420
|
+
// Get all in app messages
|
|
421
|
+
Selligent.getInAppMessages(
|
|
422
|
+
(response) => { // success callback
|
|
423
|
+
}
|
|
424
|
+
)
|
|
425
|
+
```
|
|
426
|
+
|
|
427
|
+
The response of the success callback is an array of objects which contain the in app message(s) information:
|
|
428
|
+
|
|
429
|
+
| Property | Type | Description |
|
|
430
|
+
| -------------- | ------------------------------------------------------------------------------- | ---------------------------------------------------------- |
|
|
431
|
+
| id | string | Internal id of the IAM |
|
|
432
|
+
| title | string | Title of the IAM |
|
|
433
|
+
| body | string | Body of the IAM |
|
|
434
|
+
| type | [enum](#inappmessagetype) | Type of the IAM |
|
|
435
|
+
| creationDate | number | Creation date of the IAM in unix time |
|
|
436
|
+
| expirationDate | number | Expiration date of the IAM in unix time |
|
|
437
|
+
| receptionDate | number | Reception date of the IAM in unix time |
|
|
438
|
+
| hasBeenSeen | boolean | Indication if the IAM is already seen |
|
|
439
|
+
| buttons | array of objects | Buttons that are linked to the IAM |
|
|
440
|
+
|
|
441
|
+
The `buttons` property is an array of button-objects which contain the information of a button linked to the in app message:
|
|
442
|
+
|
|
443
|
+
| Property | Type | Description | Platform |
|
|
444
|
+
| -------- | ------ | ------------------------------------------ | ------------ |
|
|
445
|
+
| id | string | Id of the button of the in app message | Both |
|
|
446
|
+
| label | string | Label of the button of the in app message | Both |
|
|
447
|
+
| value | string | Value of the button of the in app message | Both |
|
|
448
|
+
| type | number | Type of the button of the in app message | Both |
|
|
449
|
+
|
|
450
|
+
To display any of these messages, you can call `Selligent.displayMessage`:
|
|
451
|
+
|
|
452
|
+
### Selligent.displayMessage
|
|
453
|
+
|
|
454
|
+
Display an IAM based on its `id`, which is a string that needs to be passed to the method with the `messageId` parameter.
|
|
455
|
+
You can optionally pass a `templateId` parameter, which is a string, to specify which template should be used to personalize the styles of the inapp message (if any), this will only be used on iOS.
|
|
456
|
+
|
|
457
|
+
```javascript
|
|
458
|
+
Selligent.displayMessage(
|
|
459
|
+
(response) => { // success callback
|
|
460
|
+
},
|
|
461
|
+
(error) => { // error callback
|
|
462
|
+
},
|
|
463
|
+
"some message id",
|
|
464
|
+
"some template id" // (iOS only) If you want to use any specific template
|
|
465
|
+
)
|
|
466
|
+
```
|
|
467
|
+
|
|
468
|
+
#### IAM Customization - Android
|
|
469
|
+
|
|
470
|
+
On Android, if you want to customize the IAM styles, you can refer to the [native documentation](https://github.com/SelligentMarketingCloud/MobileSDK-Android/tree/master/Documentation#design-customization).
|
|
471
|
+
|
|
472
|
+
#### IAM Customization - iOS
|
|
473
|
+
|
|
474
|
+
On iOS, if you want to customize the IAM styles, you can define the templates, to do so you will need to do it in the native part, in the `UIAppDelegate/didFinishLaunchingWithOptions:` method by calling the `RNSelligent/setInAppMessageStylingTemplates:defaultTemplateId:` method, which expects an array of templates and (optionally) a default template id. If the default template is set, it will be used for all type of in-app messages (when a templateId wasn't provided or couldn't be found) and you will not need to use any specific templateId anywhere around your App.
|
|
475
|
+
|
|
476
|
+
In the other hand, you can also use the native methods `RNSelligent/willPresentNotification:templateId:withCompletionHandler:` and `RNSelligent/didReceiveNotificationResponse:templateId:withCompletionHandler:` if you want to give different styles to the in app messages that are displayed based on a push message.
|
|
477
|
+
|
|
478
|
+
> You can refer to the [native documentation](https://github.com/SelligentMarketingCloud/MobileSDK-iOS/tree/master/Documentation#styling-iam) to know more about all possible customizations that are offered.
|
|
479
|
+
|
|
480
|
+
```objective-c
|
|
481
|
+
@import RNSelligentMobileSDK;
|
|
482
|
+
@import SelligentMobileSDK;
|
|
483
|
+
// OR
|
|
484
|
+
// #import <RNSelligentMobileSDK/RNSelligentMobileSDK-Swift.h>
|
|
485
|
+
// #import <MapKit/MapKit.h>
|
|
486
|
+
// #import <SelligentMobileSDK/SMHelperSwift.h>
|
|
487
|
+
|
|
488
|
+
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
|
|
489
|
+
UNUserNotificationCenter *center = [UNUserNotificationCenter currentNotificationCenter];
|
|
490
|
+
center.delegate = self;
|
|
491
|
+
|
|
492
|
+
// RN Setup code
|
|
493
|
+
|
|
494
|
+
[RNSelligent configureWithLaunchOptions:launchOptions];
|
|
495
|
+
|
|
496
|
+
// Example style templates
|
|
497
|
+
SMInAppMessageStyleOptions* styleOptions = [[SMInAppMessageStyleOptions alloc] init];
|
|
498
|
+
styleOptions.presentWithTransition = true;
|
|
499
|
+
styleOptions.transition = kSMViewTransition_VerticalSlide;
|
|
500
|
+
|
|
501
|
+
InAppMessageStylingTemplate* defaultTemplate = [[InAppMessageStylingTemplate alloc] initWithTemplateId:@"defaultTemplate" styleOptions:styleOptions];
|
|
502
|
+
|
|
503
|
+
SMInAppMessageStyleOptions* styleOptionsUseCase2 = [[SMInAppMessageStyleOptions alloc] init];
|
|
504
|
+
styleOptionsUseCase2.presentWithTransition = true;
|
|
505
|
+
styleOptionsUseCase2.transition = kSMViewTransition_HorizontalSlide;
|
|
506
|
+
|
|
507
|
+
InAppMessageStylingTemplate* templateUseCase2 = [[InAppMessageStylingTemplate alloc] initWithTemplateId:@"usecase2" styleOptions:styleOptionsUseCase2];
|
|
508
|
+
|
|
509
|
+
[RNSelligent setInAppMessageStylingTemplates:@[ defaultTemplate, templateUseCase2 ] defaultTemplateId:@"defaultTemplate"];
|
|
510
|
+
|
|
511
|
+
return YES;
|
|
512
|
+
}
|
|
513
|
+
```
|
|
514
|
+
|
|
515
|
+
### IAM Helper methods
|
|
516
|
+
|
|
517
|
+
If you decide to display the AIM on your own (without `Selligent.displayMessage` and `Selligent.displayNotification`), listening for new messages with the `Selligent.subscribeToEvents` and/or getting the full list with `Selligent.getInAppMessages`. You will be able to build your own layout with the object provided from the mentioned functions and then you can use the helper methods described here to still push KPI statistics to the Selligent platform:
|
|
518
|
+
|
|
519
|
+
- setInAppMessageAsSeen: sets an IAM as seen and sends the corresponding `Opened` event to the Selligent platform
|
|
520
|
+
|
|
521
|
+
```javascript
|
|
522
|
+
Selligent.setInAppMessageAsSeen(
|
|
523
|
+
(response) => { // success callback
|
|
524
|
+
},
|
|
525
|
+
(error) => { // error callback
|
|
526
|
+
},
|
|
527
|
+
"id-of-message"
|
|
528
|
+
)
|
|
529
|
+
```
|
|
530
|
+
|
|
531
|
+
- setInAppMessageAsUnseen: sets an IAM as unseen
|
|
532
|
+
|
|
533
|
+
```javascript
|
|
534
|
+
Selligent.setInAppMessageAsUnseen(
|
|
535
|
+
(response) => { // success callback
|
|
536
|
+
},
|
|
537
|
+
(error) => { // error callback
|
|
538
|
+
},
|
|
539
|
+
"id-of-message"
|
|
540
|
+
)
|
|
541
|
+
```
|
|
542
|
+
|
|
543
|
+
- setInAppMessageAsDeleted: sets an IAM as deleted
|
|
544
|
+
|
|
545
|
+
```javascript
|
|
546
|
+
Selligent.setInAppMessageAsDeleted(
|
|
547
|
+
(response) => { // success callback
|
|
548
|
+
},
|
|
549
|
+
(error) => { // error callback
|
|
550
|
+
},
|
|
551
|
+
"id-of-message"
|
|
552
|
+
)
|
|
553
|
+
```
|
|
554
|
+
|
|
555
|
+
- executeButtonAction: executes the action linked to an IAM button and sends the corresponding `Clicked` event to the Selligent platform
|
|
556
|
+
|
|
557
|
+
```javascript
|
|
558
|
+
Selligent.executeButtonAction(
|
|
559
|
+
(response) => { // success callback
|
|
560
|
+
},
|
|
561
|
+
(error) => { // error callback
|
|
562
|
+
},
|
|
563
|
+
"id-of-button",
|
|
564
|
+
"id-of-message"
|
|
565
|
+
)
|
|
566
|
+
```
|
|
567
|
+
|
|
568
|
+
## Events
|
|
569
|
+
|
|
570
|
+
Sending any set of data to the backend can be done with `Selligent.sendEvent`.
|
|
571
|
+
The method accepts an `event` object which requires certain properties, depending on the type of the event:
|
|
572
|
+
|
|
573
|
+
| Property | Type | Description |
|
|
574
|
+
| ----------- | ------------------------------------- | ---------------- |
|
|
575
|
+
| type | [enum](#eventtype) | The type of event to send |
|
|
576
|
+
| email | string | The email/profile identifier to associated the event to |
|
|
577
|
+
| data | object | Additional data to be passed together with the event |
|
|
578
|
+
|
|
579
|
+
For events of type `SelligentConstants.EventType.CUSTOM` the `data` property is mandatory and the `email` one is not used.
|
|
580
|
+
For the rest of event types, the `email` property is mandatory.
|
|
581
|
+
|
|
582
|
+
```javascript
|
|
583
|
+
Selligent.sendEvent(
|
|
584
|
+
(response) => { // success callback
|
|
585
|
+
},
|
|
586
|
+
(error) => { // error callback
|
|
587
|
+
},
|
|
588
|
+
{
|
|
589
|
+
type: SelligentConstants.EventType.USER_LOGIN,
|
|
590
|
+
data: { // optional
|
|
591
|
+
description: "this is some extra information concerning this event"
|
|
592
|
+
},
|
|
593
|
+
email: "someone@somedomain.com" // required
|
|
594
|
+
}
|
|
595
|
+
)
|
|
596
|
+
Selligent.sendEvent(
|
|
597
|
+
(response) => { // success callback
|
|
598
|
+
},
|
|
599
|
+
(error) => { // error callback
|
|
600
|
+
},
|
|
601
|
+
{
|
|
602
|
+
type: SelligentConstants.EventType.CUSTOM,
|
|
603
|
+
data: { // required
|
|
604
|
+
description: "this is some extra information concerning this event"
|
|
605
|
+
}
|
|
606
|
+
}
|
|
607
|
+
)
|
|
608
|
+
```
|
|
609
|
+
|
|
610
|
+
## Miscellaneous
|
|
611
|
+
|
|
612
|
+
### Get lib version
|
|
613
|
+
|
|
614
|
+
Returns the version of the installed native Selligent SDK (string).
|
|
615
|
+
|
|
616
|
+
```javascript
|
|
617
|
+
Selligent.getVersionLib((versionLib) => {
|
|
618
|
+
})
|
|
619
|
+
```
|
|
620
|
+
|
|
621
|
+
### Get device id
|
|
622
|
+
|
|
623
|
+
Returns the currently known Selligent device Id (string).
|
|
624
|
+
|
|
625
|
+
```javascript
|
|
626
|
+
Selligent.getDeviceId((deviceId) => {
|
|
627
|
+
})
|
|
628
|
+
```
|
|
629
|
+
|
|
630
|
+
You can also subscribe to the `SelligentConstants.BroadcastEventType.RECEIVED_DEVICE_ID` event through the `Selligent.subscribeToEvents`, to know when a new device is received.
|
|
631
|
+
The response of the success callback is an object which contains information on the type of broadcast event and the data attached to it.
|
|
632
|
+
|
|
633
|
+
| Property | Type | Description |
|
|
634
|
+
| ------------------ | ------------------------------------------------------- | ----------------------------------------------------------------- |
|
|
635
|
+
| broadcastEventType | [enum](#broadcasteventtype) | The type of broadcast event |
|
|
636
|
+
| data | object | Contains more information specific to the type of broadcast event |
|
|
637
|
+
|
|
638
|
+
The `data` property is an object itself containing more information specific to the type of the broadcast event:
|
|
639
|
+
|
|
640
|
+
- RECEIVED_DEVICE_ID
|
|
641
|
+
|
|
642
|
+
| Property | Type | Description |
|
|
643
|
+
| -------- | ------ | ------------------------------- |
|
|
644
|
+
| deviceId | string | The Selligent id of the device |
|
|
645
|
+
|
|
646
|
+
### Logging
|
|
647
|
+
|
|
648
|
+
For iOS, you can use `Selligent.enableiOSLogging` passing the desired logLevel.
|
|
649
|
+
|
|
650
|
+
```javascript
|
|
651
|
+
// to enable logging of info, warning and error statements
|
|
652
|
+
Selligent.enableiOSLogging(
|
|
653
|
+
(response) => { // success callback
|
|
654
|
+
},
|
|
655
|
+
(error) => { // error callback
|
|
656
|
+
},
|
|
657
|
+
[Selligent.iOSLogLevel.INFO]
|
|
658
|
+
)
|
|
659
|
+
```
|
|
660
|
+
|
|
661
|
+
For Android, you can use `Selligent.enableAndroidLogging` passing the enabled flag.
|
|
662
|
+
|
|
663
|
+
```javascript
|
|
664
|
+
Selligent.enableAndroidLogging(
|
|
665
|
+
(response) => { // success callback
|
|
666
|
+
},
|
|
667
|
+
(error) => { // error callback
|
|
668
|
+
},
|
|
669
|
+
true
|
|
670
|
+
)
|
|
671
|
+
```
|
|
672
|
+
|
|
673
|
+
### GCM Token - Android
|
|
674
|
+
|
|
675
|
+
To get the current token being used, you can call `Selligent.getGCMToken` which will return it (string).
|
|
676
|
+
|
|
677
|
+
```javascript
|
|
678
|
+
Selligent.getGCMToken(
|
|
679
|
+
(response) => { // success callback
|
|
680
|
+
}
|
|
681
|
+
)
|
|
682
|
+
```
|
|
683
|
+
|
|
684
|
+
To set the token manually (if you integrate with GCM directly and do set `doNotFetchTheToken` property to `true`), you can call `Selligent.setFirebaseToken`
|
|
685
|
+
|
|
686
|
+
```javascript
|
|
687
|
+
Selligent.setFirebaseToken(
|
|
688
|
+
(response) => { // success callback
|
|
689
|
+
},
|
|
690
|
+
(error) => { // error callback
|
|
691
|
+
},
|
|
692
|
+
"token value"
|
|
693
|
+
)
|
|
694
|
+
```
|
|
695
|
+
|
|
696
|
+
You can also subscribe to the `SelligentConstants.BroadcastEventType.RECEIVED_GCM_TOKEN` event through the `Selligent.subscribeToEvents`, to know when a new token is received.
|
|
697
|
+
The response of the success callback is an object which contains information on the type of broadcast event and the data attached to it.
|
|
698
|
+
|
|
699
|
+
| Property | Type | Description |
|
|
700
|
+
| ------------------ | ------------------------------------------------------- | ----------------------------------------------------------------- |
|
|
701
|
+
| broadcastEventType | [enum](#broadcasteventtype) | The type of broadcast event |
|
|
702
|
+
| data | object | Contains more information specific to the type of broadcast event |
|
|
703
|
+
|
|
704
|
+
The `data` property is an object itself containing more information specific to the type of the broadcast event:
|
|
705
|
+
|
|
706
|
+
- RECEIVED_GCM_TOKEN
|
|
707
|
+
|
|
708
|
+
| Property | Type | Description |
|
|
709
|
+
| -------- | ------ | ------------------------------- |
|
|
710
|
+
| token | string | The token attached to the event |
|
|
711
|
+
|
|
712
|
+
## Constants
|
|
713
|
+
|
|
714
|
+
Add the following import to work with the constants:
|
|
715
|
+
|
|
716
|
+
```javascript
|
|
717
|
+
import SelligentConstants from "@selligent-marketing-cloud/selligent-react-native/constants";
|
|
718
|
+
```
|
|
719
|
+
|
|
720
|
+
### ClearCacheIntervalValue
|
|
721
|
+
|
|
722
|
+
Defines the interval value to clear the cache.
|
|
723
|
+
|
|
724
|
+
| Name | Type | Value | Description |
|
|
725
|
+
| ----------- | ------ | ----- | -------------------------------------------- |
|
|
726
|
+
| AUTO | number | 1 | Clear cache automatically (weekly) |
|
|
727
|
+
| NONE | number | 2 | Don't clear cache |
|
|
728
|
+
| DAY | number | 3 | Clear cache daily |
|
|
729
|
+
| WEEK | number | 4 | Clear cache weekly |
|
|
730
|
+
| MONTH | number | 5 | Clear cache monthly |
|
|
731
|
+
| QUARTER | number | 6 | Clear cache quarterly |
|
|
732
|
+
|
|
733
|
+
### InAppMessageType
|
|
734
|
+
|
|
735
|
+
Defines the type of the IAM.
|
|
736
|
+
|
|
737
|
+
| Name | Type | Value | Description |
|
|
738
|
+
| -------- | ------ | ----- | ------------------------------- |
|
|
739
|
+
| UNKNOWN | number | -2 | In App message of unknown type |
|
|
740
|
+
| HIDDEN | number | -1 | In App message of hidden type |
|
|
741
|
+
| ALERT | number | 0 | In App message of alert type |
|
|
742
|
+
| HTML | number | 1 | In App message of html type |
|
|
743
|
+
| URL | number | 2 | In App message of url type |
|
|
744
|
+
| IMAGE | number | 3 | In App message of image type |
|
|
745
|
+
| MAP | number | 4 | In App message of map type |
|
|
746
|
+
| PASSBOOK | number | 5 | In App message of passbook type |
|
|
747
|
+
|
|
748
|
+
### InAppMessageRefreshType
|
|
749
|
+
|
|
750
|
+
Defines how often the SDK must retrieve the IAM.
|
|
751
|
+
|
|
752
|
+
| Name | Type | Value | Description |
|
|
753
|
+
| -------------- | ------ | ----- | ---------------------------------- |
|
|
754
|
+
| NONE | number | 10 | Don't fetch the IAM |
|
|
755
|
+
| MINUTE | number | 11 | Refresh minutely (do not set this for production builds) |
|
|
756
|
+
| HOUR | number | 12 | Refresh hourly |
|
|
757
|
+
| DAY | number | 13 | Refresh weekly |
|
|
758
|
+
|
|
759
|
+
### RemoteMessagesDisplayType
|
|
760
|
+
|
|
761
|
+
Defines if and how remote messages must be displayed when the App is in foreground.
|
|
762
|
+
|
|
763
|
+
| Name | Type | Value | Description |
|
|
764
|
+
| ------------ | ------ | ----- | --------------------------------------- |
|
|
765
|
+
| AUTOMATIC | number | 20 | Display the IAM (if any) linked to the push, directly |
|
|
766
|
+
| NONE | number | 21 | Don't display anything |
|
|
767
|
+
| NOTIFICATION | number | 22 | Display the push notification banner (default behaviour) |
|
|
768
|
+
|
|
769
|
+
### iOSLogLevel
|
|
770
|
+
|
|
771
|
+
Defines the level of output of logging messages on iOS.
|
|
772
|
+
|
|
773
|
+
| Name | Type | Value | Description |
|
|
774
|
+
| --------- | ------ | ----- | ----------------- |
|
|
775
|
+
| NONE | number | 50 | Output nothing |
|
|
776
|
+
| INFO | number | 51 | Output info |
|
|
777
|
+
| WARNING | number | 52 | Output warning |
|
|
778
|
+
| ERROR | number | 53 | Output error |
|
|
779
|
+
| HTTP_CALL | number | 54 | Output http calls |
|
|
780
|
+
| ALL | number | 56 | Output all |
|
|
781
|
+
|
|
782
|
+
### EventType
|
|
783
|
+
|
|
784
|
+
Defines the type of an event.
|
|
785
|
+
|
|
786
|
+
| Name | Type | Value | Description |
|
|
787
|
+
| --------------- | ------ | ----- | ----------------- |
|
|
788
|
+
| USER_REGISTER | number | 90 | Used to send a register event to the server with the custom email/profile identifier of the user, with the purpose of linking the device to an user and optionally storing some data at Selligent platform side. This event will create a new user in your Selligent database, if none was found (you can use an alternate key/value field to search for the user, in the data object, since by default the `email` one will use the `MAIL` column in your Selligent database). |
|
|
789
|
+
| USER_UNREGISTER | number | 91 | Used to send an unregister event to the server with the custom email/profile identifier of the user, with the purpose of keeping track of a REGISTERED flag and optionally storing some data at Selligent platform side (this event is not unlinking the user from the device (automatically), at the moment). |
|
|
790
|
+
| USER_LOGIN | number | 92 | Used to send a login event to the server with the custom email/profile identifier of the user, with the purpose of linking the device to an user and optionally storing some data at Selligent platform side. This event will **NOT** create a new user in your Selligent database, if none found. |
|
|
791
|
+
| USER_LOGOUT | number | 93 | UUsed to send a logout event to the server with the custom email/profile identifier of the user, with the purpose of keeping track of a LOGGED flag and optionally storing some data at Selligent platform side (this event is not unlinking the user from the device (automatically), at the moment). |
|
|
792
|
+
| CUSTOM | number | 94 | Used to send a custom event to the server, with the purpose of keeping track of storing some data at Selligent platform side. |
|
|
793
|
+
|
|
794
|
+
### NotificationButtonType
|
|
795
|
+
|
|
796
|
+
Defines the type of buttons for notifications or inapp messages.
|
|
797
|
+
|
|
798
|
+
| Name | Type | Value | Description |
|
|
799
|
+
| ----------------------------- | ------ | ----- | ----------------------------------------- |
|
|
800
|
+
| UNKNOWN | number | 100 | Unknown button type |
|
|
801
|
+
| SIMPLE_OPEN_PHONE_CALL | number | 101 | Opens a phone call dialog |
|
|
802
|
+
| OPEN_SMS | number | 102 | Opens a new sms dialog |
|
|
803
|
+
| OPEN_MAIL | number | 103 | Opens a new email dialog |
|
|
804
|
+
| OPEN_BROWSER | number | 104 | Opens an URL in the default device's browser |
|
|
805
|
+
| OPEN_APPLICATION | number | 105 | Opens an external App |
|
|
806
|
+
| RATE_APPLICATION | number | 106 | Opens a 'rate this app' dialog |
|
|
807
|
+
| CUSTOM_ACTION_BROADCAST_EVENT | number | 107 | Sends a custom broadcast to the App |
|
|
808
|
+
| PASSBOOK | number | 111 | Opens a passbook URL |
|
|
809
|
+
| DEEPLINK | number | 112 | Executes a deeplink |
|
|
810
|
+
| SIMPLE | number | 113 | Nothing done except forwarding the corresponding `Clicked` event to the Selligent platform |
|
|
811
|
+
|
|
812
|
+
### BroadcastEventType
|
|
813
|
+
|
|
814
|
+
Defines the type of a broadcast event.
|
|
815
|
+
|
|
816
|
+
| Name | Type | Value | Description |
|
|
817
|
+
| -------------------------------- | ------ | -------------------------- | ----------------------------------------------------- |
|
|
818
|
+
| BUTTON_CLICKED | string | ButtonClicked | A button was clicked |
|
|
819
|
+
| RECEIVED_IN_APP_MESSAGE | string | ReceivedInAppMessage | An IAM has been received |
|
|
820
|
+
| WILL_DISPLAY_NOTIFICATION | string | WillDisplayNotification | A notification will be displayed |
|
|
821
|
+
| WILL_DISMISS_NOTIFICATION | string | WillDismissNotification | A notification will be dismissed |
|
|
822
|
+
| RECEIVED_DEVICE_ID | string | ReceivedDeviceId | A device id has been received |
|
|
823
|
+
| Android.RECEIVED_GCM_TOKEN | string | ReceivedGCMToken | A GCM token has been received (only on Android) |
|
|
824
|
+
| RECEIVED_REMOTE_NOTIFICATION | string | ReceivedRemoteNotification | A remote notification has been received |
|
|
825
|
+
| iOS.UNIVERSAL_LINK_EXECUTED | string | UniversalLinkExecuted | An universal link has been executed |
|
|
826
|
+
| TRIGGERED_CUSTOM_EVENT | string | TriggeredCustomEvent | A custom event has been triggered |
|