Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
megamegax committed Sep 9, 2024
2 parents 123beb4 + 08aa2d9 commit 463db0d
Show file tree
Hide file tree
Showing 115 changed files with 3,975 additions and 3,138 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/on_push_workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
run: pod install --no-repo-update --verbose
shell: bash
- name: Build And Test
run: xcodebuild -workspace ~/work/ios-emarsys-sdk/ios-emarsys-sdk/EmarsysSDK.xcworkspace -scheme Tests -configuration Debug -destination 'platform=iOS Simulator,name=iPhone 15 Pro,OS=17.5' -derivedDataPath ~/tmp test -quiet
run: xcodebuild -workspace ~/work/ios-emarsys-sdk/ios-emarsys-sdk/EmarsysSDK.xcworkspace -scheme Tests -configuration Debug -destination 'platform=iOS Simulator,name=iPhone 15 Pro Max,OS=17.5' -derivedDataPath ~/tmp test -quiet
shell: bash
- name: Trigger Sample App Build
uses: peter-evans/repository-dispatch@v1
Expand Down
10 changes: 5 additions & 5 deletions Emarsys Sample/Emarsys-Sample.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
archiveVersion = 1;
classes = {
};
objectVersion = 51;
objectVersion = 54;
objects = {

/* Begin PBXBuildFile section */
Expand Down Expand Up @@ -654,7 +654,7 @@
buildSettings = {
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = "$(inherited)";
CODE_SIGN_IDENTITY = "Apple Development";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Distribution";
CODE_SIGN_STYLE = Manual;
DEVELOPMENT_TEAM = "";
"DEVELOPMENT_TEAM[sdk=iphoneos*]" = 4J5FXBB97U;
Expand All @@ -668,7 +668,7 @@
PRODUCT_BUNDLE_IDENTIFIER = com.emarsys.EmarsysSample.NotificationService;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
"PROVISIONING_PROFILE_SPECIFIER[sdk=iphoneos*]" = EmarsysSampleNotificationServiceProvProfDev;
"PROVISIONING_PROFILE_SPECIFIER[sdk=iphoneos*]" = EmarsysSampleNotificationServiceProvProf;
SKIP_INSTALL = YES;
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = 1;
Expand Down Expand Up @@ -827,7 +827,7 @@
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = "$(inherited)";
CODE_SIGN_ENTITLEMENTS = "Emarsys-Sample/Emarsys-Sample.entitlements";
CODE_SIGN_IDENTITY = "Apple Development";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Distribution";
CODE_SIGN_STYLE = Manual;
CURRENT_PROJECT_VERSION = 3;
DEVELOPMENT_ASSET_PATHS = "\"Emarsys-Sample/Preview Content\"";
Expand All @@ -842,7 +842,7 @@
PRODUCT_BUNDLE_IDENTIFIER = com.emarsys.EmarsysSample;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
"PROVISIONING_PROFILE_SPECIFIER[sdk=iphoneos*]" = EmarsysSampleProvProfDev;
"PROVISIONING_PROFILE_SPECIFIER[sdk=iphoneos*]" = EmarsysSampleProvProf;
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = 1;
};
Expand Down
8 changes: 7 additions & 1 deletion Emarsys Sample/Emarsys-Sample/Views/DashboardView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,13 @@ struct DashboardView: View {
UserDefaults.standard.set(nil, forKey: ConfigUserDefaultsKey.applicationCode.rawValue)
UserDefaults.standard.set(nil, forKey: ConfigUserDefaultsKey.contactFieldId.rawValue)
}

Emarsys.config.changeMerchantId(merchantId: self.loginData.merchantId) { error in
if (error == nil) {
self.showMessage(successful: true)
} else {
self.showMessage(successful: true)
}
}
self.showSetupChangeMessage = true
}
}
Expand Down
2 changes: 1 addition & 1 deletion Emarsys Sample/Emarsys-Sample/Views/MobileEngageView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ struct MobileEngageView: View {

func convertEventPayloadToJson() -> Dictionary<String, String>? {
var eventAttributes: [String: String]?
if let attributes = self.customEventPayload {
if let attributes = self.customEventPayload, !attributes.isEmpty {
if let data = attributes.data(using: .utf8) {
do {
eventAttributes = try JSONSerialization.jsonObject(with: data, options: []) as? [String: String]
Expand Down
64 changes: 38 additions & 26 deletions EmarsysSDK.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion Sources/Core/Batch/EMSBatchingShardTrigger.m
Original file line number Diff line number Diff line change
Expand Up @@ -79,4 +79,4 @@ - (void)trigger {
}
}

@end
@end
15 changes: 15 additions & 0 deletions Sources/Core/Categories/NSString+EMSCore.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
////
//
// Copyright © 2024 Emarsys-Technologies Kft. All rights reserved.
//

#import "NSString+EMSCore.h"

@implementation NSString (EMSCore)

- (NSString *)percentEncode {
NSCharacterSet *allowedCharacters = [[NSCharacterSet characterSetWithCharactersInString:@"\"`;/?:^%#@&=$+{}<>,|\\ !'()*[]"] invertedSet];
return [self stringByAddingPercentEncodingWithAllowedCharacters:allowedCharacters];
}

@end
10 changes: 4 additions & 6 deletions Sources/Core/Categories/NSURL+EMSCore.m
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// Copyright (c) 2018 Emarsys. All rights reserved.
//
#import "NSURL+EMSCore.h"
#import "NSString+EMSCore.h"

@implementation NSURL (EMSCore)

Expand All @@ -13,17 +14,14 @@ + (NSURL *)urlWithBaseUrl:(NSString *)urlString
NSParameterAssert(url.scheme);
NSParameterAssert(url.host);

NSCharacterSet *allowedCharacters = [[NSCharacterSet characterSetWithCharactersInString:@"\"`;/?:^%#@&=$+{}<>,|\\ !'()*[]"] invertedSet];
NSMutableString *fullUrl = [NSMutableString stringWithFormat:@"%@?", urlString];
[queryParameters enumerateKeysAndObjectsUsingBlock:^(NSString *key, NSString *value, BOOL *stop) {
[fullUrl appendFormat:@"%@=%@&",
[[NSString stringWithFormat:@"%@",
key] stringByAddingPercentEncodingWithAllowedCharacters:allowedCharacters],
[[NSString stringWithFormat:@"%@",
value] stringByAddingPercentEncodingWithAllowedCharacters:allowedCharacters]];
[[NSString stringWithFormat:@"%@", key] percentEncode],
[[NSString stringWithFormat:@"%@", value] percentEncode]];
}];
[fullUrl deleteCharactersInRange:NSMakeRange(fullUrl.length - 1, 1)];
return [NSURL URLWithString:fullUrl];
}

@end
@end
3 changes: 3 additions & 0 deletions Sources/Core/Crypto/EMSCrypto.m
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,9 @@ - (BOOL)verifyContent:(NSData *)content
EMSLog(logEntry, LogLevelDebug);
}
}
if (publicKey) {
CFRelease(publicKey);
}
return result;
}

Expand Down
31 changes: 28 additions & 3 deletions Sources/Core/Database/EMSRequestModelMapper.m
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
#import "EMSRequestModel.h"
#import "NSDictionary+EMSCore.h"
#import "EMSSchemaContract.h"
#import "EMSMacros.h"
#import "EMSCrashLog.h"
#import "EMSStatusLog.h"

@interface EMSRequestModelMapper ()

Expand All @@ -14,16 +17,17 @@ - (NSData *)dataFromStatement:(sqlite3_stmt *)statement

- (BOOL)isNotNull:(sqlite3_stmt *)statement
atIndex:(int)index;
- (nullable NSString *)mapToString:(const unsigned char *)utf8String;

@end

@implementation EMSRequestModelMapper


- (id)modelFromStatement:(sqlite3_stmt *)statement {
NSString *requestId = [NSString stringWithUTF8String:(const char *) sqlite3_column_text(statement, 0)];
NSString *method = [NSString stringWithUTF8String:(const char *) sqlite3_column_text(statement, 1)];
NSURL *url = [NSURL URLWithString:[NSString stringWithUTF8String:(const char *) sqlite3_column_text(statement, 2)]];
NSString *requestId = [self mapToString:sqlite3_column_text(statement, 0)];
NSString *method = [self mapToString:sqlite3_column_text(statement, 1)];
NSURL *url = [NSURL URLWithString:[self mapToString:sqlite3_column_text(statement, 2)]];
NSDictionary<NSString *, NSString *> *headers;
if ([self isNotNull:statement atIndex:3]) {
headers = [NSDictionary dictionaryWithData:[self dataFromStatement:statement
Expand All @@ -36,6 +40,19 @@ - (id)modelFromStatement:(sqlite3_stmt *)statement {
}
NSDate *timestamp = [NSDate dateWithTimeIntervalSince1970:sqlite3_column_double(statement, 5)];
NSTimeInterval expiry = sqlite3_column_double(statement, 6);
if (!requestId || !method || !url || !timestamp || !expiry) {
NSMutableDictionary *parameters = [NSMutableDictionary dictionary];
parameters[@"requestId"] = requestId;
parameters[@"method"] = method;
parameters[@"url"] = url;
parameters[@"timestamp"] = [timestamp description];
parameters[@"expiry"] = @(expiry);
EMSStatusLog *logEntry = [[EMSStatusLog alloc] initWithClass:[self class]
sel:_cmd
parameters:[NSDictionary dictionaryWithDictionary:parameters]
status:nil];
EMSLog(logEntry, LogLevelError);
}
return [[EMSRequestModel alloc] initWithRequestId:requestId
timestamp:timestamp
expiry:expiry
Expand Down Expand Up @@ -75,6 +92,14 @@ - (BOOL)isNotNull:(sqlite3_stmt *)statement
return sqlite3_column_type(statement, index) != SQLITE_NULL;
}

- (nullable NSString *)mapToString:(const unsigned char *)utf8String {
NSString *result = nil;
if (utf8String) {
result = [NSString stringWithUTF8String:(char *)utf8String];
}
return result;
}

- (NSString *)tableName {
return REQUEST_TABLE_NAME;
}
Expand Down
Loading

0 comments on commit 463db0d

Please sign in to comment.