Skip to content

Commit 7d0a47a

Browse files
author
Krzysztof Kurzawa
committed
Release of version 0.18.0
1 parent ab94923 commit 7d0a47a

18 files changed

+159
-58
lines changed

CHANGELOG.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,17 @@
22

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

5+
## [0.8.0] - 2024-01-16
6+
7+
IMPORTANT:
8+
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:
9+
https://hub.synerise.com//developers/mobile-sdk/campaigns/action-handling/
10+
11+
### Changed
12+
- Changes in handling actions from campaigns (read important note above).
13+
- Update of native SDK's dependencies.
14+
15+
516
## [0.17.0] - 2023-12-05
617

718
### Fixed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Synerise React Native SDK (react-native-synerise-sdk) (0.17.0)
1+
# Synerise React Native SDK (react-native-synerise-sdk) (0.18.0)
22

33
[![Platform](https://img.shields.io/badge/platform-iOS-orange.svg)](https://github.com/synerise/ios-sdk)
44
[![Platform](https://img.shields.io/badge/platform-Android-orange.svg)](https://github.com/synerise/android-sdk)

android/build.gradle

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ ext.versions = [
44
'minSdk' : 21,
55
'compileSdk' : 33,
66
'targetSdk' : 33,
7-
'versionCode': 31,
8-
'versionName': "0.17.0"
7+
'versionCode': 32,
8+
'versionName': "0.18.0"
99
]
1010

1111
buildscript {
@@ -57,7 +57,7 @@ repositories {
5757
dependencies {
5858
implementation 'com.facebook.react:react-native:+'
5959
implementation "com.squareup.okhttp3:logging-interceptor:4.9.1"
60-
api 'com.synerise.sdk:synerise-mobile-sdk:5.12.0'
60+
api 'com.synerise.sdk:synerise-mobile-sdk:5.13.2'
6161
}
6262

6363
//apply from: 'publish.gradle'

android/src/main/java/com/synerise/sdk/react/RNBaseModule.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package com.synerise.sdk.react;
22

3+
import android.util.Log;
4+
35
import com.facebook.react.bridge.Arguments;
46
import com.facebook.react.bridge.Callback;
57
import com.facebook.react.bridge.ReactApplicationContext;

android/src/main/java/com/synerise/sdk/react/RNInjector.java

Lines changed: 45 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package com.synerise.sdk.react;
22

3+
import android.os.Handler;
34
import android.util.Log;
45

56
import com.facebook.react.bridge.Arguments;
@@ -10,7 +11,9 @@
1011
import com.facebook.react.bridge.WritableArray;
1112
import com.facebook.react.bridge.WritableMap;
1213
import com.google.gson.Gson;
14+
import com.synerise.sdk.core.Synerise;
1315
import com.synerise.sdk.core.listeners.DataActionListener;
16+
import com.synerise.sdk.core.utils.SystemUtils;
1417
import com.synerise.sdk.error.ApiError;
1518
import com.synerise.sdk.injector.Injector;
1619
import com.synerise.sdk.injector.callback.InjectorSource;
@@ -42,6 +45,7 @@ public class RNInjector extends RNBaseModule {
4245
private static final String DEEP_LINK_KEY = "DEEPLINK_ACTION_LISTENER_KEY";
4346
private static final String OPEN_URL_VALUE = "openUrl";
4447
private static final String DEEP_LINK = "deepLink";
48+
private static final String SOURCE = "source";
4549
private static final String DEEP_LINK_VALUE = "deepLink";
4650
private static final String BANNER_PRESENTED_KEY = "BANNER_PRESENTED_LISTENER_KEY";
4751
private static final String BANNER_HIDDEN_KEY = "BANNER_HIDDEN_LISTENER_KEY";
@@ -98,6 +102,16 @@ public void setBannerShouldPresentFlag(boolean flag) {
98102
shouldBannerPresentFlag = flag;
99103
}
100104

105+
@ReactMethod
106+
public void handleOpenUrlBySDK(String url) {
107+
SystemUtils.openURL(Synerise.getApplicationContext(), url);
108+
}
109+
110+
@ReactMethod
111+
public void handleDeepLinkBySDK(String deepLink) {
112+
SystemUtils.openDeepLink(Synerise.getApplicationContext(), deepLink);
113+
}
114+
101115
@Nullable
102116
@Override
103117
public Map<String, Object> getConstants() {
@@ -126,39 +140,54 @@ public String getName() {
126140

127141
protected static void initializeInjector() {
128142
initializeInAppListener();
129-
initializeActionInjectorListener();
130143
initializeBannerListener();
131144
initializeWalkthroughListener();
132145
}
133146

134-
private static void onActionOpenUrl(String url) {
135-
WritableMap data = Arguments.createMap();
136-
data.putString(URL, url);
137-
sendEventToJs(OPEN_URL_VALUE, data, reactApplicationContext);
138-
}
139-
140-
private static void onActionDeepLink(String deepLink) {
141-
WritableMap data = Arguments.createMap();
142-
data.putString(DEEP_LINK, deepLink);
143-
sendEventToJs(DEEP_LINK_VALUE, data, reactApplicationContext);
144-
}
145-
146-
private static void initializeActionInjectorListener() {
147+
protected static void initializeActionInjectorListener() {
147148
InjectorActionHandler.setOnInjectorListener(new OnInjectorListener() {
148149
@Override
149150
public boolean onOpenUrl(InjectorSource injectorSource, String url) {
150-
onActionOpenUrl(url);
151+
Handler handler = new android.os.Handler();
152+
handler.postDelayed(new Runnable() {
153+
@Override
154+
public void run() {
155+
onActionOpenUrl(url, injectorSource.name());
156+
}
157+
}, 300);
158+
151159
return injectorSource != InjectorSource.WALKTHROUGH;
152160
}
153161

154162
@Override
155163
public boolean onDeepLink(InjectorSource injectorSource, String deepLink) {
156-
onActionDeepLink(deepLink);
164+
Handler handler = new android.os.Handler();
165+
handler.postDelayed(new Runnable() {
166+
@Override
167+
public void run() {
168+
onActionDeepLink(deepLink, injectorSource.name());
169+
}
170+
}, 300);
171+
157172
return injectorSource != InjectorSource.WALKTHROUGH;
158173
}
159174
});
160175
}
161176

177+
private static void onActionOpenUrl(String url, String source) {
178+
WritableMap data = Arguments.createMap();
179+
data.putString(URL, url);
180+
data.putString(SOURCE, source);
181+
sendEventToJs(OPEN_URL_VALUE, data, reactApplicationContext);
182+
}
183+
184+
private static void onActionDeepLink(String deepLink, String source) {
185+
WritableMap data = Arguments.createMap();
186+
data.putString(DEEP_LINK, deepLink);
187+
data.putString(SOURCE, source);
188+
sendEventToJs(DEEP_LINK_VALUE, data, reactApplicationContext);
189+
}
190+
162191
private static void initializeInAppListener() {
163192
Injector.setOnInAppListener(new OnInAppListener() {
164193
@Override

android/src/main/java/com/synerise/sdk/react/RNNotifications.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import android.os.Bundle;
44
import android.os.Handler;
55
import android.os.Looper;
6+
import android.util.Log;
67

78
import com.facebook.react.bridge.Arguments;
89
import com.facebook.react.bridge.Callback;

android/src/main/java/com/synerise/sdk/react/RNSyneriseInitializer.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import android.app.Application;
44
import android.content.Context;
55
import android.content.pm.ApplicationInfo;
6+
import android.util.Log;
67

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

19-
public static final String SDK_PLUGIN_VERSION = "0.17.0";
20+
public static final String SDK_PLUGIN_VERSION = "0.18.0";
2021

2122
public void initialize(Application app) {
2223
if (isInitialized == false) {
2324
prepareDefaultSettings();
24-
25+
RNInjector.initializeActionInjectorListener();
2526
Synerise.Builder.with(app, clientApiKey, getApplicationName(app))
2627
.baseUrl(baseUrl)
2728
.syneriseDebugMode(isDebugModeEnabled)
@@ -31,7 +32,6 @@ public void initialize(Application app) {
3132
.hostApplicationType(HostApplicationType.REACT_NATIVE)
3233
.hostApplicationSDKPluginVersion(SDK_PLUGIN_VERSION)
3334
.build();
34-
3535
// Client.registerForPushCallback(RNNotifications.getNativePushListener());
3636
isInitialized = true;
3737
}

ios/ReactNativeSynerise/Main/RNSyneriseInitializer.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
#import "RNSyneriseInitializer.h"
1010

11-
NSString * const SNRSyneriseSDKPluginVersion = @"0.17.0";
11+
NSString * const SNRSyneriseSDKPluginVersion = @"0.18.0";
1212

1313
@implementation RNSyneriseInitializer
1414

ios/ReactNativeSynerise/Modules/RNInjector.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ NS_ASSUME_NONNULL_BEGIN
1212

1313
@interface RNInjector : RNBaseModule <RCTBridgeModule>
1414

15-
- (void)executeURLAction:(NSURL *)URL;
16-
- (void)executeDeepLinkAction:(NSString *)deepLink;
15+
- (void)executeURLAction:(NSURL *)URL activity:(SNRSyneriseActivity)activity;
16+
- (void)executeDeepLinkAction:(NSString *)deepLink activity:(SNRSyneriseActivity)activity;
1717

1818
@end
1919

ios/ReactNativeSynerise/Modules/RNInjector.m

Lines changed: 54 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -62,26 +62,28 @@ - (instancetype)init {
6262

6363
#pragma mark - Public
6464

65-
- (void)executeURLAction:(NSURL *)URL {
66-
[self sendURLActionToJS:URL];
65+
- (void)executeURLAction:(NSURL *)URL activity:(SNRSyneriseActivity)activity {
66+
[self sendURLActionToJS:URL activity:activity];
6767
}
6868

69-
- (void)executeDeepLinkAction:(NSString *)deepLink {
70-
[self sendDeepLinkActionToJS:deepLink];
69+
- (void)executeDeepLinkAction:(NSString *)deepLink activity:(SNRSyneriseActivity)activity {
70+
[self sendDeepLinkActionToJS:deepLink activity:activity];
7171
}
7272

7373
#pragma mark - Private
7474

75-
- (void)sendURLActionToJS:(NSURL *)URL {
75+
- (void)sendURLActionToJS:(NSURL *)URL activity:(SNRSyneriseActivity)activity {
7676
NSDictionary *userInfo = @{
77-
@"url": [URL absoluteString]
77+
@"url": [URL absoluteString],
78+
@"source": [self stringWithSyneriseActivity:activity]
7879
};
7980
[[NSNotificationCenter defaultCenter] postNotificationName:kRNSyneriseUrlActionEvent object:nil userInfo:userInfo];
8081
}
8182

82-
- (void)sendDeepLinkActionToJS:(NSString *)deepLink {
83+
- (void)sendDeepLinkActionToJS:(NSString *)deepLink activity:(SNRSyneriseActivity)activity {
8384
NSDictionary *userInfo = @{
84-
@"deepLink": deepLink
85+
@"deepLink": deepLink,
86+
@"source": [self stringWithSyneriseActivity:activity]
8587
};
8688
[[NSNotificationCenter defaultCenter] postNotificationName:kRNSyneriseDeepLinkActionEvent object:nil userInfo:userInfo];
8789
}
@@ -234,6 +236,20 @@ - (void)SNR_inAppMessageHandledCustomAction:(SNRInAppMessageData *)data name:(NS
234236

235237
#pragma mark - JS Mapping
236238

239+
- (NSString *)stringWithSyneriseActivity:(SNRSyneriseActivity)activity {
240+
if (activity == SNRSyneriseActivitySimplePush) {
241+
return @"SIMPLE_PUSH";
242+
} else if (activity == SNRSyneriseActivityBanner) {
243+
return @"BANNER";
244+
} else if (activity == SNRSyneriseActivityWalkthrough) {
245+
return @"WALKTHROUGH";
246+
} else if (activity == SNRSyneriseActivityInAppMessage) {
247+
return @"IN_APP_MESSAGE";
248+
} else {
249+
return @"NOT_SPECIFIED";
250+
}
251+
}
252+
237253
- (nullable NSDictionary *)dictionaryWithInAppMessageData:(nullable SNRInAppMessageData *)model {
238254
if (model != nil) {
239255
NSMutableDictionary *dictionary = [@{} mutableCopy];
@@ -273,11 +289,38 @@ - (NSDictionary *)constantsToExport
273289
};
274290
}
275291

276-
//setBannerShouldPresentFlag(flag: boolean)
292+
//handleOpenUrlBySDK(url: string)
293+
294+
RCT_EXPORT_METHOD(handleOpenUrlBySDK:(nonnull NSString *)urlString)
295+
{
296+
dispatch_async(dispatch_get_main_queue(), ^{
297+
NSURL *URL = [NSURL URLWithString:urlString];
298+
if ([[UIApplication sharedApplication] canOpenURL:URL]) {
299+
if (@available(iOS 10, *)) {
300+
[[UIApplication sharedApplication] openURL:URL options:@{} completionHandler:nil];
301+
} else {
302+
[[UIApplication sharedApplication] openURL:URL];
303+
}
304+
}
305+
});
306+
}
307+
308+
//handleDeepLinkBySDK(deepLink: string)
277309

278-
RCT_EXPORT_METHOD(setBannerShouldPresentFlag:(nonnull NSNumber *)flag)
310+
RCT_EXPORT_METHOD(handleDeepLinkBySDK:(nonnull NSString *)deepLink)
279311
{
280-
_bannerShouldPresentFlag = [flag boolValue];
312+
dispatch_async(dispatch_get_main_queue(), ^{
313+
NSURL *deepLinkURL = [NSURL URLWithString:deepLink];
314+
if ([[UIApplication sharedApplication] canOpenURL:deepLinkURL]) {
315+
if (@available(iOS 10, *)) {
316+
[[UIApplication sharedApplication] openURL:deepLinkURL options:@{} completionHandler:^(BOOL success) {
317+
318+
}];
319+
} else {
320+
[[UIApplication sharedApplication] openURL:deepLinkURL];
321+
}
322+
}
323+
});
281324
}
282325

283326
//getWalkthrough()

ios/ReactNativeSynerise/Modules/RNSynerise.m

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -74,22 +74,14 @@ - (void)SNR_registerForPushNotificationsIsNeeded {
7474
}
7575

7676
- (void)SNR_handledActionWithURL:(NSURL *)url activity:(SNRSyneriseActivity)activity completionHandler:(SNRSyneriseActivityCompletionHandler)completionHandler {
77-
if (activity == SNRSyneriseActivityInAppMessage) {
78-
return;
79-
}
80-
81-
completionHandler(SNRSyneriseActivityActionHide, ^{
82-
[[RNSyneriseManager sharedInstance].injector executeURLAction:url];
77+
completionHandler(SNRSyneriseActivityActionNone, ^{
78+
[[RNSyneriseManager sharedInstance].injector executeURLAction:url activity:activity];
8379
});
8480
}
8581

8682
- (void)SNR_handledActionWithDeepLink:(NSString *)deepLink activity:(SNRSyneriseActivity)activity completionHandler:(SNRSyneriseActivityCompletionHandler)completionHandler {
87-
if (activity == SNRSyneriseActivityInAppMessage) {
88-
return;
89-
}
90-
91-
completionHandler(SNRSyneriseActivityActionHide, ^{
92-
[[RNSyneriseManager sharedInstance].injector executeDeepLinkAction:deepLink];
83+
completionHandler(SNRSyneriseActivityActionNone, ^{
84+
[[RNSyneriseManager sharedInstance].injector executeDeepLinkAction:deepLink activity:activity];
9385
});
9486
}
9587

ios/react-native-synerise-sdk.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ Pod::Spec.new do |s|
99
s.version = package['version']
1010
s.summary = package['description']
1111
s.homepage = "https://synerise.com"
12-
s.license = "MIT"
12+
s.license = { :type => "Apache License 2.0", :file => "LICENSE" }
1313
s.author = { "Synerise" => "developer@synerise.com" }
1414
s.platform = :ios, "11.0"
1515
s.source = { :git => "https://github.com/Synerise/react-native-synerise-sdk", :tag => s.version.to_s }

lib/config/import_models.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,4 +47,5 @@ export { DocumentsApiQuery } from './../classes/api_queries/DocumentsApiQuery';
4747
export { DocumentsApiQueryType } from './../classes/api_queries/DocumentsApiQueryType';
4848
export { Token } from './../classes/models/Token/Token';
4949
export { TokenOrigin, TokenOriginFromString, TokenOriginToString } from './../classes/models/Token/TokenOrigin';
50+
export { SyneriseSource } from './../classes/models/Misc/SyneriseSource';
5051
export { InAppMessageData } from './../classes/models/Misc/InAppMessageData';

lib/config/import_models.js

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/main/modules/InjectorModule.d.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
import { BaseModule as Module } from './BaseModule';
22
import { InAppMessageData } from './../../classes/models/Misc/InAppMessageData';
33
import { Error } from './../../classes/types/Error';
4+
import { SyneriseSource } from '../../classes/models/Misc/SyneriseSource';
45
interface IInjectorListener {
5-
onOpenUrl(url: string): void;
6-
onDeepLink(deepLink: string): void;
6+
onOpenUrl(url: string, source: SyneriseSource): void;
7+
onDeepLink(deepLink: string, source: SyneriseSource): void;
78
}
89
interface IInjectorBannerListener {
910
onPresent?(): void;
@@ -105,5 +106,7 @@ declare class InjectorModule extends Module {
105106
* @returns `true` if the loaded walkthrough is unique, otherwise returns `false`
106107
*/
107108
isLoadedWalkthroughUnique(): boolean;
109+
handleOpenUrlBySDK(url: string): void;
110+
handleDeepLinkBySDK(deepLink: string): void;
108111
}
109112
export { InjectorModule, IInjectorListener };

0 commit comments

Comments
 (0)