Skip to content

Commit

Permalink
Release of version 0.18.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Krzysztof Kurzawa committed Jan 16, 2024
1 parent ab94923 commit 7d0a47a
Show file tree
Hide file tree
Showing 18 changed files with 159 additions and 58 deletions.
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,17 @@

All notable changes to this project will be documented in this file.

## [0.8.0] - 2024-01-16

IMPORTANT:
Due to changes in the handling of actions for URLs and deep links in Synerise campaigns, we strongly recommend comparing your configuration with the SDK documentation. Review the changes from the previous SDK version integrated into your application here:
https://hub.synerise.com//developers/mobile-sdk/campaigns/action-handling/

### Changed
- Changes in handling actions from campaigns (read important note above).
- Update of native SDK's dependencies.


## [0.17.0] - 2023-12-05

### Fixed
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Synerise React Native SDK (react-native-synerise-sdk) (0.17.0)
# Synerise React Native SDK (react-native-synerise-sdk) (0.18.0)

[![Platform](https://img.shields.io/badge/platform-iOS-orange.svg)](https://github.com/synerise/ios-sdk)
[![Platform](https://img.shields.io/badge/platform-Android-orange.svg)](https://github.com/synerise/android-sdk)
Expand Down
6 changes: 3 additions & 3 deletions android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ ext.versions = [
'minSdk' : 21,
'compileSdk' : 33,
'targetSdk' : 33,
'versionCode': 31,
'versionName': "0.17.0"
'versionCode': 32,
'versionName': "0.18.0"
]

buildscript {
Expand Down Expand Up @@ -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:5.12.0'
api 'com.synerise.sdk:synerise-mobile-sdk:5.13.2'
}

//apply from: 'publish.gradle'
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
61 changes: 45 additions & 16 deletions android/src/main/java/com/synerise/sdk/react/RNInjector.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.synerise.sdk.react;

import android.os.Handler;
import android.util.Log;

import com.facebook.react.bridge.Arguments;
Expand All @@ -10,7 +11,9 @@
import com.facebook.react.bridge.WritableArray;
import com.facebook.react.bridge.WritableMap;
import com.google.gson.Gson;
import com.synerise.sdk.core.Synerise;
import com.synerise.sdk.core.listeners.DataActionListener;
import com.synerise.sdk.core.utils.SystemUtils;
import com.synerise.sdk.error.ApiError;
import com.synerise.sdk.injector.Injector;
import com.synerise.sdk.injector.callback.InjectorSource;
Expand Down Expand Up @@ -42,6 +45,7 @@ public class RNInjector extends RNBaseModule {
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 SOURCE = "source";
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";
Expand Down Expand Up @@ -98,6 +102,16 @@ public void setBannerShouldPresentFlag(boolean flag) {
shouldBannerPresentFlag = flag;
}

@ReactMethod
public void handleOpenUrlBySDK(String url) {
SystemUtils.openURL(Synerise.getApplicationContext(), url);
}

@ReactMethod
public void handleDeepLinkBySDK(String deepLink) {
SystemUtils.openDeepLink(Synerise.getApplicationContext(), deepLink);
}

@Nullable
@Override
public Map<String, Object> getConstants() {
Expand Down Expand Up @@ -126,39 +140,54 @@ public String getName() {

protected static void initializeInjector() {
initializeInAppListener();
initializeActionInjectorListener();
initializeBannerListener();
initializeWalkthroughListener();
}

private static void onActionOpenUrl(String url) {
WritableMap data = Arguments.createMap();
data.putString(URL, url);
sendEventToJs(OPEN_URL_VALUE, data, reactApplicationContext);
}

private static void onActionDeepLink(String deepLink) {
WritableMap data = Arguments.createMap();
data.putString(DEEP_LINK, deepLink);
sendEventToJs(DEEP_LINK_VALUE, data, reactApplicationContext);
}

private static void initializeActionInjectorListener() {
protected static void initializeActionInjectorListener() {
InjectorActionHandler.setOnInjectorListener(new OnInjectorListener() {
@Override
public boolean onOpenUrl(InjectorSource injectorSource, String url) {
onActionOpenUrl(url);
Handler handler = new android.os.Handler();
handler.postDelayed(new Runnable() {
@Override
public void run() {
onActionOpenUrl(url, injectorSource.name());
}
}, 300);

return injectorSource != InjectorSource.WALKTHROUGH;
}

@Override
public boolean onDeepLink(InjectorSource injectorSource, String deepLink) {
onActionDeepLink(deepLink);
Handler handler = new android.os.Handler();
handler.postDelayed(new Runnable() {
@Override
public void run() {
onActionDeepLink(deepLink, injectorSource.name());
}
}, 300);

return injectorSource != InjectorSource.WALKTHROUGH;
}
});
}

private static void onActionOpenUrl(String url, String source) {
WritableMap data = Arguments.createMap();
data.putString(URL, url);
data.putString(SOURCE, source);
sendEventToJs(OPEN_URL_VALUE, data, reactApplicationContext);
}

private static void onActionDeepLink(String deepLink, String source) {
WritableMap data = Arguments.createMap();
data.putString(DEEP_LINK, deepLink);
data.putString(SOURCE, source);
sendEventToJs(DEEP_LINK_VALUE, data, reactApplicationContext);
}

private static void initializeInAppListener() {
Injector.setOnInAppListener(new OnInAppListener() {
@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.util.Log;

import com.facebook.react.bridge.Arguments;
import com.facebook.react.bridge.Callback;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import android.app.Application;
import android.content.Context;
import android.content.pm.ApplicationInfo;
import android.util.Log;

import com.synerise.sdk.core.Synerise;
import com.synerise.sdk.core.types.enums.HostApplicationType;
Expand All @@ -16,12 +17,12 @@ public class RNSyneriseInitializer {
public Boolean isCrashHandlingEnabled;
public static volatile boolean isInitialized = false;

public static final String SDK_PLUGIN_VERSION = "0.17.0";
public static final String SDK_PLUGIN_VERSION = "0.18.0";

public void initialize(Application app) {
if (isInitialized == false) {
prepareDefaultSettings();

RNInjector.initializeActionInjectorListener();
Synerise.Builder.with(app, clientApiKey, getApplicationName(app))
.baseUrl(baseUrl)
.syneriseDebugMode(isDebugModeEnabled)
Expand All @@ -31,7 +32,6 @@ public void initialize(Application app) {
.hostApplicationType(HostApplicationType.REACT_NATIVE)
.hostApplicationSDKPluginVersion(SDK_PLUGIN_VERSION)
.build();

// Client.registerForPushCallback(RNNotifications.getNativePushListener());
isInitialized = true;
}
Expand Down
2 changes: 1 addition & 1 deletion ios/ReactNativeSynerise/Main/RNSyneriseInitializer.m
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

#import "RNSyneriseInitializer.h"

NSString * const SNRSyneriseSDKPluginVersion = @"0.17.0";
NSString * const SNRSyneriseSDKPluginVersion = @"0.18.0";

@implementation RNSyneriseInitializer

Expand Down
4 changes: 2 additions & 2 deletions ios/ReactNativeSynerise/Modules/RNInjector.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ NS_ASSUME_NONNULL_BEGIN

@interface RNInjector : RNBaseModule <RCTBridgeModule>

- (void)executeURLAction:(NSURL *)URL;
- (void)executeDeepLinkAction:(NSString *)deepLink;
- (void)executeURLAction:(NSURL *)URL activity:(SNRSyneriseActivity)activity;
- (void)executeDeepLinkAction:(NSString *)deepLink activity:(SNRSyneriseActivity)activity;

@end

Expand Down
65 changes: 54 additions & 11 deletions ios/ReactNativeSynerise/Modules/RNInjector.m
Original file line number Diff line number Diff line change
Expand Up @@ -62,26 +62,28 @@ - (instancetype)init {

#pragma mark - Public

- (void)executeURLAction:(NSURL *)URL {
[self sendURLActionToJS:URL];
- (void)executeURLAction:(NSURL *)URL activity:(SNRSyneriseActivity)activity {
[self sendURLActionToJS:URL activity:activity];
}

- (void)executeDeepLinkAction:(NSString *)deepLink {
[self sendDeepLinkActionToJS:deepLink];
- (void)executeDeepLinkAction:(NSString *)deepLink activity:(SNRSyneriseActivity)activity {
[self sendDeepLinkActionToJS:deepLink activity:activity];
}

#pragma mark - Private

- (void)sendURLActionToJS:(NSURL *)URL {
- (void)sendURLActionToJS:(NSURL *)URL activity:(SNRSyneriseActivity)activity {
NSDictionary *userInfo = @{
@"url": [URL absoluteString]
@"url": [URL absoluteString],
@"source": [self stringWithSyneriseActivity:activity]
};
[[NSNotificationCenter defaultCenter] postNotificationName:kRNSyneriseUrlActionEvent object:nil userInfo:userInfo];
}

- (void)sendDeepLinkActionToJS:(NSString *)deepLink {
- (void)sendDeepLinkActionToJS:(NSString *)deepLink activity:(SNRSyneriseActivity)activity {
NSDictionary *userInfo = @{
@"deepLink": deepLink
@"deepLink": deepLink,
@"source": [self stringWithSyneriseActivity:activity]
};
[[NSNotificationCenter defaultCenter] postNotificationName:kRNSyneriseDeepLinkActionEvent object:nil userInfo:userInfo];
}
Expand Down Expand Up @@ -234,6 +236,20 @@ - (void)SNR_inAppMessageHandledCustomAction:(SNRInAppMessageData *)data name:(NS

#pragma mark - JS Mapping

- (NSString *)stringWithSyneriseActivity:(SNRSyneriseActivity)activity {
if (activity == SNRSyneriseActivitySimplePush) {
return @"SIMPLE_PUSH";
} else if (activity == SNRSyneriseActivityBanner) {
return @"BANNER";
} else if (activity == SNRSyneriseActivityWalkthrough) {
return @"WALKTHROUGH";
} else if (activity == SNRSyneriseActivityInAppMessage) {
return @"IN_APP_MESSAGE";
} else {
return @"NOT_SPECIFIED";
}
}

- (nullable NSDictionary *)dictionaryWithInAppMessageData:(nullable SNRInAppMessageData *)model {
if (model != nil) {
NSMutableDictionary *dictionary = [@{} mutableCopy];
Expand Down Expand Up @@ -273,11 +289,38 @@ - (NSDictionary *)constantsToExport
};
}

//setBannerShouldPresentFlag(flag: boolean)
//handleOpenUrlBySDK(url: string)

RCT_EXPORT_METHOD(handleOpenUrlBySDK:(nonnull NSString *)urlString)
{
dispatch_async(dispatch_get_main_queue(), ^{
NSURL *URL = [NSURL URLWithString:urlString];
if ([[UIApplication sharedApplication] canOpenURL:URL]) {
if (@available(iOS 10, *)) {
[[UIApplication sharedApplication] openURL:URL options:@{} completionHandler:nil];
} else {
[[UIApplication sharedApplication] openURL:URL];
}
}
});
}

//handleDeepLinkBySDK(deepLink: string)

RCT_EXPORT_METHOD(setBannerShouldPresentFlag:(nonnull NSNumber *)flag)
RCT_EXPORT_METHOD(handleDeepLinkBySDK:(nonnull NSString *)deepLink)
{
_bannerShouldPresentFlag = [flag boolValue];
dispatch_async(dispatch_get_main_queue(), ^{
NSURL *deepLinkURL = [NSURL URLWithString:deepLink];
if ([[UIApplication sharedApplication] canOpenURL:deepLinkURL]) {
if (@available(iOS 10, *)) {
[[UIApplication sharedApplication] openURL:deepLinkURL options:@{} completionHandler:^(BOOL success) {

}];
} else {
[[UIApplication sharedApplication] openURL:deepLinkURL];
}
}
});
}

//getWalkthrough()
Expand Down
16 changes: 4 additions & 12 deletions ios/ReactNativeSynerise/Modules/RNSynerise.m
Original file line number Diff line number Diff line change
Expand Up @@ -74,22 +74,14 @@ - (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];
completionHandler(SNRSyneriseActivityActionNone, ^{
[[RNSyneriseManager sharedInstance].injector executeURLAction:url activity:activity];
});
}

- (void)SNR_handledActionWithDeepLink:(NSString *)deepLink activity:(SNRSyneriseActivity)activity completionHandler:(SNRSyneriseActivityCompletionHandler)completionHandler {
if (activity == SNRSyneriseActivityInAppMessage) {
return;
}

completionHandler(SNRSyneriseActivityActionHide, ^{
[[RNSyneriseManager sharedInstance].injector executeDeepLinkAction:deepLink];
completionHandler(SNRSyneriseActivityActionNone, ^{
[[RNSyneriseManager sharedInstance].injector executeDeepLinkAction:deepLink activity:activity];
});
}

Expand Down
2 changes: 1 addition & 1 deletion ios/react-native-synerise-sdk.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Pod::Spec.new do |s|
s.version = package['version']
s.summary = package['description']
s.homepage = "https://synerise.com"
s.license = "MIT"
s.license = { :type => "Apache License 2.0", :file => "LICENSE" }
s.author = { "Synerise" => "[email protected]" }
s.platform = :ios, "11.0"
s.source = { :git => "https://github.com/Synerise/react-native-synerise-sdk", :tag => s.version.to_s }
Expand Down
1 change: 1 addition & 0 deletions lib/config/import_models.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,5 @@ 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 { SyneriseSource } from './../classes/models/Misc/SyneriseSource';
export { InAppMessageData } from './../classes/models/Misc/InAppMessageData';
2 changes: 2 additions & 0 deletions lib/config/import_models.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 5 additions & 2 deletions lib/main/modules/InjectorModule.d.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { BaseModule as Module } from './BaseModule';
import { InAppMessageData } from './../../classes/models/Misc/InAppMessageData';
import { Error } from './../../classes/types/Error';
import { SyneriseSource } from '../../classes/models/Misc/SyneriseSource';
interface IInjectorListener {
onOpenUrl(url: string): void;
onDeepLink(deepLink: string): void;
onOpenUrl(url: string, source: SyneriseSource): void;
onDeepLink(deepLink: string, source: SyneriseSource): void;
}
interface IInjectorBannerListener {
onPresent?(): void;
Expand Down Expand Up @@ -105,5 +106,7 @@ declare class InjectorModule extends Module {
* @returns `true` if the loaded walkthrough is unique, otherwise returns `false`
*/
isLoadedWalkthroughUnique(): boolean;
handleOpenUrlBySDK(url: string): void;
handleDeepLinkBySDK(deepLink: string): void;
}
export { InjectorModule, IInjectorListener };
Loading

0 comments on commit 7d0a47a

Please sign in to comment.