diff --git a/CHANGELOG.md b/CHANGELOG.md index 6a5a946..6826a3c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,24 @@ All notable changes to this project will be documented in this file. +## [0.12.0] - 2023-03-27 + +### Fixed +- Voucher objects mapping. + +### Changed +- `Token` object structure. +- Update of native SDK's dependencies. +- Improvements to stability. + +### Added +- In-app messaging support. + +### Removed +- `Injector.fetchBanners` method. +- `Injector.getBanners` method. +- `Injector.showBanner` method. + ## [0.11.0] - 2023-02-07 ### Fixed diff --git a/android/build.gradle b/android/build.gradle index dc23479..275ecd1 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -2,10 +2,10 @@ apply plugin: 'com.android.library' ext.versions = [ 'minSdk' : 21, - 'compileSdk' : 31, - 'targetSdk' : 31, - 'versionCode': 23, - 'versionName': "0.11.0" + 'compileSdk' : 33, + 'targetSdk' : 33, + 'versionCode': 24, + 'versionName': "0.12.0" ] buildscript { @@ -23,11 +23,11 @@ buildscript { } android { - compileSdkVersion 31 + compileSdkVersion 33 defaultConfig { minSdkVersion 21 - targetSdkVersion 31 + targetSdkVersion 33 versionCode 1 versionName "1.0" } @@ -57,7 +57,7 @@ repositories { dependencies { implementation 'com.facebook.react:react-native:+' implementation "com.squareup.okhttp3:logging-interceptor:4.9.1" - api 'com.synerise.sdk:synerise-mobile-sdk:4.6.2' + api 'com.synerise.sdk:synerise-mobile-sdk:5.0.1' } //apply from: 'publish.gradle' \ No newline at end of file diff --git a/android/src/main/java/com/synerise/sdk/react/RNInjector.java b/android/src/main/java/com/synerise/sdk/react/RNInjector.java index 3a76cf6..9e6abd3 100644 --- a/android/src/main/java/com/synerise/sdk/react/RNInjector.java +++ b/android/src/main/java/com/synerise/sdk/react/RNInjector.java @@ -1,5 +1,7 @@ package com.synerise.sdk.react; +import android.util.Log; + import com.facebook.react.bridge.Arguments; import com.facebook.react.bridge.Callback; import com.facebook.react.bridge.ReactApplicationContext; @@ -15,9 +17,12 @@ import com.synerise.sdk.injector.callback.OnBannerListener; import com.synerise.sdk.injector.callback.OnInjectorListener; import com.synerise.sdk.injector.callback.OnWalkthroughListener; +import com.synerise.sdk.injector.inapp.InAppMessageData; +import com.synerise.sdk.injector.inapp.OnInAppListener; import com.synerise.sdk.injector.net.model.inject.walkthrough.WalkthroughResponse; import com.synerise.sdk.injector.net.model.push.banner.TemplateBanner; import com.synerise.sdk.injector.ui.handler.InjectorActionHandler; +import com.synerise.sdk.react.utils.MapUtil; import org.json.JSONException; import org.json.JSONObject; @@ -32,24 +37,34 @@ public class RNInjector extends RNBaseModule { private static ReactApplicationContext reactApplicationContext; - private static String URL = "url"; - private static String OPEN_URL_KEY = "URL_ACTION_LISTENER_KEY"; - private static String DEEP_LINK_KEY = "DEEPLINK_ACTION_LISTENER_KEY"; - private static String OPEN_URL_VALUE = "openUrl"; - private static String DEEP_LINK = "deepLink"; - private static String DEEP_LINK_VALUE = "deepLink"; - private static String BANNER_PRESENTED_KEY = "BANNER_PRESENTED_LISTENER_KEY"; - private static String BANNER_HIDDEN_KEY = "BANNER_HIDDEN_LISTENER_KEY"; - private static String BANNER_PRESENTED_VALUE = "bannerPresented"; - private static String BANNER_HIDDEN_VALUE = "bannerClosed"; - private static String WALKTHROUGH_LOADING_ERROR_KEY = "WALKTHROUGH_LOADING_ERROR_LISTENER_KEY"; - private static String WALKTHROUGH_LOADING_ERROR_VALUE = "walkthroughLoadingError"; - private static String WALKTHROUGH_LOADED_KEY = "WALKTHROUGH_LOADED_LISTENER_KEY"; - private static String WALKTHROUGH_LOADED_VALUE = "walkthroughLoaded"; - private static String WALKTHROUGH_PRESENTED_KEY = "WALKTHROUGH_PRESENTED_LISTENER_KEY"; - private static String WALKTHROUGH_PRESENTED_VALUE = "walkthroughPresented"; - private static String WALKTHROUGH_HIDDEN_KEY = "WALKTHROUGH_HIDDEN_LISTENER_KEY"; - private static String WALKTHROUGH_HIDDEN_VALUE = "walkthroughHidden"; + private static final String URL = "url"; + private static final String OPEN_URL_KEY = "URL_ACTION_LISTENER_KEY"; + private static final String DEEP_LINK_KEY = "DEEPLINK_ACTION_LISTENER_KEY"; + private static final String OPEN_URL_VALUE = "openUrl"; + private static final String DEEP_LINK = "deepLink"; + private static final String DEEP_LINK_VALUE = "deepLink"; + private static final String BANNER_PRESENTED_KEY = "BANNER_PRESENTED_LISTENER_KEY"; + private static final String BANNER_HIDDEN_KEY = "BANNER_HIDDEN_LISTENER_KEY"; + private static final String BANNER_PRESENTED_VALUE = "bannerPresented"; + private static final String BANNER_HIDDEN_VALUE = "bannerClosed"; + private static final String WALKTHROUGH_LOADING_ERROR_KEY = "WALKTHROUGH_LOADING_ERROR_LISTENER_KEY"; + private static final String WALKTHROUGH_LOADING_ERROR_VALUE = "walkthroughLoadingError"; + private static final String WALKTHROUGH_LOADED_KEY = "WALKTHROUGH_LOADED_LISTENER_KEY"; + private static final String WALKTHROUGH_LOADED_VALUE = "walkthroughLoaded"; + private static final String WALKTHROUGH_PRESENTED_KEY = "WALKTHROUGH_PRESENTED_LISTENER_KEY"; + private static final String WALKTHROUGH_PRESENTED_VALUE = "walkthroughPresented"; + private static final String WALKTHROUGH_HIDDEN_KEY = "WALKTHROUGH_HIDDEN_LISTENER_KEY"; + private static final String WALKTHROUGH_HIDDEN_VALUE = "walkthroughHidden"; + private static final String IN_APP_MESSAGE_PRESENTED_LISTENER_KEY = "IN_APP_MESSAGE_PRESENTED_LISTENER_KEY"; + private static final String IN_APP_MESSAGE_HIDDEN_LISTENER_KEY = "IN_APP_MESSAGE_HIDDEN_LISTENER_KEY"; + private static final String IN_APP_MESSAGE_URL_ACTION_LISTENER_KEY = "IN_APP_MESSAGE_URL_ACTION_LISTENER_KEY"; + private static final String IN_APP_MESSAGE_DEEPLINK_ACTION_LISTENER_KEY = "IN_APP_MESSAGE_DEEPLINK_ACTION_LISTENER_KEY"; + private static final String IN_APP_MESSAGE_CUSTOM_ACTION_LISTENER_KEY = "IN_APP_MESSAGE_CUSTOM_ACTION_LISTENER_KEY"; + private static final String IN_APP_MESSAGE_PRESENTED_LISTENER_VALUE = "inAppPresented"; + private static final String IN_APP_MESSAGE_HIDDEN_LISTENER_VALUE = "inAppHidden"; + private static final String IN_APP_MESSAGE_URL_ACTION_LISTENER_VALUE = "inAppUrlAction"; + private static final String IN_APP_MESSAGE_DEEPLINK_ACTION_LISTENER_VALUE = "inAppDeepLinkAction"; + private static final String IN_APP_MESSAGE_CUSTOM_ACTION_LISTENER_VALUE = "inAppCustomAction"; private static Boolean shouldBannerPresentFlag = false; private Gson gson = new Gson(); @@ -79,56 +94,8 @@ public boolean isLoadedWalkthroughUnique() { } @ReactMethod - public void setShouldBannerPresentFlag(Boolean shouldBannerPresentFlag) { - this.shouldBannerPresentFlag = shouldBannerPresentFlag; - } - - @ReactMethod - public void fetchBanners(Callback callback) { - Injector.fetchBanners(new DataActionListener>() { - @Override - public void onDataAction(List templateBanners) { - WritableArray array = Arguments.createArray(); - for (TemplateBanner banner : templateBanners) { - try { - String jsonObject = gson.toJson(banner); - WritableMap objectMap = convertJsonToMap(new JSONObject(jsonObject)); - array.pushMap(objectMap); - } catch (JSONException e) { - e.printStackTrace(); - } - } - executeSuccessCallbackResponse(callback, array, null); - } - }, new DataActionListener() { - @Override - public void onDataAction(ApiError apiError) { - executeFailureCallbackResponse(callback, null, apiError); - } - }); - } - - @ReactMethod(isBlockingSynchronousMethod = true) - public WritableArray getBanners() { - List bannerList = Injector.getBanners(); - WritableArray array = Arguments.createArray(); - for (TemplateBanner banner : bannerList) { - try { - String jsonObject = gson.toJson(banner); - WritableMap objectMap = convertJsonToMap(new JSONObject(jsonObject)); - array.pushMap(objectMap); - } catch (JSONException e) { - e.printStackTrace(); - } - } - return array; - } - - @ReactMethod - public void showBanner(ReadableMap bannerObject, Boolean markPresented) { - String bannerJson = readableMapToJson(bannerObject); - TemplateBanner banner = TemplateBanner.fromJson(bannerJson, new Gson()); - Injector.showBanner(banner, markPresented); + public void setBannerShouldPresentFlag(boolean flag) { + shouldBannerPresentFlag = flag; } @Nullable @@ -143,6 +110,11 @@ public Map getConstants() { constants.put(WALKTHROUGH_PRESENTED_KEY, WALKTHROUGH_PRESENTED_VALUE); constants.put(WALKTHROUGH_LOADED_KEY, WALKTHROUGH_LOADED_VALUE); constants.put(WALKTHROUGH_HIDDEN_KEY, WALKTHROUGH_HIDDEN_VALUE); + constants.put(IN_APP_MESSAGE_PRESENTED_LISTENER_KEY, IN_APP_MESSAGE_PRESENTED_LISTENER_VALUE); + constants.put(IN_APP_MESSAGE_HIDDEN_LISTENER_KEY, IN_APP_MESSAGE_HIDDEN_LISTENER_VALUE); + constants.put(IN_APP_MESSAGE_URL_ACTION_LISTENER_KEY, IN_APP_MESSAGE_URL_ACTION_LISTENER_VALUE); + constants.put(IN_APP_MESSAGE_DEEPLINK_ACTION_LISTENER_KEY, IN_APP_MESSAGE_DEEPLINK_ACTION_LISTENER_VALUE); + constants.put(IN_APP_MESSAGE_CUSTOM_ACTION_LISTENER_KEY, IN_APP_MESSAGE_CUSTOM_ACTION_LISTENER_VALUE); return constants; } @@ -153,6 +125,7 @@ public String getName() { } protected static void initializeInjector() { + initializeInAppListener(); initializeActionInjectorListener(); initializeBannerListener(); initializeWalkthroughListener(); @@ -186,6 +159,99 @@ public boolean onDeepLink(InjectorSource injectorSource, String deepLink) { }); } + private static void initializeInAppListener() { + Injector.setOnInAppListener(new OnInAppListener() { + @Override + public boolean shouldShow(InAppMessageData inAppMessageData) { + return true; + } + + @Override + public void onShown(InAppMessageData inAppMessageData) { + onInAppPresented(inAppMessageData); + } + + @Override + public void onDismissed(InAppMessageData inAppMessageData) { + onInAppHidden(inAppMessageData); + } + + @Override + public void onHandledOpenUrl(InAppMessageData inAppMessageData) { + onInAppMessageOpenUrl(inAppMessageData); + } + + @Override + public void onHandledOpenDeepLink(InAppMessageData inAppMessageData) { + onInAppMessageDeepLink(inAppMessageData); + } + + @Override + public HashMap onContextFromAppRequired(InAppMessageData inAppMessageData) { + return null; + } + + @Override + public void onCustomAction(String identifier, HashMap params, InAppMessageData inAppMessageData) { + onInAppCustomAction(identifier, params, inAppMessageData); + } + }); + } + + private static void onInAppPresented(InAppMessageData inAppMessageData) { + WritableMap objectToJs = Arguments.createMap(); + WritableMap data = Arguments.createMap(); + data.putString("campaignHash", inAppMessageData.getCampaignHash()); + data.putString("variantIdentifier", inAppMessageData.getVariantId()); + data.putMap("additionalParameters", MapUtil.toWritableMap(inAppMessageData.getAdditionalParameters())); + objectToJs.putMap("data", data); + sendEventToJs(IN_APP_MESSAGE_PRESENTED_LISTENER_VALUE, objectToJs, reactApplicationContext); + } + + private static void onInAppHidden(InAppMessageData inAppMessageData) { + WritableMap objectToJs = Arguments.createMap(); + WritableMap data = Arguments.createMap(); + data.putString("campaignHash", inAppMessageData.getCampaignHash()); + data.putString("variantIdentifier", inAppMessageData.getVariantId()); + data.putMap("additionalParameters", MapUtil.toWritableMap(inAppMessageData.getAdditionalParameters())); + objectToJs.putMap("data", data); + sendEventToJs(IN_APP_MESSAGE_HIDDEN_LISTENER_VALUE, objectToJs, reactApplicationContext); + } + + private static void onInAppMessageOpenUrl(InAppMessageData inAppMessageData) { + WritableMap objectToJs = Arguments.createMap(); + WritableMap data = Arguments.createMap(); + data.putString("campaignHash", inAppMessageData.getCampaignHash()); + data.putString("variantIdentifier", inAppMessageData.getVariantId()); + data.putMap("additionalParameters", MapUtil.toWritableMap(inAppMessageData.getAdditionalParameters())); + objectToJs.putMap("data", data); + objectToJs.putString("url", inAppMessageData.getUrl()); + sendEventToJs(IN_APP_MESSAGE_URL_ACTION_LISTENER_VALUE, objectToJs, reactApplicationContext); + } + + private static void onInAppMessageDeepLink(InAppMessageData inAppMessageData) { + WritableMap objectToJs = Arguments.createMap(); + WritableMap data = Arguments.createMap(); + data.putString("campaignHash", inAppMessageData.getCampaignHash()); + data.putString("variantIdentifier", inAppMessageData.getVariantId()); + data.putMap("additionalParameters", MapUtil.toWritableMap(inAppMessageData.getAdditionalParameters())); + objectToJs.putMap("data", data); + objectToJs.putString("deepLink", inAppMessageData.getDeepLink()); + sendEventToJs(IN_APP_MESSAGE_DEEPLINK_ACTION_LISTENER_VALUE, objectToJs, reactApplicationContext); + } + + private static void onInAppCustomAction(String identifier, HashMap params, InAppMessageData inAppMessageData) { + WritableMap objectToJs = Arguments.createMap(); + WritableMap data = Arguments.createMap(); + data.putString("campaignHash", inAppMessageData.getCampaignHash()); + data.putString("variantIdentifier", inAppMessageData.getVariantId()); + data.putMap("additionalParameters", MapUtil.toWritableMap(inAppMessageData.getAdditionalParameters())); + objectToJs.putMap("data", objectToJs); + objectToJs.putString("name", identifier); + objectToJs.putMap("parameters", MapUtil.toWritableMap(params)); + sendEventToJs(IN_APP_MESSAGE_CUSTOM_ACTION_LISTENER_VALUE, objectToJs, reactApplicationContext); + } + private static void initializeBannerListener() { Injector.setOnBannerListener(new OnBannerListener() { diff --git a/android/src/main/java/com/synerise/sdk/react/RNSettings.java b/android/src/main/java/com/synerise/sdk/react/RNSettings.java index e597ad8..7b0e765 100644 --- a/android/src/main/java/com/synerise/sdk/react/RNSettings.java +++ b/android/src/main/java/com/synerise/sdk/react/RNSettings.java @@ -1,5 +1,7 @@ package com.synerise.sdk.react; +import android.util.Log; + import com.facebook.react.bridge.Arguments; import com.facebook.react.bridge.ReactApplicationContext; import com.facebook.react.bridge.ReactMethod; @@ -28,6 +30,8 @@ public class RNSettings extends RNBaseModule { public static final String RN_SETTINGS_NOTIFICATIONS_ENABLED = "NOTIFICATIONS_ENABLED"; public static final String RN_SETTINGS_NOTIFICATIONS_ENCRYPTION = "NOTIFICATIONS_ENCRYPTION"; public static final String RN_SETTINGS_INJECTOR_AUTOMATIC = "INJECTOR_AUTOMATIC"; + public static final String RN_SETTINGS_IN_APP_MAX_DEFINITION_UPDATE_INTERVAL_LIMIT = "IN_APP_MAX_DEFINITION_UPDATE_INTERVAL_LIMIT"; + public static final String RN_SETTINGS_IN_APP_MESSAGING_RENDERING_TIMEOUT = "IN_APP_MESSAGING_RENDERING_TIMEOUT"; public RNSettings(ReactApplicationContext reactApplicationContext) { super(reactApplicationContext); @@ -53,6 +57,8 @@ public Map getConstants() { constants.put(RN_SETTINGS_NOTIFICATIONS_ENABLED, RN_SETTINGS_NOTIFICATIONS_ENABLED); constants.put(RN_SETTINGS_NOTIFICATIONS_ENCRYPTION, RN_SETTINGS_NOTIFICATIONS_ENCRYPTION); constants.put(RN_SETTINGS_SHOULD_DESTROY_SESSION_ON_API_KEY_CHANGE, RN_SETTINGS_SHOULD_DESTROY_SESSION_ON_API_KEY_CHANGE); + constants.put(RN_SETTINGS_IN_APP_MAX_DEFINITION_UPDATE_INTERVAL_LIMIT, RN_SETTINGS_IN_APP_MAX_DEFINITION_UPDATE_INTERVAL_LIMIT); + constants.put(RN_SETTINGS_IN_APP_MESSAGING_RENDERING_TIMEOUT, RN_SETTINGS_IN_APP_MESSAGING_RENDERING_TIMEOUT); return constants; } @@ -123,7 +129,7 @@ private void matchSetting(String key, Object value) { } case RN_SETTINGS_TRACKER_AUTO_FLUSH_TIMEOUT: if (value instanceof Integer) { - Settings.getInstance().tracker.setAutoFlushTimeout((int) value); + Settings.getInstance().tracker.setAutoFlushTimeout(((int) value) * 1000); } break; case RN_SETTINGS_TRACKER_MAX_BATCH_SIZE: @@ -156,6 +162,15 @@ private void matchSetting(String key, Object value) { Settings.getInstance().sdk.shouldDestroySessionOnApiKeyChange = (Boolean) value; } break; + case RN_SETTINGS_IN_APP_MAX_DEFINITION_UPDATE_INTERVAL_LIMIT: + if (value instanceof Integer) { + Settings.getInstance().inAppMessaging.setMaxDefinitionUpdateIntervalLimit((int) value); + } + + case RN_SETTINGS_IN_APP_MESSAGING_RENDERING_TIMEOUT: + if (value instanceof Integer) { + Settings.getInstance().inAppMessaging.renderingTimeout = ((int) value) * 1000; + } } } @@ -166,11 +181,13 @@ private Map settingsDictionary() { settings.put(RN_SETTINGS_TRACKER_IS_BACKEND_TIME_SYNC_REQUIRED, Synerise.settings.tracker.isBackendTimeSyncRequired); settings.put(RN_SETTINGS_TRACKER_MIN_BATCH_SIZE, Synerise.settings.tracker.minBatchSize); settings.put(RN_SETTINGS_TRACKER_MAX_BATCH_SIZE, Synerise.settings.tracker.maxBatchSize); - settings.put(RN_SETTINGS_TRACKER_AUTO_FLUSH_TIMEOUT, Synerise.settings.tracker.autoFlushTimeout); + settings.put(RN_SETTINGS_TRACKER_AUTO_FLUSH_TIMEOUT, Synerise.settings.tracker.autoFlushTimeout / 1000); settings.put(RN_SETTINGS_INJECTOR_AUTOMATIC, Synerise.settings.injector.automatic); settings.put(RN_SETTINGS_NOTIFICATIONS_ENABLED, Synerise.settings.notifications.enabled); settings.put(RN_SETTINGS_NOTIFICATIONS_ENCRYPTION, Synerise.settings.notifications.getEncryption()); settings.put(RN_SETTINGS_SHOULD_DESTROY_SESSION_ON_API_KEY_CHANGE, Synerise.settings.sdk.shouldDestroySessionOnApiKeyChange); + settings.put(RN_SETTINGS_IN_APP_MESSAGING_RENDERING_TIMEOUT, Synerise.settings.inAppMessaging.renderingTimeout / 1000); + settings.put(RN_SETTINGS_IN_APP_MAX_DEFINITION_UPDATE_INTERVAL_LIMIT, Synerise.settings.inAppMessaging.getMaxDefinitionUpdateIntervalLimit()); return settings; } } diff --git a/android/src/main/java/com/synerise/sdk/react/RNSyneriseInitializer.java b/android/src/main/java/com/synerise/sdk/react/RNSyneriseInitializer.java index 273c19a..d4efdf1 100644 --- a/android/src/main/java/com/synerise/sdk/react/RNSyneriseInitializer.java +++ b/android/src/main/java/com/synerise/sdk/react/RNSyneriseInitializer.java @@ -3,6 +3,7 @@ import android.app.Application; import android.content.Context; import android.content.pm.ApplicationInfo; + import com.synerise.sdk.core.Synerise; import com.synerise.sdk.core.types.enums.HostApplicationType; @@ -26,6 +27,7 @@ public void initialize(Application app) { .hostApplicationType(HostApplicationType.REACT_NATIVE) .build(); +// Client.registerForPushCallback(RNNotifications.getNativePushListener()); isInitialized = true; } } diff --git a/android/src/main/java/com/synerise/sdk/react/RNTracker.java b/android/src/main/java/com/synerise/sdk/react/RNTracker.java index 83ed20a..cd6339d 100644 --- a/android/src/main/java/com/synerise/sdk/react/RNTracker.java +++ b/android/src/main/java/com/synerise/sdk/react/RNTracker.java @@ -42,7 +42,7 @@ public void setCustomEmail(String email) { //send(event: Event) @ReactMethod public void send(ReadableMap map) { - String type = map.getString("type"); + String type = "custom"; String action = null; if (map.getType("action") != ReadableType.Null) { action = map.getString("action"); diff --git a/ios/ReactNativeSynerise.xcodeproj/project.pbxproj b/ios/ReactNativeSynerise.xcodeproj/project.pbxproj index 504e8da..c91389d 100644 --- a/ios/ReactNativeSynerise.xcodeproj/project.pbxproj +++ b/ios/ReactNativeSynerise.xcodeproj/project.pbxproj @@ -100,7 +100,6 @@ children = ( 6F17D06023756C4F00D725AE /* ReactNativeSynerise.h */, 6FCFFCEE2384347500EBD863 /* Categories */, - FFB8DEA227A9405800E70EBB /* Classes */, 6F17D06123756C4F00D725AE /* Main */, 6F17D06423756C4F00D725AE /* Modules */, ); @@ -156,13 +155,6 @@ path = Categories; sourceTree = ""; }; - FFB8DEA227A9405800E70EBB /* Classes */ = { - isa = PBXGroup; - children = ( - ); - path = Classes; - sourceTree = ""; - }; /* End PBXGroup section */ /* Begin PBXNativeTarget section */ diff --git a/ios/ReactNativeSynerise.xcodeproj/project.xcworkspace/xcuserdata/kurzy.xcuserdatad/UserInterfaceState.xcuserstate b/ios/ReactNativeSynerise.xcodeproj/project.xcworkspace/xcuserdata/kurzy.xcuserdatad/UserInterfaceState.xcuserstate index 2e34e78..0cfaabe 100644 Binary files a/ios/ReactNativeSynerise.xcodeproj/project.xcworkspace/xcuserdata/kurzy.xcuserdatad/UserInterfaceState.xcuserstate and b/ios/ReactNativeSynerise.xcodeproj/project.xcworkspace/xcuserdata/kurzy.xcuserdatad/UserInterfaceState.xcuserstate differ diff --git a/ios/ReactNativeSynerise/Main/RNSyneriseEventEmitter.m b/ios/ReactNativeSynerise/Main/RNSyneriseEventEmitter.m index a2d49e5..15706e9 100644 --- a/ios/ReactNativeSynerise/Main/RNSyneriseEventEmitter.m +++ b/ios/ReactNativeSynerise/Main/RNSyneriseEventEmitter.m @@ -27,6 +27,11 @@ @implementation RNSyneriseEventEmitter kRNSyneriseWalkthroughLoadingErrorEvent, kRNSyneriseWalkthroughPresentedEvent, kRNSyneriseWalkthroughHiddenEvent, + kRNSyneriseInAppMessagePresentedKey, + kRNSyneriseInAppMessageHiddenKey, + kRNSyneriseInAppMessageUrlActionKey, + kRNSyneriseInAppMessageDeeplinkActionKey, + kRNSyneriseInAppMessageCustomActionKey, kRNSyneriseClientIsSignedInEvent, kRNSyneriseClientIsSignedOutEvent ]; @@ -42,6 +47,7 @@ - (void)startObserving { [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(sendEventToJSWithNotification:) name:kRNSyneriseUrlActionEvent object:nil]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(sendEventToJSWithNotification:) name:kRNSyneriseDeepLinkActionEvent object:nil]; + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(sendEventToJSWithNotification:) name:kRNSyneriseBannerPresentedEvent object:nil]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(sendEventToJSWithNotification:) name:kRNSyneriseBannerHiddenEvent object:nil]; @@ -50,6 +56,12 @@ - (void)startObserving { [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(sendEventToJSWithNotification:) name:kRNSyneriseWalkthroughPresentedEvent object:nil]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(sendEventToJSWithNotification:) name:kRNSyneriseWalkthroughHiddenEvent object:nil]; + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(sendEventToJSWithNotification:) name:kRNSyneriseInAppMessagePresentedKey object:nil]; + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(sendEventToJSWithNotification:) name:kRNSyneriseInAppMessageHiddenKey object:nil]; + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(sendEventToJSWithNotification:) name:kRNSyneriseInAppMessageUrlActionKey object:nil]; + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(sendEventToJSWithNotification:) name:kRNSyneriseInAppMessageDeeplinkActionKey object:nil]; + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(sendEventToJSWithNotification:) name:kRNSyneriseInAppMessageCustomActionKey object:nil]; + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(sendEventToJSWithNotification:) name:kRNSyneriseClientIsSignedInEvent object:nil]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(sendEventToJSWithNotification:) name:kRNSyneriseClientIsSignedOutEvent object:nil]; } diff --git a/ios/ReactNativeSynerise/Modules/RNClient.m b/ios/ReactNativeSynerise/Modules/RNClient.m index f5765dc..51fb561 100644 --- a/ios/ReactNativeSynerise/Modules/RNClient.m +++ b/ios/ReactNativeSynerise/Modules/RNClient.m @@ -11,8 +11,6 @@ static NSString * const RNClientEventListenerClientIsSignedInKey = @"CLIENT_SIGNED_IN_LISTENER_KEY"; static NSString * const RNClientEventListenerClientIsSignedOutKey = @"CLIENT_SIGNED_OUT_LISTENER_KEY"; -static NSString * const RNClientEventObjectReasonKey = @"reason"; - NS_ASSUME_NONNULL_BEGIN @interface RNClient () @@ -50,8 +48,10 @@ - (void)sendClientIsSignedInToJS { } - (void)sendClientIsSignedOutToJS:(SNRClientSessionEndReason)reason { - id eventBody = [self dictionaryWithClientSessionEndReason:reason]; - [[NSNotificationCenter defaultCenter] postNotificationName:kRNSyneriseClientIsSignedOutEvent object:nil userInfo:eventBody]; + NSDictionary *userInfo = @{ + @"reason": [self stringWithClientSessionEndReason:reason] + }; + [[NSNotificationCenter defaultCenter] postNotificationName:kRNSyneriseClientIsSignedOutEvent object:nil userInfo:userInfo]; } #pragma mark - RNSyneriseManagerDelegate @@ -235,6 +235,20 @@ - (nullable SNRClientAgreements *)modelClientAgreementsWithDictionary:(nullable return nil; } +- (SNRClientSignOutMode)enumClientSignOutModeWithString:(nullable NSString *)string { + if (string != nil && [string isKindOfClass:NSString.class] == YES) { + if ([string isEqualToString:@"SIGN_OUT"] == YES) { + return SNRClientSignOutModeSignOut; + } + + if ([string isEqualToString:@"SIGN_OUT_WITH_SESSION_DESTROY"] == YES) { + return SNRClientSignOutModeSignOutWithSessionDestroy; + } + } + + return SNRClientSignOutModeSignOut; +} + #pragma mark - JS Mapping - (nullable NSDictionary *)dictionaryWithClientConditionalAuthResult:(nullable SNRClientConditionalAuthResult *)model { @@ -309,8 +323,11 @@ - (nullable NSDictionary *)dictionaryWithToken:(nullable SNRToken *)model { NSMutableDictionary *dictionary = [@{} mutableCopy]; [dictionary setString:model.tokenString forKey:@"tokenString"]; - [dictionary setString:SNR_TokenOriginToString(model.tokenOrigin) forKey:@"tokenOrigin"]; [dictionary setDate:model.expirationDate forKey:@"expirationDate"]; + + [dictionary setString:(model.rlm) forKey:@"rlm"]; + [dictionary setString:SNR_TokenOriginToString(model.origin) forKey:@"origin"]; + [dictionary setString:model.customId forKey:@"customId"]; return dictionary; } @@ -338,14 +355,6 @@ - (NSString *)stringWithClientSessionEndReason:(SNRClientSessionEndReason)reason } } -- (NSDictionary *)dictionaryWithClientSessionEndReason:(SNRClientSessionEndReason)reason { - NSString *clientSessionEndReasonString = [self stringWithClientSessionEndReason:reason]; - - return @{ - RNClientEventObjectReasonKey: clientSessionEndReasonString - }; -} - #pragma mark - JS Module - (NSDictionary *)constantsToExport @@ -578,6 +587,16 @@ - (NSDictionary *)constantsToExport return @YES; } +//signOutWithMode(mode: ClientSignOutMode) + +RCT_EXPORT_BLOCKING_SYNCHRONOUS_METHOD(signOutWithMode:(NSString *)string) +{ + SNRClientSignOutMode mode = [self enumClientSignOutModeWithString:string]; + [SNRClient signOutWithMode:mode]; + + return @YES; +} + //destroySession() RCT_EXPORT_METHOD(destroySession) diff --git a/ios/ReactNativeSynerise/Modules/RNInjector.m b/ios/ReactNativeSynerise/Modules/RNInjector.m index 103a715..f16adc9 100644 --- a/ios/ReactNativeSynerise/Modules/RNInjector.m +++ b/ios/ReactNativeSynerise/Modules/RNInjector.m @@ -20,17 +20,20 @@ static NSString * const RNInjectorEventListenerWalkthroughPresentedKey = @"WALKTHROUGH_PRESENTED_LISTENER_KEY"; static NSString * const RNInjectorEventListenerWalkthroughHiddenKey = @"WALKTHROUGH_HIDDEN_LISTENER_KEY"; -static NSString * const RNInjectorEventObjectUrlKey = @"url"; -static NSString * const RNInjectorEventObjectDeepLinkKey = @"deepLink"; +static NSString * const RNInjectorEventListenerInAppMessagePresentedKey = @"IN_APP_MESSAGE_PRESENTED_LISTENER_KEY"; +static NSString * const RNInjectorEventListenerInAppMessageHiddenKey = @"IN_APP_MESSAGE_HIDDEN_LISTENER_KEY"; +static NSString * const RNInjectorEventListenerInAppMessageUrlActionKey = @"IN_APP_MESSAGE_URL_ACTION_LISTENER_KEY"; +static NSString * const RNInjectorEventListenerInAppMessageDeeplinkActionKey = @"IN_APP_MESSAGE_DEEPLINK_ACTION_LISTENER_KEY"; +static NSString * const RNInjectorEventListenerInAppMessageCustomActionKey = @"IN_APP_MESSAGE_CUSTOM_ACTION_LISTENER_KEY"; NS_ASSUME_NONNULL_BEGIN -@interface RNInjector () +@interface RNInjector () @end @implementation RNInjector { - BOOL _shouldBannerPresentFlag; + BOOL _bannerShouldPresentFlag; } static RNInjector *moduleInstance; @@ -49,7 +52,7 @@ - (instancetype)init { if (self) { [[RNSyneriseManager sharedInstance] addDelegate:self]; - _shouldBannerPresentFlag = YES; + _bannerShouldPresentFlag = YES; } moduleInstance = self; @@ -70,13 +73,17 @@ - (void)executeDeepLinkAction:(NSString *)deepLink { #pragma mark - Private - (void)sendURLActionToJS:(NSURL *)URL { - id eventBody = [self dictionaryWithURLAction:URL]; - [[NSNotificationCenter defaultCenter] postNotificationName:kRNSyneriseUrlActionEvent object:nil userInfo:eventBody]; + NSDictionary *userInfo = @{ + @"url": [URL absoluteString] + }; + [[NSNotificationCenter defaultCenter] postNotificationName:kRNSyneriseUrlActionEvent object:nil userInfo:userInfo]; } - (void)sendDeepLinkActionToJS:(NSString *)deepLink { - id eventBody = [self dictionaryWithDeepLinkAction:deepLink]; - [[NSNotificationCenter defaultCenter] postNotificationName:kRNSyneriseDeepLinkActionEvent object:nil userInfo:eventBody]; + NSDictionary *userInfo = @{ + @"deepLink": deepLink + }; + [[NSNotificationCenter defaultCenter] postNotificationName:kRNSyneriseDeepLinkActionEvent object:nil userInfo:userInfo]; } - (void)sendBannerPresentedToJS { @@ -104,6 +111,45 @@ - (void)sendWalkthroughHiddenToJS { [[NSNotificationCenter defaultCenter] postNotificationName:kRNSyneriseWalkthroughHiddenEvent object:nil userInfo:nil]; } +- (void)sendInAppMessagePresentedToJS:(SNRInAppMessageData *)data { + NSDictionary *userInfo = @{ + @"data": [self dictionaryWithInAppMessageData:data] + }; + [[NSNotificationCenter defaultCenter] postNotificationName:kRNSyneriseInAppMessagePresentedKey object:nil userInfo:userInfo]; +} + +- (void)sendInAppMessageHiddenToJS:(SNRInAppMessageData *)data { + NSDictionary *userInfo = @{ + @"data": [self dictionaryWithInAppMessageData:data] + }; + [[NSNotificationCenter defaultCenter] postNotificationName:kRNSyneriseInAppMessageHiddenKey object:nil userInfo:userInfo]; +} + +- (void)sendInAppMessageUrlActionToJS:(SNRInAppMessageData *)data url:(NSURL *)URL { + NSDictionary *userInfo = @{ + @"data": [self dictionaryWithInAppMessageData:data], + @"url": [URL absoluteString] + }; + [[NSNotificationCenter defaultCenter] postNotificationName:kRNSyneriseInAppMessageUrlActionKey object:nil userInfo:userInfo]; +} + +- (void)sendInAppMessageDeepLinkActionToJS:(SNRInAppMessageData *)data deepLink:(NSString *)deepLink { + NSDictionary *userInfo = @{ + @"data": [self dictionaryWithInAppMessageData:data], + @"deepLink": deepLink + }; + [[NSNotificationCenter defaultCenter] postNotificationName:kRNSyneriseInAppMessageDeeplinkActionKey object:nil userInfo:userInfo]; +} + +- (void)sendInAppMessageCustomActionToJS:(SNRInAppMessageData *)data name:(NSString *)name parameters:(nullable NSDictionary *)parameters { + NSDictionary *userInfo = @{ + @"data": [self dictionaryWithInAppMessageData:data], + @"name": name, + @"parameters": [NSDictionary dictionaryWithDictionary:parameters] + }; + [[NSNotificationCenter defaultCenter] postNotificationName:kRNSyneriseInAppMessageCustomActionKey object:nil userInfo:userInfo]; +} + #pragma mark - RNSyneriseManagerDelegate - (void)applicationJavaScriptDidLoad { @@ -113,12 +159,13 @@ - (void)applicationJavaScriptDidLoad { - (void)syneriseJavaScriptDidLoad { [SNRInjector setBannerDelegate:self]; [SNRInjector setWalkthroughDelegate:self]; + [SNRInjector setInAppMessageDelegate:self]; } #pragma mark - SNRInjectorBannerDelegate - (BOOL)SNR_shouldBannerAppear:(NSDictionary *)bannerDictionary { - return _shouldBannerPresentFlag; + return _bannerShouldPresentFlag; } - (void)SNR_bannerDidAppear { @@ -151,18 +198,55 @@ - (void)SNR_walkthroughDidDisappear { [self sendWalkthroughHiddenToJS]; } -#pragma mark - JS Mapping +#pragma mark - SNRInjectorInAppMessageDelegate -- (NSDictionary *)dictionaryWithURLAction:(NSURL *)URL { - return @{ - RNInjectorEventObjectUrlKey: [URL absoluteString] - }; +- (BOOL)SNR_shouldInAppMessageAppear:(SNRInAppMessageData *)data { + return YES; } -- (NSDictionary *)dictionaryWithDeepLinkAction:(NSString *)deepLink { - return @{ - RNInjectorEventObjectDeepLinkKey: deepLink - }; +- (void)SNR_inAppMessageDidAppear:(SNRInAppMessageData *)data { + [self sendInAppMessagePresentedToJS:data]; +} + +- (void)SNR_inAppMessageDidDisappear:(SNRInAppMessageData *)data { + [self sendInAppMessageHiddenToJS:data]; +} + +- (void)SNR_inAppMessageDidChangeSize:(CGRect)rect { + // nothing for yet +} + +- (nullable NSDictionary *)SNR_inAppMessageContextIsNeeded:(SNRInAppMessageData *)data { + return nil; +} + +- (void)SNR_inAppMessageHandledURLAction:(SNRInAppMessageData *)data url:(NSURL *)url { + [self sendInAppMessageUrlActionToJS:data url:url]; +} + +- (void)SNR_inAppMessageHandledDeeplinkAction:(SNRInAppMessageData *)data deeplink:(NSString *)deeplink { + [self sendInAppMessageDeepLinkActionToJS:data deepLink:deeplink]; +} + +- (void)SNR_inAppMessageHandledCustomAction:(SNRInAppMessageData *)data name:(NSString *)name parameters:(NSDictionary *)parameters { + [self sendInAppMessageCustomActionToJS:data name:name parameters:parameters]; +} + +#pragma mark - JS Mapping + +- (nullable NSDictionary *)dictionaryWithInAppMessageData:(nullable SNRInAppMessageData *)model { + if (model != nil) { + NSMutableDictionary *dictionary = [@{} mutableCopy]; + + [dictionary setString:model.campaignHash forKey:@"campaignHash"]; + [dictionary setString:model.variantIdentifier forKey:@"variantIdentifier"]; + [dictionary setDictionary:model.additionalParameters forKey:@"additionalParameters"]; + [dictionary setBool:model.isTest forKey:@"isTest"]; + + return dictionary; + } + + return nil; } #pragma mark - JS Module @@ -179,40 +263,21 @@ - (NSDictionary *)constantsToExport RNInjectorEventListenerWalkthroughLoadedKey: kRNSyneriseWalkthroughLoadedEvent, RNInjectorEventListenerWalkthroughLoadingErrorKey: kRNSyneriseWalkthroughLoadingErrorEvent, RNInjectorEventListenerWalkthroughPresentedKey: kRNSyneriseWalkthroughPresentedEvent, - RNInjectorEventListenerWalkthroughHiddenKey: kRNSyneriseWalkthroughHiddenEvent + RNInjectorEventListenerWalkthroughHiddenKey: kRNSyneriseWalkthroughHiddenEvent, + + RNInjectorEventListenerInAppMessagePresentedKey: kRNSyneriseInAppMessagePresentedKey, + RNInjectorEventListenerInAppMessageHiddenKey: kRNSyneriseInAppMessageHiddenKey, + RNInjectorEventListenerInAppMessageUrlActionKey: kRNSyneriseInAppMessageUrlActionKey, + RNInjectorEventListenerInAppMessageDeeplinkActionKey: kRNSyneriseInAppMessageDeeplinkActionKey, + RNInjectorEventListenerInAppMessageCustomActionKey: kRNSyneriseInAppMessageCustomActionKey }; } -//setShouldBannerPresentFlag(shouldPresentBanner: boolean) - -RCT_EXPORT_METHOD(setShouldBannerPresentFlag:(nonnull NSNumber *)flag) -{ - _shouldBannerPresentFlag = [flag boolValue]; -} - -//fetchBanners(onSuccess: (banners: Array) => void, onError: (error: Error) => void) - -RCT_REMAP_METHOD(fetchBanners, fetchBannersWithResponse:(RCTResponseSenderBlock)response) -{ - [SNRInjector fetchBannersWithSuccess:^(NSArray *banners) { - [self executeSuccessCallbackResponse:response data:banners]; - } failure:^(NSError *error) { - [self executeFailureCallbackResponse:response error:error]; - }]; -} - -//getBanners(): Array - -RCT_EXPORT_BLOCKING_SYNCHRONOUS_METHOD(getBanners) -{ - return [SNRInjector getBanners]; -} - -//showBanner(banner: Object, markPresented: boolean) +//setBannerShouldPresentFlag(flag: boolean) -RCT_EXPORT_METHOD(showBanner:(NSDictionary *)bannerDictionary markPresented:(BOOL)markPresented) +RCT_EXPORT_METHOD(setBannerShouldPresentFlag:(nonnull NSNumber *)flag) { - [SNRInjector showBanner:bannerDictionary markPresented:markPresented]; + _bannerShouldPresentFlag = [flag boolValue]; } //getWalkthrough() diff --git a/ios/ReactNativeSynerise/Modules/RNPromotions.m b/ios/ReactNativeSynerise/Modules/RNPromotions.m index 63ec1f3..ab451c9 100644 --- a/ios/ReactNativeSynerise/Modules/RNPromotions.m +++ b/ios/ReactNativeSynerise/Modules/RNPromotions.m @@ -295,7 +295,7 @@ - (nullable NSDictionary *)dictionaryWithVoucherCodesData:(SNRVoucherCodesData * [dictionary setString:model.code forKey:@"code"]; [dictionary setString:SNR_VoucherCodeStatusToString(model.status) forKey:@"status"]; - [dictionary setString:model.clientId forKey:@"clientId"]; + [dictionary setInteger:model.clientId forKey:@"clientId"]; [dictionary setString:model.clientUuid forKey:@"clientUuid"]; [dictionary setString:model.poolUuid forKey:@"poolUuid"]; [dictionary setDate:model.expireIn forKey:@"expireIn"]; diff --git a/ios/ReactNativeSynerise/Modules/RNSettings.m b/ios/ReactNativeSynerise/Modules/RNSettings.m index 884d786..ead08c5 100644 --- a/ios/ReactNativeSynerise/Modules/RNSettings.m +++ b/ios/ReactNativeSynerise/Modules/RNSettings.m @@ -23,6 +23,9 @@ static NSString * const RNSettingsNotificationsEncryption = @"NOTIFICATIONS_ENCRYPTION"; static NSString * const RNSettingsNotificationsDisableInAppAlerts = @"NOTIFICATIONS_DISABLE_IN_APP_ALERTS"; +static NSString * const RNSettingsInAppMessagingMaxDefinitionUpdateIntervalLimit = @"IN_APP_MAX_DEFINITION_UPDATE_INTERVAL_LIMIT"; +static NSString * const RNSettingsInAppMessagingRenderingTimeout = @"IN_APP_MESSAGING_RENDERING_TIMEOUT"; + static NSString * const RNSettingsInjectorAutomatic = @"INJECTOR_AUTOMATIC"; NS_ASSUME_NONNULL_BEGIN @@ -69,6 +72,9 @@ - (void)updateSettingsWithDictionary:(NSDictionary *)dictionary { [self updateSettingsKeyPath:@"notifications.encryption" expectedClass:[NSNumber class] object:dictionary[RNSettingsNotificationsEncryption]]; [self updateSettingsKeyPath:@"notifications.disableInAppAlerts" expectedClass:[NSNumber class] object:dictionary[RNSettingsNotificationsDisableInAppAlerts]]; + [self updateSettingsKeyPath:@"inAppMessaging.maxDefinitionUpdateIntervalLimit" expectedClass:[NSNumber class] object:dictionary[RNSettingsInAppMessagingMaxDefinitionUpdateIntervalLimit]]; + [self updateSettingsKeyPath:@"inAppMessaging.renderingTimeout" expectedClass:[NSNumber class] object:dictionary[RNSettingsInAppMessagingRenderingTimeout]]; + [self updateSettingsKeyPath:@"injector.automatic" expectedClass:[NSNumber class] object:dictionary[RNSettingsInjectorAutomatic]]; } @@ -108,6 +114,9 @@ - (NSDictionary *)settingsDictionary { dictionary[RNSettingsNotificationsEncryption] = [NSNumber numberWithBool:SNRSynerise.settings.notifications.encryption]; dictionary[RNSettingsNotificationsDisableInAppAlerts] = [NSNumber numberWithBool:SNRSynerise.settings.notifications.disableInAppAlerts]; + dictionary[RNSettingsInAppMessagingMaxDefinitionUpdateIntervalLimit] = [NSNumber numberWithDouble:SNRSynerise.settings.inAppMessaging.maxDefinitionUpdateIntervalLimit]; + dictionary[RNSettingsInAppMessagingRenderingTimeout] = [NSNumber numberWithDouble:SNRSynerise.settings.inAppMessaging.renderingTimeout]; + dictionary[RNSettingsInjectorAutomatic] = [NSNumber numberWithBool:SNRSynerise.settings.injector.automatic]; return dictionary; @@ -133,6 +142,9 @@ - (NSDictionary *)constantsToExport RNSettingsNotificationsEncryption: RNSettingsNotificationsEncryption, RNSettingsNotificationsDisableInAppAlerts: RNSettingsNotificationsDisableInAppAlerts, + RNSettingsInAppMessagingMaxDefinitionUpdateIntervalLimit: RNSettingsInAppMessagingMaxDefinitionUpdateIntervalLimit, + RNSettingsInAppMessagingRenderingTimeout: RNSettingsInAppMessagingRenderingTimeout, + RNSettingsInjectorAutomatic: RNSettingsInjectorAutomatic }; } diff --git a/ios/ReactNativeSynerise/Modules/RNSynerise.m b/ios/ReactNativeSynerise/Modules/RNSynerise.m index 5c549c6..295b319 100644 --- a/ios/ReactNativeSynerise/Modules/RNSynerise.m +++ b/ios/ReactNativeSynerise/Modules/RNSynerise.m @@ -74,12 +74,20 @@ - (void)SNR_registerForPushNotificationsIsNeeded { } - (void)SNR_handledActionWithURL:(NSURL *)url activity:(SNRSyneriseActivity)activity completionHandler:(SNRSyneriseActivityCompletionHandler)completionHandler { + if (activity == SNRSyneriseActivityInAppMessage) { + return; + } + completionHandler(SNRSyneriseActivityActionHide, ^{ [[RNSyneriseManager sharedInstance].injector executeURLAction:url]; }); } - (void)SNR_handledActionWithDeepLink:(NSString *)deepLink activity:(SNRSyneriseActivity)activity completionHandler:(SNRSyneriseActivityCompletionHandler)completionHandler { + if (activity == SNRSyneriseActivityInAppMessage) { + return; + } + completionHandler(SNRSyneriseActivityActionHide, ^{ [[RNSyneriseManager sharedInstance].injector executeDeepLinkAction:deepLink]; }); diff --git a/ios/ReactNativeSynerise/Modules/RNTracker.m b/ios/ReactNativeSynerise/Modules/RNTracker.m index cd0e45a..b91fda2 100644 --- a/ios/ReactNativeSynerise/Modules/RNTracker.m +++ b/ios/ReactNativeSynerise/Modules/RNTracker.m @@ -8,7 +8,6 @@ #import "RNTracker.h" -static NSString * const RNTrackerEventTypeKey = @"type"; static NSString * const RNTrackerEventLabelKey = @"label"; static NSString * const RNTrackerEventActionKey = @"action"; static NSString * const RNTrackerEventParametersKey = @"parameters"; @@ -42,12 +41,11 @@ - (instancetype)init { #pragma mark - SDK Mapping - (SNRCustomEvent *)eventWithDictionary:(NSDictionary *)dictionary { - NSString *type = [dictionary getStringForKey:RNTrackerEventTypeKey]; NSString *label = [dictionary getStringForKey:RNTrackerEventLabelKey]; NSString *action = [dictionary getStringForKey:RNTrackerEventActionKey]; NSDictionary *parameters = [dictionary getDictionaryForKey:RNTrackerEventParametersKey]; - if (type != nil && label != nil) { + if (label != nil && action != nil) { SNRTrackerParams *params = [SNRTrackerParams makeWithBuilder:^(SNRTrackerParamsBuilder *builder) { if (parameters != nil && [parameters count] > 0) { for (NSString *paramKey in parameters) { @@ -81,7 +79,7 @@ - (SNRCustomEvent *)eventWithDictionary:(NSDictionary *)dictionary { } }]; - SNRCustomEvent *event = [[SNRCustomEvent alloc] initWithType:type label:label action:action andParams:params]; + SNRCustomEvent *event = [[SNRCustomEvent alloc] initWithLabel:label action:action andParams:params]; return event; } diff --git a/ios/ReactNativeSynerise/ReactNativeSynerise.h b/ios/ReactNativeSynerise/ReactNativeSynerise.h index eb6be0e..1b7fc6c 100644 --- a/ios/ReactNativeSynerise/ReactNativeSynerise.h +++ b/ios/ReactNativeSynerise/ReactNativeSynerise.h @@ -38,5 +38,11 @@ static NSString * const kRNSyneriseWalkthroughLoadingErrorEvent = @"kRNSyneriseW static NSString * const kRNSyneriseWalkthroughPresentedEvent = @"kRNSyneriseWalkthroughPresentedEvent"; static NSString * const kRNSyneriseWalkthroughHiddenEvent = @"kRNSyneriseWalkthroughHiddenEvent"; +static NSString * const kRNSyneriseInAppMessagePresentedKey = @"kRNSyneriseInAppMessagePresentedKey"; +static NSString * const kRNSyneriseInAppMessageHiddenKey = @"kRNSyneriseInAppMessageHiddenKey"; +static NSString * const kRNSyneriseInAppMessageUrlActionKey = @"kRNSyneriseInAppMessageUrlActionKey"; +static NSString * const kRNSyneriseInAppMessageDeeplinkActionKey = @"kRNSyneriseInAppMessageDeeplinkActionKey"; +static NSString * const kRNSyneriseInAppMessageCustomActionKey = @"kRNSyneriseInAppMessageCustomActionKey"; + static NSString * const kRNSyneriseClientIsSignedInEvent = @"kRNSyneriseClientIsSignedInEvent"; static NSString * const kRNSyneriseClientIsSignedOutEvent = @"kRNSyneriseClientIsSignedOutEvent"; diff --git a/ios/react-native-synerise-sdk.podspec b/ios/react-native-synerise-sdk.podspec index 10a821c..fdda41b 100644 --- a/ios/react-native-synerise-sdk.podspec +++ b/ios/react-native-synerise-sdk.podspec @@ -2,7 +2,7 @@ require 'json' package = JSON.parse(File.read('./../package.json')) -SYNERISE_SDK_FRAMEWORK_VERSION = '3.12.0' +SYNERISE_SDK_FRAMEWORK_VERSION = '4.10.1' Pod::Spec.new do |s| s.name = package['name'] diff --git a/lib/classes/events/CustomEvent.js b/lib/classes/events/CustomEvent.js index 072715c..847bf70 100644 --- a/lib/classes/events/CustomEvent.js +++ b/lib/classes/events/CustomEvent.js @@ -15,11 +15,10 @@ var __extends = (this && this.__extends) || (function () { Object.defineProperty(exports, "__esModule", { value: true }); exports.CustomEvent = void 0; var Event_1 = require("./Event"); -var CUSTOM_EVENT_TYPE = 'custom'; var CustomEvent = /** @class */ (function (_super) { __extends(CustomEvent, _super); function CustomEvent(label, action, parameters) { - return _super.call(this, CUSTOM_EVENT_TYPE, label, action, parameters || {}) || this; + return _super.call(this, label, action, parameters || {}) || this; } CustomEvent.prototype.setString = function (key, string) { if (typeof key == 'string' && typeof string == 'string') { diff --git a/lib/classes/events/Event.d.ts b/lib/classes/events/Event.d.ts index 35b5a62..668787c 100644 --- a/lib/classes/events/Event.d.ts +++ b/lib/classes/events/Event.d.ts @@ -1,11 +1,9 @@ declare abstract class Event { - private type; private label; private action; protected parameters: Record; - constructor(type: string, label: string, action: string | null, parameters: object); + constructor(label: string, action: string | null, parameters: object); toObject(): { - type: string; label: string; action: string | null; parameters: Record; diff --git a/lib/classes/events/Event.js b/lib/classes/events/Event.js index 021ed86..3dfa62e 100644 --- a/lib/classes/events/Event.js +++ b/lib/classes/events/Event.js @@ -2,15 +2,13 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.Event = void 0; var Event = /** @class */ (function () { - function Event(type, label, action, parameters) { - this.type = type; + function Event(label, action, parameters) { this.label = label; this.action = action; this.parameters = parameters; } Event.prototype.toObject = function () { return { - type: this.type, label: this.label, action: this.action, parameters: this.parameters, diff --git a/lib/classes/events/auth/LoggedInEvent.d.ts b/lib/classes/events/auth/LoggedInEvent.d.ts index 91072b9..652688f 100644 --- a/lib/classes/events/auth/LoggedInEvent.d.ts +++ b/lib/classes/events/auth/LoggedInEvent.d.ts @@ -1,5 +1,5 @@ -import { Event } from './../Event'; -declare class LoggedInEvent extends Event { +import { CustomEvent } from './../CustomEvent'; +declare class LoggedInEvent extends CustomEvent { constructor(label: string, parameters?: object); } export { LoggedInEvent }; diff --git a/lib/classes/events/auth/LoggedInEvent.js b/lib/classes/events/auth/LoggedInEvent.js index b407eac..39ee8f2 100644 --- a/lib/classes/events/auth/LoggedInEvent.js +++ b/lib/classes/events/auth/LoggedInEvent.js @@ -14,13 +14,12 @@ var __extends = (this && this.__extends) || (function () { })(); Object.defineProperty(exports, "__esModule", { value: true }); exports.LoggedInEvent = void 0; -var Event_1 = require("./../Event"); -var LOGGED_IN_EVENT_TYPE = 'logged-in'; +var CustomEvent_1 = require("./../CustomEvent"); var LoggedInEvent = /** @class */ (function (_super) { __extends(LoggedInEvent, _super); function LoggedInEvent(label, parameters) { - return _super.call(this, LOGGED_IN_EVENT_TYPE, label, null, parameters || {}) || this; + return _super.call(this, label, 'client.login', parameters || {}) || this; } return LoggedInEvent; -}(Event_1.Event)); +}(CustomEvent_1.CustomEvent)); exports.LoggedInEvent = LoggedInEvent; diff --git a/lib/classes/events/auth/LoggedOutEvent.d.ts b/lib/classes/events/auth/LoggedOutEvent.d.ts index 2cebb5b..a8db9ae 100644 --- a/lib/classes/events/auth/LoggedOutEvent.d.ts +++ b/lib/classes/events/auth/LoggedOutEvent.d.ts @@ -1,5 +1,5 @@ -import { Event } from './../Event'; -declare class LoggedOutEvent extends Event { +import { CustomEvent } from './../CustomEvent'; +declare class LoggedOutEvent extends CustomEvent { constructor(label: string, parameters?: object); } export { LoggedOutEvent }; diff --git a/lib/classes/events/auth/LoggedOutEvent.js b/lib/classes/events/auth/LoggedOutEvent.js index 2570013..3f15679 100644 --- a/lib/classes/events/auth/LoggedOutEvent.js +++ b/lib/classes/events/auth/LoggedOutEvent.js @@ -14,13 +14,12 @@ var __extends = (this && this.__extends) || (function () { })(); Object.defineProperty(exports, "__esModule", { value: true }); exports.LoggedOutEvent = void 0; -var Event_1 = require("./../Event"); -var LOGGED_OUT_EVENT_TYPE = 'logged-out'; +var CustomEvent_1 = require("./../CustomEvent"); var LoggedOutEvent = /** @class */ (function (_super) { __extends(LoggedOutEvent, _super); function LoggedOutEvent(label, parameters) { - return _super.call(this, LOGGED_OUT_EVENT_TYPE, label, null, parameters || {}) || this; + return _super.call(this, label, 'client.logout', parameters || {}) || this; } return LoggedOutEvent; -}(Event_1.Event)); +}(CustomEvent_1.CustomEvent)); exports.LoggedOutEvent = LoggedOutEvent; diff --git a/lib/classes/events/auth/RecognizeClientEvent.d.ts b/lib/classes/events/auth/RecognizeClientEvent.d.ts index 483afd0..22209d7 100644 --- a/lib/classes/events/auth/RecognizeClientEvent.d.ts +++ b/lib/classes/events/auth/RecognizeClientEvent.d.ts @@ -1,5 +1,5 @@ -import { Event } from './../Event'; -declare class RecognizeClientEvent extends Event { +import { CustomEvent } from './../CustomEvent'; +declare class RecognizeClientEvent extends CustomEvent { constructor(parameters?: object); } export { RecognizeClientEvent }; diff --git a/lib/classes/events/auth/RecognizeClientEvent.js b/lib/classes/events/auth/RecognizeClientEvent.js index 2254e47..ebf634e 100644 --- a/lib/classes/events/auth/RecognizeClientEvent.js +++ b/lib/classes/events/auth/RecognizeClientEvent.js @@ -14,15 +14,14 @@ var __extends = (this && this.__extends) || (function () { })(); Object.defineProperty(exports, "__esModule", { value: true }); exports.RecognizeClientEvent = void 0; -var Event_1 = require("./../Event"); -var RECOGNIZE_CLIENT_EVENT_TYPE = 'custom'; +var CustomEvent_1 = require("./../CustomEvent"); var RECOGNIZE_CLIENT_EVENT_LABEL = 'client'; var RECOGNIZE_CLIENT_EVENT_ACTION = 'client.createOrUpdate'; var RecognizeClientEvent = /** @class */ (function (_super) { __extends(RecognizeClientEvent, _super); function RecognizeClientEvent(parameters) { - return _super.call(this, RECOGNIZE_CLIENT_EVENT_TYPE, RECOGNIZE_CLIENT_EVENT_LABEL, RECOGNIZE_CLIENT_EVENT_ACTION, parameters || {}) || this; + return _super.call(this, RECOGNIZE_CLIENT_EVENT_LABEL, RECOGNIZE_CLIENT_EVENT_ACTION, parameters || {}) || this; } return RecognizeClientEvent; -}(Event_1.Event)); +}(CustomEvent_1.CustomEvent)); exports.RecognizeClientEvent = RecognizeClientEvent; diff --git a/lib/classes/events/auth/RegisteredEvent.d.ts b/lib/classes/events/auth/RegisteredEvent.d.ts index 51a3a70..256956f 100644 --- a/lib/classes/events/auth/RegisteredEvent.d.ts +++ b/lib/classes/events/auth/RegisteredEvent.d.ts @@ -1,5 +1,5 @@ -import { Event } from './../Event'; -declare class RegisteredEvent extends Event { +import { CustomEvent } from './../CustomEvent'; +declare class RegisteredEvent extends CustomEvent { constructor(label: string, parameters?: object); } export { RegisteredEvent }; diff --git a/lib/classes/events/auth/RegisteredEvent.js b/lib/classes/events/auth/RegisteredEvent.js index c900492..c0ba552 100644 --- a/lib/classes/events/auth/RegisteredEvent.js +++ b/lib/classes/events/auth/RegisteredEvent.js @@ -14,13 +14,12 @@ var __extends = (this && this.__extends) || (function () { })(); Object.defineProperty(exports, "__esModule", { value: true }); exports.RegisteredEvent = void 0; -var Event_1 = require("./../Event"); -var REGISTERED_EVENT_TYPE = 'registered'; +var CustomEvent_1 = require("./../CustomEvent"); var RegisteredEvent = /** @class */ (function (_super) { __extends(RegisteredEvent, _super); function RegisteredEvent(label, parameters) { - return _super.call(this, REGISTERED_EVENT_TYPE, label, null, parameters || {}) || this; + return _super.call(this, label, 'client.register', parameters || {}) || this; } return RegisteredEvent; -}(Event_1.Event)); +}(CustomEvent_1.CustomEvent)); exports.RegisteredEvent = RegisteredEvent; diff --git a/lib/classes/events/cart/CartEvent.d.ts b/lib/classes/events/cart/CartEvent.d.ts index ef85f21..eee4af6 100644 --- a/lib/classes/events/cart/CartEvent.d.ts +++ b/lib/classes/events/cart/CartEvent.d.ts @@ -1,7 +1,7 @@ -import { Event } from './../Event'; +import { CustomEvent } from './../CustomEvent'; import { UnitPrice } from './UnitPrice'; -declare class CartEvent extends Event { - constructor(type: string, label: string, sku: string, finalPrice: UnitPrice, quantity: number, parameters?: object); +declare class CartEvent extends CustomEvent { + constructor(label: string, action: string, sku: string, finalPrice: UnitPrice, quantity: number, parameters?: object); setName(name: string): void; setCategory(category: string): void; setCategories(categories: string[]): void; diff --git a/lib/classes/events/cart/CartEvent.js b/lib/classes/events/cart/CartEvent.js index 3220144..105deb6 100644 --- a/lib/classes/events/cart/CartEvent.js +++ b/lib/classes/events/cart/CartEvent.js @@ -14,7 +14,7 @@ var __extends = (this && this.__extends) || (function () { })(); Object.defineProperty(exports, "__esModule", { value: true }); exports.CartEvent = void 0; -var Event_1 = require("./../Event"); +var CustomEvent_1 = require("./../CustomEvent"); var Params; (function (Params) { Params["SKU"] = "sku"; @@ -31,8 +31,8 @@ var Params; })(Params || (Params = {})); var CartEvent = /** @class */ (function (_super) { __extends(CartEvent, _super); - function CartEvent(type, label, sku, finalPrice, quantity, parameters) { - var _this = _super.call(this, type, label, null, parameters || {}) || this; + function CartEvent(label, action, sku, finalPrice, quantity, parameters) { + var _this = _super.call(this, label, action, parameters || {}) || this; // TODO: walidacja przed konfilktami kluczy _this.parameters[Params.SKU] = sku; _this.parameters[Params.QUANTITY] = quantity; @@ -74,5 +74,5 @@ var CartEvent = /** @class */ (function (_super) { } }; return CartEvent; -}(Event_1.Event)); +}(CustomEvent_1.CustomEvent)); exports.CartEvent = CartEvent; diff --git a/lib/classes/events/cart/ProductAddedToCartEvent.js b/lib/classes/events/cart/ProductAddedToCartEvent.js index 5f8e109..0a654ec 100644 --- a/lib/classes/events/cart/ProductAddedToCartEvent.js +++ b/lib/classes/events/cart/ProductAddedToCartEvent.js @@ -15,11 +15,10 @@ var __extends = (this && this.__extends) || (function () { Object.defineProperty(exports, "__esModule", { value: true }); exports.ProductAddedToCartEvent = void 0; var CartEvent_1 = require("../cart/CartEvent"); -var PRODUCT_ADDED_TO_CART_EVENT_TYPE = 'added-to-cart'; var ProductAddedToCartEvent = /** @class */ (function (_super) { __extends(ProductAddedToCartEvent, _super); function ProductAddedToCartEvent(label, sku, finalPrice, quantity, parameters) { - return _super.call(this, PRODUCT_ADDED_TO_CART_EVENT_TYPE, label, sku, finalPrice, quantity, parameters || {}) || this; + return _super.call(this, label, 'product.addToCart', sku, finalPrice, quantity, parameters || {}) || this; } return ProductAddedToCartEvent; }(CartEvent_1.CartEvent)); diff --git a/lib/classes/events/cart/ProductRemovedFromCartEvent.js b/lib/classes/events/cart/ProductRemovedFromCartEvent.js index 16a6b1d..44639dd 100644 --- a/lib/classes/events/cart/ProductRemovedFromCartEvent.js +++ b/lib/classes/events/cart/ProductRemovedFromCartEvent.js @@ -15,11 +15,10 @@ var __extends = (this && this.__extends) || (function () { Object.defineProperty(exports, "__esModule", { value: true }); exports.ProductRemovedFromCartEvent = void 0; var CartEvent_1 = require("../cart/CartEvent"); -var PRODUCT_REMOVED_FROM_CART_EVENT_TYPE = 'removed-from-cart'; var ProductRemovedFromCartEvent = /** @class */ (function (_super) { __extends(ProductRemovedFromCartEvent, _super); function ProductRemovedFromCartEvent(label, sku, finalPrice, quantity, parameters) { - return _super.call(this, PRODUCT_REMOVED_FROM_CART_EVENT_TYPE, label, sku, finalPrice, quantity, parameters || {}) || this; + return _super.call(this, label, 'product.removeFromCart', sku, finalPrice, quantity, parameters || {}) || this; } return ProductRemovedFromCartEvent; }(CartEvent_1.CartEvent)); diff --git a/lib/classes/events/other/AppearedInLocationEvent.d.ts b/lib/classes/events/other/AppearedInLocationEvent.d.ts index ea21363..fe25260 100644 --- a/lib/classes/events/other/AppearedInLocationEvent.d.ts +++ b/lib/classes/events/other/AppearedInLocationEvent.d.ts @@ -1,5 +1,5 @@ -import { Event } from './../Event'; -declare class AppearedInLocationEvent extends Event { +import { CustomEvent } from './../CustomEvent'; +declare class AppearedInLocationEvent extends CustomEvent { constructor(label: string, lat: number, lon: number, parameters?: object); } export { AppearedInLocationEvent }; diff --git a/lib/classes/events/other/AppearedInLocationEvent.js b/lib/classes/events/other/AppearedInLocationEvent.js index 99c481f..59c4d05 100644 --- a/lib/classes/events/other/AppearedInLocationEvent.js +++ b/lib/classes/events/other/AppearedInLocationEvent.js @@ -14,22 +14,21 @@ var __extends = (this && this.__extends) || (function () { })(); Object.defineProperty(exports, "__esModule", { value: true }); exports.AppearedInLocationEvent = void 0; -var Event_1 = require("./../Event"); +var CustomEvent_1 = require("./../CustomEvent"); var Params; (function (Params) { Params["LAT"] = "lat"; Params["LON"] = "lon"; })(Params || (Params = {})); -var APPEARED_IN_LOCATION_EVENT_TYPE = 'appeared-in-location'; var AppearedInLocationEvent = /** @class */ (function (_super) { __extends(AppearedInLocationEvent, _super); function AppearedInLocationEvent(label, lat, lon, parameters) { - var _this = _super.call(this, APPEARED_IN_LOCATION_EVENT_TYPE, label, null, parameters || {}) || this; + var _this = _super.call(this, label, 'client.location', parameters || {}) || this; //TODO: walidacja czy nie ma kluczy takich _this.parameters[Params.LAT] = lat; _this.parameters[Params.LON] = lon; return _this; } return AppearedInLocationEvent; -}(Event_1.Event)); +}(CustomEvent_1.CustomEvent)); exports.AppearedInLocationEvent = AppearedInLocationEvent; diff --git a/lib/classes/events/other/HitTimerEvent.d.ts b/lib/classes/events/other/HitTimerEvent.d.ts index 3dade3c..5a6c301 100644 --- a/lib/classes/events/other/HitTimerEvent.d.ts +++ b/lib/classes/events/other/HitTimerEvent.d.ts @@ -1,5 +1,5 @@ -import { Event } from './../Event'; -declare class HitTimerEvent extends Event { +import { CustomEvent } from './../CustomEvent'; +declare class HitTimerEvent extends CustomEvent { constructor(label: string, parameters?: object); } export { HitTimerEvent }; diff --git a/lib/classes/events/other/HitTimerEvent.js b/lib/classes/events/other/HitTimerEvent.js index dcb3bad..62be245 100644 --- a/lib/classes/events/other/HitTimerEvent.js +++ b/lib/classes/events/other/HitTimerEvent.js @@ -14,13 +14,12 @@ var __extends = (this && this.__extends) || (function () { })(); Object.defineProperty(exports, "__esModule", { value: true }); exports.HitTimerEvent = void 0; -var Event_1 = require("./../Event"); -var HIT_TIMER_EVENT_TYPE = 'hit-timer'; +var CustomEvent_1 = require("./../CustomEvent"); var HitTimerEvent = /** @class */ (function (_super) { __extends(HitTimerEvent, _super); function HitTimerEvent(label, parameters) { - return _super.call(this, HIT_TIMER_EVENT_TYPE, label, null, parameters || {}) || this; + return _super.call(this, label, 'client.hitTimer', parameters || {}) || this; } return HitTimerEvent; -}(Event_1.Event)); +}(CustomEvent_1.CustomEvent)); exports.HitTimerEvent = HitTimerEvent; diff --git a/lib/classes/events/other/SearchedEvent.d.ts b/lib/classes/events/other/SearchedEvent.d.ts index 18f5fcc..34a80ef 100644 --- a/lib/classes/events/other/SearchedEvent.d.ts +++ b/lib/classes/events/other/SearchedEvent.d.ts @@ -1,5 +1,5 @@ -import { Event } from './../Event'; -declare class SearchedEvent extends Event { +import { CustomEvent } from './../CustomEvent'; +declare class SearchedEvent extends CustomEvent { constructor(label: string, parameters?: object); } export { SearchedEvent }; diff --git a/lib/classes/events/other/SearchedEvent.js b/lib/classes/events/other/SearchedEvent.js index 9a92b4f..1c3519c 100644 --- a/lib/classes/events/other/SearchedEvent.js +++ b/lib/classes/events/other/SearchedEvent.js @@ -14,13 +14,12 @@ var __extends = (this && this.__extends) || (function () { })(); Object.defineProperty(exports, "__esModule", { value: true }); exports.SearchedEvent = void 0; -var Event_1 = require("./../Event"); -var SEARCHED_EVENT_TYPE = 'searched'; +var CustomEvent_1 = require("./../CustomEvent"); var SearchedEvent = /** @class */ (function (_super) { __extends(SearchedEvent, _super); function SearchedEvent(label, parameters) { - return _super.call(this, SEARCHED_EVENT_TYPE, label, null, parameters || {}) || this; + return _super.call(this, label, 'client.search', parameters || {}) || this; } return SearchedEvent; -}(Event_1.Event)); +}(CustomEvent_1.CustomEvent)); exports.SearchedEvent = SearchedEvent; diff --git a/lib/classes/events/other/SharedEvent.d.ts b/lib/classes/events/other/SharedEvent.d.ts index 4d7e620..d2a4e2f 100644 --- a/lib/classes/events/other/SharedEvent.d.ts +++ b/lib/classes/events/other/SharedEvent.d.ts @@ -1,5 +1,5 @@ -import { Event } from './../Event'; -declare class SharedEvent extends Event { +import { CustomEvent } from './../CustomEvent'; +declare class SharedEvent extends CustomEvent { constructor(label: string, parameters?: object); } export { SharedEvent }; diff --git a/lib/classes/events/other/SharedEvent.js b/lib/classes/events/other/SharedEvent.js index 5b41109..4056279 100644 --- a/lib/classes/events/other/SharedEvent.js +++ b/lib/classes/events/other/SharedEvent.js @@ -14,13 +14,12 @@ var __extends = (this && this.__extends) || (function () { })(); Object.defineProperty(exports, "__esModule", { value: true }); exports.SharedEvent = void 0; -var Event_1 = require("./../Event"); -var SHARED_EVENT_TYPE = 'shared'; +var CustomEvent_1 = require("./../CustomEvent"); var SharedEvent = /** @class */ (function (_super) { __extends(SharedEvent, _super); function SharedEvent(label, parameters) { - return _super.call(this, SHARED_EVENT_TYPE, label, null, parameters || {}) || this; + return _super.call(this, label, 'client.shared', parameters || {}) || this; } return SharedEvent; -}(Event_1.Event)); +}(CustomEvent_1.CustomEvent)); exports.SharedEvent = SharedEvent; diff --git a/lib/classes/events/other/VisitedScreenEvent.d.ts b/lib/classes/events/other/VisitedScreenEvent.d.ts index bcb3d50..bdea877 100644 --- a/lib/classes/events/other/VisitedScreenEvent.d.ts +++ b/lib/classes/events/other/VisitedScreenEvent.d.ts @@ -1,5 +1,5 @@ -import { Event } from './../Event'; -declare class VisitedScreenEvent extends Event { +import { CustomEvent } from './../CustomEvent'; +declare class VisitedScreenEvent extends CustomEvent { constructor(label: string, parameters?: object); } export { VisitedScreenEvent }; diff --git a/lib/classes/events/other/VisitedScreenEvent.js b/lib/classes/events/other/VisitedScreenEvent.js index d6f2e6f..222ee34 100644 --- a/lib/classes/events/other/VisitedScreenEvent.js +++ b/lib/classes/events/other/VisitedScreenEvent.js @@ -14,13 +14,12 @@ var __extends = (this && this.__extends) || (function () { })(); Object.defineProperty(exports, "__esModule", { value: true }); exports.VisitedScreenEvent = void 0; -var Event_1 = require("./../Event"); -var VISITED_SCREEN_EVENT_TYPE = 'visited-screen'; +var CustomEvent_1 = require("./../CustomEvent"); var VisitedScreenEvent = /** @class */ (function (_super) { __extends(VisitedScreenEvent, _super); function VisitedScreenEvent(label, parameters) { - return _super.call(this, VISITED_SCREEN_EVENT_TYPE, label, null, parameters || {}) || this; + return _super.call(this, label, 'screen.view', parameters || {}) || this; } return VisitedScreenEvent; -}(Event_1.Event)); +}(CustomEvent_1.CustomEvent)); exports.VisitedScreenEvent = VisitedScreenEvent; diff --git a/lib/classes/events/product/ProductAddedToFavouritesEvent.d.ts b/lib/classes/events/product/ProductAddedToFavouritesEvent.d.ts index 065375d..c636f73 100644 --- a/lib/classes/events/product/ProductAddedToFavouritesEvent.d.ts +++ b/lib/classes/events/product/ProductAddedToFavouritesEvent.d.ts @@ -1,5 +1,5 @@ -import { Event } from '../Event'; -declare class ProductAddedToFavouritesEvent extends Event { +import { CustomEvent } from '../CustomEvent'; +declare class ProductAddedToFavouritesEvent extends CustomEvent { constructor(label: string, parameters?: object); } export { ProductAddedToFavouritesEvent }; diff --git a/lib/classes/events/product/ProductAddedToFavouritesEvent.js b/lib/classes/events/product/ProductAddedToFavouritesEvent.js index ce124ab..faf3503 100644 --- a/lib/classes/events/product/ProductAddedToFavouritesEvent.js +++ b/lib/classes/events/product/ProductAddedToFavouritesEvent.js @@ -14,13 +14,12 @@ var __extends = (this && this.__extends) || (function () { })(); Object.defineProperty(exports, "__esModule", { value: true }); exports.ProductAddedToFavouritesEvent = void 0; -var Event_1 = require("../Event"); -var PRODUCT_DDED_TO_FAVOURITES_EVENT_TYPE = 'added-to-favorites'; +var CustomEvent_1 = require("../CustomEvent"); var ProductAddedToFavouritesEvent = /** @class */ (function (_super) { __extends(ProductAddedToFavouritesEvent, _super); function ProductAddedToFavouritesEvent(label, parameters) { - return _super.call(this, PRODUCT_DDED_TO_FAVOURITES_EVENT_TYPE, label, null, parameters || {}) || this; + return _super.call(this, label, 'product.addToFavorite', parameters || {}) || this; } return ProductAddedToFavouritesEvent; -}(Event_1.Event)); +}(CustomEvent_1.CustomEvent)); exports.ProductAddedToFavouritesEvent = ProductAddedToFavouritesEvent; diff --git a/lib/classes/events/product/ProductViewedEvent.d.ts b/lib/classes/events/product/ProductViewedEvent.d.ts index e9fc796..a71d25a 100644 --- a/lib/classes/events/product/ProductViewedEvent.d.ts +++ b/lib/classes/events/product/ProductViewedEvent.d.ts @@ -1,5 +1,5 @@ -import { Event } from '../Event'; -declare class ProductViewedEvent extends Event { +import { CustomEvent } from '../CustomEvent'; +declare class ProductViewedEvent extends CustomEvent { constructor(label: string, productId: string, name: string, parameters?: object); setCategory(category: string): void; setUrl(url: string): void; diff --git a/lib/classes/events/product/ProductViewedEvent.js b/lib/classes/events/product/ProductViewedEvent.js index 2f83ace..aa7e364 100644 --- a/lib/classes/events/product/ProductViewedEvent.js +++ b/lib/classes/events/product/ProductViewedEvent.js @@ -14,8 +14,7 @@ var __extends = (this && this.__extends) || (function () { })(); Object.defineProperty(exports, "__esModule", { value: true }); exports.ProductViewedEvent = void 0; -var Event_1 = require("../Event"); -var PRODUCT_VIEWED_EVENT_TYPE = 'product-view'; +var CustomEvent_1 = require("../CustomEvent"); var Params; (function (Params) { Params["PRODUCT_ID"] = "productId"; @@ -26,7 +25,7 @@ var Params; var ProductViewedEvent = /** @class */ (function (_super) { __extends(ProductViewedEvent, _super); function ProductViewedEvent(label, productId, name, parameters) { - var _this = _super.call(this, PRODUCT_VIEWED_EVENT_TYPE, label, null, parameters || {}) || this; + var _this = _super.call(this, label, 'product.view', parameters || {}) || this; _this.parameters[Params.PRODUCT_ID] = productId; _this.parameters[Params.NAME] = name; return _this; @@ -42,5 +41,5 @@ var ProductViewedEvent = /** @class */ (function (_super) { } }; return ProductViewedEvent; -}(Event_1.Event)); +}(CustomEvent_1.CustomEvent)); exports.ProductViewedEvent = ProductViewedEvent; diff --git a/lib/classes/events/push/PushCancelledEvent.d.ts b/lib/classes/events/push/PushCancelledEvent.d.ts index 8e561cd..6a6e66b 100644 --- a/lib/classes/events/push/PushCancelledEvent.d.ts +++ b/lib/classes/events/push/PushCancelledEvent.d.ts @@ -1,5 +1,5 @@ -import { Event } from '../Event'; -declare class PushCancelledEvent extends Event { +import { CustomEvent } from '../CustomEvent'; +declare class PushCancelledEvent extends CustomEvent { constructor(label: string, parameters?: object); } export { PushCancelledEvent }; diff --git a/lib/classes/events/push/PushCancelledEvent.js b/lib/classes/events/push/PushCancelledEvent.js index 958eaa2..70ebbd4 100644 --- a/lib/classes/events/push/PushCancelledEvent.js +++ b/lib/classes/events/push/PushCancelledEvent.js @@ -14,13 +14,12 @@ var __extends = (this && this.__extends) || (function () { })(); Object.defineProperty(exports, "__esModule", { value: true }); exports.PushCancelledEvent = void 0; -var Event_1 = require("../Event"); -var PUSH_CANCELLED_EVENT_TYPE = 'cancelled-push'; +var CustomEvent_1 = require("../CustomEvent"); var PushCancelledEvent = /** @class */ (function (_super) { __extends(PushCancelledEvent, _super); function PushCancelledEvent(label, parameters) { - return _super.call(this, PUSH_CANCELLED_EVENT_TYPE, label, null, parameters || {}) || this; + return _super.call(this, label, 'push.cancel', parameters || {}) || this; } return PushCancelledEvent; -}(Event_1.Event)); +}(CustomEvent_1.CustomEvent)); exports.PushCancelledEvent = PushCancelledEvent; diff --git a/lib/classes/events/push/PushClickedEvent.d.ts b/lib/classes/events/push/PushClickedEvent.d.ts index 4b969af..2301b88 100644 --- a/lib/classes/events/push/PushClickedEvent.d.ts +++ b/lib/classes/events/push/PushClickedEvent.d.ts @@ -1,5 +1,5 @@ -import { Event } from '../Event'; -declare class PushClickedEvent extends Event { +import { CustomEvent } from '../CustomEvent'; +declare class PushClickedEvent extends CustomEvent { constructor(label: string, parameters?: object); } export { PushClickedEvent }; diff --git a/lib/classes/events/push/PushClickedEvent.js b/lib/classes/events/push/PushClickedEvent.js index 8f815f1..68c90cc 100644 --- a/lib/classes/events/push/PushClickedEvent.js +++ b/lib/classes/events/push/PushClickedEvent.js @@ -14,13 +14,12 @@ var __extends = (this && this.__extends) || (function () { })(); Object.defineProperty(exports, "__esModule", { value: true }); exports.PushClickedEvent = void 0; -var Event_1 = require("../Event"); -var PUSH_CLICKED_EVENT_TYPE = 'clicked-push'; +var CustomEvent_1 = require("../CustomEvent"); var PushClickedEvent = /** @class */ (function (_super) { __extends(PushClickedEvent, _super); function PushClickedEvent(label, parameters) { - return _super.call(this, PUSH_CLICKED_EVENT_TYPE, label, null, parameters || {}) || this; + return _super.call(this, label, 'push.click', parameters || {}) || this; } return PushClickedEvent; -}(Event_1.Event)); +}(CustomEvent_1.CustomEvent)); exports.PushClickedEvent = PushClickedEvent; diff --git a/lib/classes/events/push/PushViewedEvent.d.ts b/lib/classes/events/push/PushViewedEvent.d.ts index 52291c7..b6ae1a5 100644 --- a/lib/classes/events/push/PushViewedEvent.d.ts +++ b/lib/classes/events/push/PushViewedEvent.d.ts @@ -1,5 +1,5 @@ -import { Event } from '../Event'; -declare class PushViewedEvent extends Event { +import { CustomEvent } from '../CustomEvent'; +declare class PushViewedEvent extends CustomEvent { constructor(label: string, parameters?: object); } export { PushViewedEvent }; diff --git a/lib/classes/events/push/PushViewedEvent.js b/lib/classes/events/push/PushViewedEvent.js index 36e1842..b89bf34 100644 --- a/lib/classes/events/push/PushViewedEvent.js +++ b/lib/classes/events/push/PushViewedEvent.js @@ -14,13 +14,12 @@ var __extends = (this && this.__extends) || (function () { })(); Object.defineProperty(exports, "__esModule", { value: true }); exports.PushViewedEvent = void 0; -var Event_1 = require("../Event"); -var PUSH_VIEWED_EVENT_TYPE = 'viewed-push'; +var CustomEvent_1 = require("../CustomEvent"); var PushViewedEvent = /** @class */ (function (_super) { __extends(PushViewedEvent, _super); function PushViewedEvent(label, parameters) { - return _super.call(this, PUSH_VIEWED_EVENT_TYPE, label, null, parameters || {}) || this; + return _super.call(this, label, 'push.view', parameters || {}) || this; } return PushViewedEvent; -}(Event_1.Event)); +}(CustomEvent_1.CustomEvent)); exports.PushViewedEvent = PushViewedEvent; diff --git a/lib/classes/events/recommendation/RecommendationClickEvent.js b/lib/classes/events/recommendation/RecommendationClickEvent.js index d89f51d..9c63865 100644 --- a/lib/classes/events/recommendation/RecommendationClickEvent.js +++ b/lib/classes/events/recommendation/RecommendationClickEvent.js @@ -15,11 +15,10 @@ var __extends = (this && this.__extends) || (function () { Object.defineProperty(exports, "__esModule", { value: true }); exports.RecommendationClickEvent = void 0; var RecommendationEvent_1 = require("./RecommendationEvent"); -var RECOMMENDATION_CLICK_EVENT_TYPE = 'recommendation-click'; var RecommendationClickEvent = /** @class */ (function (_super) { __extends(RecommendationClickEvent, _super); function RecommendationClickEvent(label, productId, name, campaignId, campaignHash, parameters) { - return _super.call(this, RECOMMENDATION_CLICK_EVENT_TYPE, label, productId, name, campaignId, campaignHash, parameters || {}) || this; + return _super.call(this, label, 'recommendation.click', productId, name, campaignId, campaignHash, parameters || {}) || this; } return RecommendationClickEvent; }(RecommendationEvent_1.RecommendationEvent)); diff --git a/lib/classes/events/recommendation/RecommendationEvent.d.ts b/lib/classes/events/recommendation/RecommendationEvent.d.ts index fdae887..11ab0e8 100644 --- a/lib/classes/events/recommendation/RecommendationEvent.d.ts +++ b/lib/classes/events/recommendation/RecommendationEvent.d.ts @@ -1,6 +1,6 @@ -import { Event } from '../Event'; -declare class RecommendationEvent extends Event { - constructor(type: string, label: string, productId: string, name: string, campaignId: string, campaignHash: string, parameters?: object); +import { CustomEvent } from '../CustomEvent'; +declare class RecommendationEvent extends CustomEvent { + constructor(label: string, action: string, productId: string, name: string, campaignId: string, campaignHash: string, parameters?: object); setCategory(category: string): void; setUrl(url: string): void; } diff --git a/lib/classes/events/recommendation/RecommendationEvent.js b/lib/classes/events/recommendation/RecommendationEvent.js index ea02f10..42626d8 100644 --- a/lib/classes/events/recommendation/RecommendationEvent.js +++ b/lib/classes/events/recommendation/RecommendationEvent.js @@ -14,7 +14,7 @@ var __extends = (this && this.__extends) || (function () { })(); Object.defineProperty(exports, "__esModule", { value: true }); exports.RecommendationEvent = void 0; -var Event_1 = require("../Event"); +var CustomEvent_1 = require("../CustomEvent"); var Params; (function (Params) { Params["PRODUCT_ID"] = "productId"; @@ -26,8 +26,8 @@ var Params; })(Params || (Params = {})); var RecommendationEvent = /** @class */ (function (_super) { __extends(RecommendationEvent, _super); - function RecommendationEvent(type, label, productId, name, campaignId, campaignHash, parameters) { - var _this = _super.call(this, type, label, null, parameters || {}) || this; + function RecommendationEvent(label, action, productId, name, campaignId, campaignHash, parameters) { + var _this = _super.call(this, label, action, parameters || {}) || this; _this.parameters[Params.PRODUCT_ID] = productId; _this.parameters[Params.NAME] = name; _this.parameters[Params.CAMPAIGN_ID] = campaignId; @@ -41,5 +41,5 @@ var RecommendationEvent = /** @class */ (function (_super) { this.parameters[Params.URL] = url; }; return RecommendationEvent; -}(Event_1.Event)); +}(CustomEvent_1.CustomEvent)); exports.RecommendationEvent = RecommendationEvent; diff --git a/lib/classes/events/recommendation/RecommendationSeenEvent.js b/lib/classes/events/recommendation/RecommendationSeenEvent.js index 6c891e1..1ee21f1 100644 --- a/lib/classes/events/recommendation/RecommendationSeenEvent.js +++ b/lib/classes/events/recommendation/RecommendationSeenEvent.js @@ -15,11 +15,10 @@ var __extends = (this && this.__extends) || (function () { Object.defineProperty(exports, "__esModule", { value: true }); exports.RecommendationSeenEvent = void 0; var RecommendationEvent_1 = require("./RecommendationEvent"); -var RECOMMENDATION_SEEN_EVENT_TYPE = 'recommendation-seen'; var RecommendationSeenEvent = /** @class */ (function (_super) { __extends(RecommendationSeenEvent, _super); function RecommendationSeenEvent(label, productId, name, campaignId, campaignHash, parameters) { - return _super.call(this, RECOMMENDATION_SEEN_EVENT_TYPE, label, productId, name, campaignId, campaignHash, parameters || {}) || this; + return _super.call(this, label, 'recommendation.seen', productId, name, campaignId, campaignHash, parameters || {}) || this; } return RecommendationSeenEvent; }(RecommendationEvent_1.RecommendationEvent)); diff --git a/lib/classes/models/Client/ClientSignOutMode.d.ts b/lib/classes/models/Client/ClientSignOutMode.d.ts new file mode 100644 index 0000000..578099c --- /dev/null +++ b/lib/classes/models/Client/ClientSignOutMode.d.ts @@ -0,0 +1,6 @@ +declare enum ClientSignOutMode { + SignOut = "SIGN_OUT", + SignOutWithSessionDestroy = "SIGN_OUT_WITH_SESSION_DESTROY" +} +declare function ClientSignOutModeToString(mode: ClientSignOutMode): string; +export { ClientSignOutMode, ClientSignOutModeToString }; diff --git a/lib/classes/models/Client/ClientSignOutMode.js b/lib/classes/models/Client/ClientSignOutMode.js new file mode 100644 index 0000000..7a02d9d --- /dev/null +++ b/lib/classes/models/Client/ClientSignOutMode.js @@ -0,0 +1,13 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.ClientSignOutModeToString = exports.ClientSignOutMode = void 0; +var ClientSignOutMode; +(function (ClientSignOutMode) { + ClientSignOutMode["SignOut"] = "SIGN_OUT"; + ClientSignOutMode["SignOutWithSessionDestroy"] = "SIGN_OUT_WITH_SESSION_DESTROY"; +})(ClientSignOutMode || (ClientSignOutMode = {})); +exports.ClientSignOutMode = ClientSignOutMode; +function ClientSignOutModeToString(mode) { + return mode; +} +exports.ClientSignOutModeToString = ClientSignOutModeToString; diff --git a/lib/classes/models/Misc/InAppMessageData.d.ts b/lib/classes/models/Misc/InAppMessageData.d.ts new file mode 100644 index 0000000..3d08dc4 --- /dev/null +++ b/lib/classes/models/Misc/InAppMessageData.d.ts @@ -0,0 +1,15 @@ +import { BaseModel } from './../BaseModel'; +interface IInAppMessageData { + campaignHash: string; + variantIdentifier: string; + additionalParameters?: object; + isTest: boolean; +} +declare class InAppMessageData extends BaseModel { + campaignHash: string; + variantIdentifier: string; + additionalParameters?: object; + isTest: boolean; + constructor(modelObject: IInAppMessageData); +} +export { IInAppMessageData, InAppMessageData }; diff --git a/lib/classes/models/Misc/InAppMessageData.js b/lib/classes/models/Misc/InAppMessageData.js new file mode 100644 index 0000000..5959869 --- /dev/null +++ b/lib/classes/models/Misc/InAppMessageData.js @@ -0,0 +1,30 @@ +"use strict"; +var __extends = (this && this.__extends) || (function () { + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return extendStatics(d, b); + }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +Object.defineProperty(exports, "__esModule", { value: true }); +exports.InAppMessageData = void 0; +var BaseModel_1 = require("./../BaseModel"); +var InAppMessageData = /** @class */ (function (_super) { + __extends(InAppMessageData, _super); + function InAppMessageData(modelObject) { + var _this = _super.call(this, modelObject) || this; + _this.campaignHash = modelObject.campaignHash; + _this.variantIdentifier = modelObject.variantIdentifier; + _this.additionalParameters = modelObject.additionalParameters; + _this.isTest = modelObject.isTest; + return _this; + } + return InAppMessageData; +}(BaseModel_1.BaseModel)); +exports.InAppMessageData = InAppMessageData; diff --git a/lib/classes/models/Token/Token.d.ts b/lib/classes/models/Token/Token.d.ts index 4fd6044..639d8d4 100644 --- a/lib/classes/models/Token/Token.d.ts +++ b/lib/classes/models/Token/Token.d.ts @@ -2,13 +2,17 @@ import { BaseModel } from './../BaseModel'; import { TokenOrigin } from './TokenOrigin'; interface IToken { tokenString: string; - tokenOrigin: string; expirationDate: number; + rlm: string; + origin: string; + customId?: string; } declare class Token extends BaseModel { tokenString: string; - tokenOrigin: TokenOrigin; expirationDate: Date; + rlm: string; + origin: TokenOrigin; + customId?: string; constructor(modelObject: IToken); } export { Token }; diff --git a/lib/classes/models/Token/Token.js b/lib/classes/models/Token/Token.js index e5f9e3b..48f522f 100644 --- a/lib/classes/models/Token/Token.js +++ b/lib/classes/models/Token/Token.js @@ -21,8 +21,12 @@ var Token = /** @class */ (function (_super) { function Token(modelObject) { var _this = _super.call(this, modelObject) || this; _this.tokenString = modelObject.tokenString; - _this.tokenOrigin = TokenOrigin_1.TokenOriginFromString(modelObject.tokenOrigin); _this.expirationDate = new Date(modelObject.expirationDate * 1000); + _this.rlm = modelObject.rlm; + _this.origin = TokenOrigin_1.TokenOriginFromString(modelObject.origin); + if (modelObject.customId !== undefined && modelObject.customId != null) { + _this.customId = modelObject.customId; + } return _this; } return Token; diff --git a/lib/classes/models/Vouchers/VoucherCodesData.d.ts b/lib/classes/models/Vouchers/VoucherCodesData.d.ts index 05cd87c..20f55a0 100644 --- a/lib/classes/models/Vouchers/VoucherCodesData.d.ts +++ b/lib/classes/models/Vouchers/VoucherCodesData.d.ts @@ -2,7 +2,7 @@ import { BaseModel } from '../BaseModel'; interface IVoucherCodesData { code: string; status: string; - clientId: string; + clientId: number; clientUuid?: string; poolUuid: string; expireIn?: number; @@ -14,7 +14,7 @@ interface IVoucherCodesData { declare class VoucherCodesData extends BaseModel { code: string; status: string; - clientId: string; + clientId: number; clientUuid?: string; poolUuid: string; expireIn?: Date; diff --git a/lib/config/import_models.d.ts b/lib/config/import_models.d.ts index 2992f23..5686bc1 100644 --- a/lib/config/import_models.d.ts +++ b/lib/config/import_models.d.ts @@ -7,6 +7,7 @@ export { IClientAccountRegisterContext, ClientAccountRegisterContext } from './. export { IClientAccountUpdateContext, ClientAccountUpdateContext } from './../classes/models/Client/ClientAccountUpdateContext'; export { IClientAgreements, ClientAgreements } from './../classes/models/Client/ClientAgreements'; export { ClientSex, ClientSexFromString, ClientSexToString } from './../classes/models/Client/ClientSex'; +export { ClientSignOutMode, ClientSignOutModeToString } from './../classes/models/Client/ClientSignOutMode'; export { ClientIdentityProvider } from './../classes/models/Client/ClientIdentityProvider'; export { ClientSessionEndReason, ClientSessionEndReasonFromString, ClientSessionEndReasonToString } from './../classes/models/Client/ClientSessionEndReason'; export { IClientConditionalAuthResult, ClientConditionalAuthResult } from '../classes/models/Client/ClientConditionalAuthResult'; @@ -39,3 +40,4 @@ export { DocumentsApiQuery } from './../classes/api_queries/DocumentsApiQuery'; export { DocumentsApiQueryType } from './../classes/api_queries/DocumentsApiQueryType'; export { Token } from './../classes/models/Token/Token'; export { TokenOrigin, TokenOriginFromString, TokenOriginToString } from './../classes/models/Token/TokenOrigin'; +export { InAppMessageData } from './../classes/models/Misc/InAppMessageData'; diff --git a/lib/config/import_models.js b/lib/config/import_models.js index d115df8..f17dc02 100644 --- a/lib/config/import_models.js +++ b/lib/config/import_models.js @@ -21,6 +21,9 @@ var ClientSex_1 = require("./../classes/models/Client/ClientSex"); Object.defineProperty(exports, "ClientSex", { enumerable: true, get: function () { return ClientSex_1.ClientSex; } }); Object.defineProperty(exports, "ClientSexFromString", { enumerable: true, get: function () { return ClientSex_1.ClientSexFromString; } }); Object.defineProperty(exports, "ClientSexToString", { enumerable: true, get: function () { return ClientSex_1.ClientSexToString; } }); +var ClientSignOutMode_1 = require("./../classes/models/Client/ClientSignOutMode"); +Object.defineProperty(exports, "ClientSignOutMode", { enumerable: true, get: function () { return ClientSignOutMode_1.ClientSignOutMode; } }); +Object.defineProperty(exports, "ClientSignOutModeToString", { enumerable: true, get: function () { return ClientSignOutMode_1.ClientSignOutModeToString; } }); var ClientIdentityProvider_1 = require("./../classes/models/Client/ClientIdentityProvider"); Object.defineProperty(exports, "ClientIdentityProvider", { enumerable: true, get: function () { return ClientIdentityProvider_1.ClientIdentityProvider; } }); var ClientSessionEndReason_1 = require("./../classes/models/Client/ClientSessionEndReason"); @@ -96,3 +99,6 @@ var TokenOrigin_1 = require("./../classes/models/Token/TokenOrigin"); Object.defineProperty(exports, "TokenOrigin", { enumerable: true, get: function () { return TokenOrigin_1.TokenOrigin; } }); Object.defineProperty(exports, "TokenOriginFromString", { enumerable: true, get: function () { return TokenOrigin_1.TokenOriginFromString; } }); Object.defineProperty(exports, "TokenOriginToString", { enumerable: true, get: function () { return TokenOrigin_1.TokenOriginToString; } }); +// MISC +var InAppMessageData_1 = require("./../classes/models/Misc/InAppMessageData"); +Object.defineProperty(exports, "InAppMessageData", { enumerable: true, get: function () { return InAppMessageData_1.InAppMessageData; } }); diff --git a/lib/main/modules/ClientModule.d.ts b/lib/main/modules/ClientModule.d.ts index 2d334e5..fa338dc 100644 --- a/lib/main/modules/ClientModule.d.ts +++ b/lib/main/modules/ClientModule.d.ts @@ -7,8 +7,9 @@ import { ClientOAuthAuthenticationContext } from '../../classes/models/Client/Cl import { ClientFacebookAuthenticationContext } from '../../classes/models/Client/ClientFacebookAuthenticationContext'; import { ClientAppleSignInAuthenticationContext } from '../../classes/models/Client/ClientAppleSignInAuthenticationContext'; import { ClientIdentityProvider } from '../../classes/models/Client/ClientIdentityProvider'; -import { ClientSessionEndReason } from '../../classes/models/Client/ClientSessionEndReason'; import { ClientConditionalAuthResult } from '../../classes/models/Client/ClientConditionalAuthResult'; +import { ClientSessionEndReason } from '../../classes/models/Client/ClientSessionEndReason'; +import { ClientSignOutMode } from '../../classes/models/Client/ClientSignOutMode'; import { Token } from './../../classes/models/Token/Token'; import { Error } from './../../classes/types/Error'; interface IClientStateChangeListener { @@ -53,6 +54,7 @@ declare class ClientModule extends Module { authenticateByAppleSignInIfRegistered(identityToken: string, authID: string, onSuccess: () => void, onError: (error: Error) => void): void; isSignedIn(): boolean; signOut(): void; + signOutWithMode(mode: ClientSignOutMode): void; refreshToken(onSuccess: () => void, onError: (error: Error) => void): void; retrieveToken(onSuccess: (token: Token) => void, onError: (error: Error) => void): void; getUUID(): string; diff --git a/lib/main/modules/ClientModule.js b/lib/main/modules/ClientModule.js index aafecc0..c5a8f4b 100644 --- a/lib/main/modules/ClientModule.js +++ b/lib/main/modules/ClientModule.js @@ -19,8 +19,9 @@ var SyneriseModuleConnector_1 = require("./../communication/SyneriseModuleConnec var BaseModel_1 = require("./../../classes/models/BaseModel"); var BaseModule_1 = require("./BaseModule"); var ClientAccountInformation_1 = require("./../../classes/models/Client/ClientAccountInformation"); -var ClientSessionEndReason_1 = require("../../classes/models/Client/ClientSessionEndReason"); var ClientConditionalAuthResult_1 = require("../../classes/models/Client/ClientConditionalAuthResult"); +var ClientSessionEndReason_1 = require("../../classes/models/Client/ClientSessionEndReason"); +var ClientSignOutMode_1 = require("../../classes/models/Client/ClientSignOutMode"); var Token_1 = require("./../../classes/models/Token/Token"); var SyneriseModuleEmitter_1 = require("./../communication/SyneriseModuleEmitter"); var RNClient = react_native_1.NativeModules.RNClient; @@ -128,6 +129,10 @@ var ClientModule = /** @class */ (function (_super) { ClientModule.prototype.signOut = function () { SyneriseModuleConnector_1.SyneriseModuleConnector.invokeMethodWithReturnValue(RNClient.signOut, []); }; + ClientModule.prototype.signOutWithMode = function (mode) { + var modeObject = ClientSignOutMode_1.ClientSignOutModeToString(mode); + SyneriseModuleConnector_1.SyneriseModuleConnector.invokeMethodWithReturnValue(RNClient.signOutWithMode, [modeObject]); + }; ClientModule.prototype.refreshToken = function (onSuccess, onError) { SyneriseModuleConnector_1.SyneriseModuleConnector.invokeMethodWithCallback(RNClient.refreshToken, [], onSuccess, onError); }; diff --git a/lib/main/modules/InjectorModule.d.ts b/lib/main/modules/InjectorModule.d.ts index 8de11a5..8c964bd 100644 --- a/lib/main/modules/InjectorModule.d.ts +++ b/lib/main/modules/InjectorModule.d.ts @@ -1,4 +1,5 @@ import { BaseModule as Module } from './BaseModule'; +import { InAppMessageData } from './../../classes/models/Misc/InAppMessageData'; import { Error } from './../../classes/types/Error'; interface IInjectorListener { onOpenUrl(url: string): void; @@ -14,40 +15,44 @@ interface IInjectorWalkthroughListener { onPresent?(): void; onHide?(): void; } +interface IInjectorInAppMessageListener { + onPresent?(data: InAppMessageData): void; + onHide?(data: InAppMessageData): void; + onOpenUrl(data: InAppMessageData, url: string): void; + onDeepLink(data: InAppMessageData, deepLink: string): void; + onCustomAction?(data: InAppMessageData, name: string, parameters: object): void; +} declare class InjectorModule extends Module { private static _instance; private listener; private bannerListener; private walkthroughListener; + private inAppMessageListener; static instance(): InjectorModule; private constructor(); private configureListeners; private configureMainListener; private configureBannerListener; private configureWalkthroughListener; - private configureUrlActionListener; - private configureDeepLinkActionListener; - private configureBannerPresentedListener; - private configureBannerHiddenListener; - private configureWalkthroughLoadedListener; - private configureWalkthroughLoadingErrorListener; - private configureWalkthroughPresentedListener; - private configureWalkthroughHiddenListener; + private configureInAppMessageListener; private onUrlAction; private onDeepLinkAction; - private onPresentBanner; - private onHideBanner; - private onLoadWalkthrough; - private onLoadingErrorWalkthrough; - private onPresentWalkthrough; - private onHideWalkthrough; + private onBannerPresent; + private onBannerHide; + private onWalkthroughLoad; + private onWalkthroughLoadingError; + private onWalkthroughPresent; + private onWalkthroughHide; + private onInAppMessagePresent; + private onInAppMessageHide; + private onInAppMessageOpenUrlAction; + private onInAppMessageDeepLinkAction; + private onInAppMessageCustomAction; setListener(listener: IInjectorListener): void; setBannerListener(listener: IInjectorBannerListener): void; setShouldBannerPresentFlag(shouldPresentBanner: boolean): void; - fetchBanners(onSuccess: (banners: Array) => void, onError: (error: Error) => void): void; - getBanners(): Array; - showBanner(banner: object, markPresented: boolean): void; setWalkthroughListener(listener: IInjectorWalkthroughListener): void; + setInAppMessageListener(listener: IInjectorInAppMessageListener): void; getWalkthrough(): void; showWalkthrough(): void; isWalkthroughLoaded(): boolean; diff --git a/lib/main/modules/InjectorModule.js b/lib/main/modules/InjectorModule.js index b3d9829..8a5e412 100644 --- a/lib/main/modules/InjectorModule.js +++ b/lib/main/modules/InjectorModule.js @@ -18,6 +18,7 @@ var react_native_1 = require("react-native"); var BaseModule_1 = require("./BaseModule"); var SyneriseModuleConnector_1 = require("./../communication/SyneriseModuleConnector"); var SyneriseModuleEmitter_1 = require("./../communication/SyneriseModuleEmitter"); +var InAppMessageData_1 = require("./../../classes/models/Misc/InAppMessageData"); var Error_1 = require("./../../classes/types/Error"); var RNInjector = react_native_1.NativeModules.RNInjector; var InjectorModule = /** @class */ (function (_super) { @@ -34,37 +35,71 @@ var InjectorModule = /** @class */ (function (_super) { _this.listener.onDeepLink(event.deepLink); } }; - _this.onPresentBanner = function () { + _this.onBannerPresent = function () { if (_this.bannerListener !== undefined && _this.bannerListener.onPresent != undefined) { _this.bannerListener.onPresent(); } }; - _this.onHideBanner = function () { + _this.onBannerHide = function () { if (_this.bannerListener !== undefined && _this.bannerListener.onHide != undefined) { _this.bannerListener.onHide(); } }; - _this.onLoadWalkthrough = function () { + _this.onWalkthroughLoad = function () { if (_this.walkthroughListener !== undefined && _this.walkthroughListener.onLoad != undefined) { _this.walkthroughListener.onLoad(); } }; - _this.onLoadingErrorWalkthrough = function (errorObject) { + _this.onWalkthroughLoadingError = function (errorObject) { if (_this.walkthroughListener !== undefined && _this.walkthroughListener.onLoadingError != undefined) { var error = Error_1.ErrorMapper.getErrorInstance(errorObject); _this.walkthroughListener.onLoadingError(error); } }; - _this.onPresentWalkthrough = function () { + _this.onWalkthroughPresent = function () { if (_this.walkthroughListener !== undefined && _this.walkthroughListener.onPresent != undefined) { _this.walkthroughListener.onPresent(); } }; - _this.onHideWalkthrough = function () { + _this.onWalkthroughHide = function () { if (_this.walkthroughListener !== undefined && _this.walkthroughListener.onHide != undefined) { _this.walkthroughListener.onHide(); } }; + _this.onInAppMessagePresent = function (event) { + if (_this.inAppMessageListener !== undefined && _this.inAppMessageListener.onPresent != undefined) { + var data = new InAppMessageData_1.InAppMessageData(event.data); + _this.inAppMessageListener.onPresent(data); + } + }; + _this.onInAppMessageHide = function (event) { + if (_this.inAppMessageListener !== undefined && _this.inAppMessageListener.onHide != undefined) { + var data = new InAppMessageData_1.InAppMessageData(event.data); + _this.inAppMessageListener.onHide(data); + } + }; + _this.onInAppMessageOpenUrlAction = function (event) { + if (_this.inAppMessageListener !== undefined && _this.inAppMessageListener.onOpenUrl != undefined) { + var data = new InAppMessageData_1.InAppMessageData(event.data); + var url = event.url; + _this.inAppMessageListener.onOpenUrl(data, url); + } + }; + _this.onInAppMessageDeepLinkAction = function (event) { + if (_this.inAppMessageListener !== undefined && _this.inAppMessageListener.onDeepLink != undefined) { + var data = new InAppMessageData_1.InAppMessageData(event.data); + var deepLink = event.deepLink; + _this.inAppMessageListener.onDeepLink(data, deepLink); + } + }; + _this.onInAppMessageCustomAction = function (event) { + if (_this.inAppMessageListener !== undefined && _this.inAppMessageListener.onCustomAction != undefined) { + var data = new InAppMessageData_1.InAppMessageData(event.data); + var name_1 = event.name; + var parameters = event.parameters; + _this.inAppMessageListener.onCustomAction(data, name_1, parameters); + } + }; _this.configureListeners(); return _this; } @@ -78,44 +113,28 @@ var InjectorModule = /** @class */ (function (_super) { this.configureMainListener(); this.configureBannerListener(); this.configureWalkthroughListener(); + this.configureInAppMessageListener(); }; InjectorModule.prototype.configureMainListener = function () { - this.configureUrlActionListener(); - this.configureDeepLinkActionListener(); - }; - InjectorModule.prototype.configureBannerListener = function () { - this.configureBannerPresentedListener(); - this.configureBannerHiddenListener(); - }; - InjectorModule.prototype.configureWalkthroughListener = function () { - this.configureWalkthroughLoadedListener(); - this.configureWalkthroughLoadingErrorListener(); - this.configureWalkthroughPresentedListener(); - this.configureWalkthroughHiddenListener(); - }; - InjectorModule.prototype.configureUrlActionListener = function () { SyneriseModuleEmitter_1.SyneriseModuleEmitter.getEmitter().addListener(RNInjector.URL_ACTION_LISTENER_KEY, this.onUrlAction); - }; - InjectorModule.prototype.configureDeepLinkActionListener = function () { SyneriseModuleEmitter_1.SyneriseModuleEmitter.getEmitter().addListener(RNInjector.DEEPLINK_ACTION_LISTENER_KEY, this.onDeepLinkAction); }; - InjectorModule.prototype.configureBannerPresentedListener = function () { - SyneriseModuleEmitter_1.SyneriseModuleEmitter.getEmitter().addListener(RNInjector.BANNER_PRESENTED_LISTENER_KEY, this.onPresentBanner); - }; - InjectorModule.prototype.configureBannerHiddenListener = function () { - SyneriseModuleEmitter_1.SyneriseModuleEmitter.getEmitter().addListener(RNInjector.BANNER_HIDDEN_LISTENER_KEY, this.onHideBanner); - }; - InjectorModule.prototype.configureWalkthroughLoadedListener = function () { - SyneriseModuleEmitter_1.SyneriseModuleEmitter.getEmitter().addListener(RNInjector.WALKTHROUGH_LOADED_LISTENER_KEY, this.onLoadWalkthrough); - }; - InjectorModule.prototype.configureWalkthroughLoadingErrorListener = function () { - SyneriseModuleEmitter_1.SyneriseModuleEmitter.getEmitter().addListener(RNInjector.WALKTHROUGH_LOADING_ERROR_LISTENER_KEY, this.onLoadingErrorWalkthrough); - }; - InjectorModule.prototype.configureWalkthroughPresentedListener = function () { - SyneriseModuleEmitter_1.SyneriseModuleEmitter.getEmitter().addListener(RNInjector.WALKTHROUGH_PRESENTED_LISTENER_KEY, this.onPresentWalkthrough); + InjectorModule.prototype.configureBannerListener = function () { + SyneriseModuleEmitter_1.SyneriseModuleEmitter.getEmitter().addListener(RNInjector.BANNER_PRESENTED_LISTENER_KEY, this.onBannerPresent); + SyneriseModuleEmitter_1.SyneriseModuleEmitter.getEmitter().addListener(RNInjector.BANNER_HIDDEN_LISTENER_KEY, this.onBannerHide); }; - InjectorModule.prototype.configureWalkthroughHiddenListener = function () { - SyneriseModuleEmitter_1.SyneriseModuleEmitter.getEmitter().addListener(RNInjector.WALKTHROUGH_HIDDEN_LISTENER_KEY, this.onHideWalkthrough); + InjectorModule.prototype.configureWalkthroughListener = function () { + SyneriseModuleEmitter_1.SyneriseModuleEmitter.getEmitter().addListener(RNInjector.WALKTHROUGH_LOADED_LISTENER_KEY, this.onWalkthroughLoad); + SyneriseModuleEmitter_1.SyneriseModuleEmitter.getEmitter().addListener(RNInjector.WALKTHROUGH_LOADING_ERROR_LISTENER_KEY, this.onWalkthroughLoadingError); + SyneriseModuleEmitter_1.SyneriseModuleEmitter.getEmitter().addListener(RNInjector.WALKTHROUGH_PRESENTED_LISTENER_KEY, this.onWalkthroughPresent); + SyneriseModuleEmitter_1.SyneriseModuleEmitter.getEmitter().addListener(RNInjector.WALKTHROUGH_HIDDEN_LISTENER_KEY, this.onWalkthroughHide); + }; + InjectorModule.prototype.configureInAppMessageListener = function () { + SyneriseModuleEmitter_1.SyneriseModuleEmitter.getEmitter().addListener(RNInjector.IN_APP_MESSAGE_PRESENTED_LISTENER_KEY, this.onInAppMessagePresent); + SyneriseModuleEmitter_1.SyneriseModuleEmitter.getEmitter().addListener(RNInjector.IN_APP_MESSAGE_HIDDEN_LISTENER_KEY, this.onInAppMessageHide); + SyneriseModuleEmitter_1.SyneriseModuleEmitter.getEmitter().addListener(RNInjector.IN_APP_MESSAGE_URL_ACTION_LISTENER_KEY, this.onInAppMessageOpenUrlAction); + SyneriseModuleEmitter_1.SyneriseModuleEmitter.getEmitter().addListener(RNInjector.IN_APP_MESSAGE_DEEPLINK_ACTION_LISTENER_KEY, this.onInAppMessageDeepLinkAction); + SyneriseModuleEmitter_1.SyneriseModuleEmitter.getEmitter().addListener(RNInjector.IN_APP_MESSAGE_CUSTOM_ACTION_LISTENER_KEY, this.onInAppMessageCustomAction); }; InjectorModule.prototype.setListener = function (listener) { this.listener = listener; @@ -126,18 +145,12 @@ var InjectorModule = /** @class */ (function (_super) { InjectorModule.prototype.setShouldBannerPresentFlag = function (shouldPresentBanner) { SyneriseModuleConnector_1.SyneriseModuleConnector.invokeMethod(RNInjector.setShouldBannerPresentFlag, [shouldPresentBanner]); }; - InjectorModule.prototype.fetchBanners = function (onSuccess, onError) { - SyneriseModuleConnector_1.SyneriseModuleConnector.invokeMethodWithCallback(RNInjector.fetchBanners, [], onSuccess, onError); - }; - InjectorModule.prototype.getBanners = function () { - return SyneriseModuleConnector_1.SyneriseModuleConnector.invokeMethodWithReturnValue(RNInjector.getBanners, []); - }; - InjectorModule.prototype.showBanner = function (banner, markPresented) { - SyneriseModuleConnector_1.SyneriseModuleConnector.invokeMethod(RNInjector.showBanner, [banner, markPresented]); - }; InjectorModule.prototype.setWalkthroughListener = function (listener) { this.walkthroughListener = listener; }; + InjectorModule.prototype.setInAppMessageListener = function (listener) { + this.inAppMessageListener = listener; + }; InjectorModule.prototype.getWalkthrough = function () { SyneriseModuleConnector_1.SyneriseModuleConnector.invokeMethod(RNInjector.getWalkthrough, []); }; diff --git a/lib/main/modules/SettingsModule.d.ts b/lib/main/modules/SettingsModule.d.ts index 77bf2be..7a0567b 100644 --- a/lib/main/modules/SettingsModule.d.ts +++ b/lib/main/modules/SettingsModule.d.ts @@ -18,6 +18,10 @@ interface ISettingsOptions { encryption?: boolean; disableInAppAlerts?: boolean; }; + inAppMessaging?: { + maxDefinitionUpdateIntervalLimit?: number; + renderingTimeout?: number; + }; injector?: { automatic?: boolean; }; @@ -42,6 +46,10 @@ declare class SettingsModule extends Module { encryption: any; disableInAppAlerts: any; }; + inAppMessaging: { + maxDefinitionUpdateIntervalLimit: any; + renderingTimeout: any; + }; injector: { automatic: any; }; diff --git a/lib/main/modules/SettingsModule.js b/lib/main/modules/SettingsModule.js index 9cbd596..56b9a2b 100644 --- a/lib/main/modules/SettingsModule.js +++ b/lib/main/modules/SettingsModule.js @@ -39,6 +39,8 @@ function mapSettingsOptionsForNativeModule(settingsOptions) { NOTIFICATIONS_ENABLED: settingsOptions.notifications && settingsOptions.notifications.enabled, NOTIFICATIONS_ENCRYPTION: settingsOptions.notifications && settingsOptions.notifications.encryption, NOTIFICATIONS_DISABLE_IN_APP_ALERTS: settingsOptions.notifications && settingsOptions.notifications.disableInAppAlerts, + IN_APP_MAX_DEFINITION_UPDATE_INTERVAL_LIMIT: settingsOptions.inAppMessaging && settingsOptions.inAppMessaging.maxDefinitionUpdateIntervalLimit, + IN_APP_MESSAGING_RENDERING_TIMEOUT: settingsOptions.inAppMessaging && settingsOptions.inAppMessaging.renderingTimeout, INJECTOR_AUTOMATIC: settingsOptions.injector && settingsOptions.injector.automatic, }; } @@ -156,6 +158,20 @@ var SettingsModule = /** @class */ (function (_super) { } }, }; + _this.inAppMessaging = { + get maxDefinitionUpdateIntervalLimit() { + return getOne(RNSettings.IN_APP_MAX_DEFINITION_UPDATE_INTERVAL_LIMIT); + }, + set maxDefinitionUpdateIntervalLimit(value) { + setOne(RNSettings.IN_APP_MAX_DEFINITION_UPDATE_INTERVAL_LIMIT, value); + }, + get renderingTimeout() { + return getOne(RNSettings.IN_APP_MESSAGING_RENDERING_TIMEOUT); + }, + set renderingTimeout(value) { + setOne(RNSettings.IN_APP_MESSAGING_RENDERING_TIMEOUT, value); + }, + }; _this.injector = { get automatic() { return getOne(RNSettings.INJECTOR_AUTOMATIC); diff --git a/package.json b/package.json index 0c42b14..53b4509 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "react-native-synerise-sdk", - "version": "0.11.0", + "version": "0.12.0", "description": "React Native wrapper for Synerise SDK", "author": { "name": "Synerise", diff --git a/react-native-synerise-sdk.podspec b/react-native-synerise-sdk.podspec index 10a821c..ac32aef 100644 --- a/react-native-synerise-sdk.podspec +++ b/react-native-synerise-sdk.podspec @@ -1,8 +1,8 @@ require 'json' -package = JSON.parse(File.read('./../package.json')) +package = JSON.parse(File.read('./package.json')) -SYNERISE_SDK_FRAMEWORK_VERSION = '3.12.0' +SYNERISE_SDK_FRAMEWORK_VERSION = '4.10.1' Pod::Spec.new do |s| s.name = package['name']