Skip to content

Commit

Permalink
Merge pull request #162 from CleverTap/develop
Browse files Browse the repository at this point in the history
SDK-1144: Release v4.0.0
  • Loading branch information
akashvercetti authored Feb 7, 2022
2 parents 189f517 + e962c9d commit e788bca
Show file tree
Hide file tree
Showing 93 changed files with 4,650 additions and 230 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,6 @@ ObjCStarter/Podfile.lock

# Swift Package Manager
Package.resolved

Pods
Podfile.lock
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
# Change Log
All notable changes to this project will be documented in this file.

### [Version 4.0.0](https://github.com/CleverTap/clevertap-ios-sdk/releases/tag/4.0.0) (February 7, 2022)

##### Added
- Adds Custom Proxy Domain functionality for Push Impressions and Events
- Adds support for configurable CleverTap Profile identifiers

#### Changed
- Use `resource_bundle` instead of `resources` in podspec

### [Version 3.10.0](https://github.com/CleverTap/clevertap-ios-sdk/releases/tag/3.10.0) (Aug 23, 2021)

##### Added
Expand Down
4 changes: 2 additions & 2 deletions CleverTap-iOS-SDK.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = "CleverTap-iOS-SDK"
s.version = "3.10.0"
s.version = "4.0.0"
s.summary = "The CleverTap iOS SDK for App Analytics and Engagement."
s.homepage = "https://github.com/CleverTap/clevertap-ios-sdk"
s.license = { :type => "MIT" }
Expand All @@ -10,7 +10,7 @@ s.requires_arc = true
s.module_name = 'CleverTapSDK'
s.resources = 'CleverTapSDK/*.crt'
s.ios.dependency 'SDWebImage', '~> 5.1'
s.ios.resources = 'CleverTapSDK/**/*.{png,xib}', 'CleverTapSDK/**/*.xcdatamodeld'
s.ios.resource_bundle = {'CleverTapSDK' => ['CleverTapSDK/**/*.{png,xib}', 'CleverTapSDK/**/*.xcdatamodeld']}
s.ios.deployment_target = '9.0'
s.ios.source_files = 'CleverTapSDK/**/*.{h,m}'
s.ios.public_header_files = 'CleverTapSDK/CleverTap.h', 'CleverTapSDK/CleverTap+SSLPinning.h','CleverTapSDK/CleverTap+Inbox.h', 'CleverTapSDK/CleverTapInstanceConfig.h', 'CleverTapSDK/CleverTapBuildInfo.h', 'CleverTapSDK/CleverTapEventDetail.h', 'CleverTapSDK/CleverTapInAppNotificationDelegate.h', 'CleverTapSDK/CleverTapSyncDelegate.h', 'CleverTapSDK/CleverTapTrackedViewController.h', 'CleverTapSDK/CleverTapUTMDetail.h', 'CleverTapSDK/CleverTapJSInterface.h', 'CleverTapSDK/CleverTap+DisplayUnit.h', 'CleverTapSDK/CleverTap+FeatureFlags.h', 'CleverTapSDK/CleverTap+ProductConfig.h', 'CleverTapSDK/CleverTapPushNotificationDelegate.h', 'CleverTapSDK/CleverTapURLDelegate.h',
Expand Down
791 changes: 787 additions & 4 deletions CleverTapSDK.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1200"
LastUpgradeVersion = "1320"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1200"
LastUpgradeVersion = "1320"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
10 changes: 10 additions & 0 deletions CleverTapSDK.xcworkspace/contents.xcworkspacedata

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

Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDEDidComputeMac32BitWarning</key>
<true/>
</dict>
</plist>
6 changes: 5 additions & 1 deletion CleverTapSDK/CTConstants.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ extern NSString *const kCTNotifViewedApiDomain;
#define CLTAP_ACCOUNT_ID_LABEL @"CleverTapAccountID"
#define CLTAP_TOKEN_LABEL @"CleverTapToken"
#define CLTAP_REGION_LABEL @"CleverTapRegion"
#define CLTAP_PROXY_DOMAIN_LABEL @"CleverTapProxyDomain"
#define CLTAP_SPIKY_PROXY_DOMAIN_LABEL @"CleverTapSpikyProxyDomain"
#define CLTAP_DISABLE_APP_LAUNCH_LABEL @"CleverTapDisableAppLaunched"
#define CLTAP_USE_CUSTOM_CLEVERTAP_ID_LABEL @"CleverTapUseCustomId"
#define CLTAP_DISABLE_IDFV_LABEL @"CleverTapDisableIDFV"
Expand Down Expand Up @@ -114,5 +116,7 @@ extern NSString *const kCTNotifViewedApiDomain;
#define CLTAP_GEOFENCES_DID_UPDATE_NOTIFICATION @"CleverTapGeofencesDidUpdateNotification"

// valid profile identifier keys
#define CLTAP_PROFILE_IDENTIFIER_KEYS @[@"Identity", @"Email", @"FBID", @"GPID"]
#define CLTAP_PROFILE_IDENTIFIER_KEYS @[@"Identity", @"Email"] // LEGACY KEYS
#define CLTAP_ALL_PROFILE_IDENTIFIER_KEYS @[@"Identity", @"Email", @"Phone"]


30 changes: 17 additions & 13 deletions CleverTapSDK/CTDeviceInfo.m
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ @interface CTDeviceInfo () {}
@end

@implementation CTDeviceInfo
const char *domainURL;

@synthesize deviceId =_deviceId;
@synthesize validationErrors =_validationErrors;
Expand All @@ -71,19 +72,6 @@ + (void)initialize {
dispatch_once(&onceToken, ^{
_idfv = [self getIDFV];
deviceIDLock = [NSRecursiveLock new];
#if !CLEVERTAP_NO_REACHABILITY_SUPPORT
backgroundQueue = dispatch_queue_create(backgroundQueueLabel, DISPATCH_QUEUE_SERIAL);
// reachability callback
if ((_reachability = SCNetworkReachabilityCreateWithName(NULL, "eu1.clevertap-prod.com")) != NULL) {
SCNetworkReachabilityContext context = {0, (__bridge void*)self, NULL, NULL, NULL};
if (SCNetworkReachabilitySetCallback(_reachability, CleverTapReachabilityHandler, &context)) {
if (!SCNetworkReachabilitySetDispatchQueue(_reachability, backgroundQueue)) {
SCNetworkReachabilitySetCallback(_reachability, NULL, NULL);
}
}
}
_networkInfo = [CTTelephonyNetworkInfo new];
#endif
});
}

Expand All @@ -101,7 +89,23 @@ + (void)handleReachabilityUpdate:(SCNetworkReachabilityFlags)flags {
- (instancetype)initWithConfig:(CleverTapInstanceConfig *)config andCleverTapID:(NSString *)cleverTapID {
if (self = [super init]) {
_config = config;
NSString *_domainURL = config.proxyDomain ? config.proxyDomain : kCTApiDomain;
domainURL = [_domainURL cStringUsingEncoding:NSASCIIStringEncoding];
_validationErrors = [NSMutableArray new];

#if !CLEVERTAP_NO_REACHABILITY_SUPPORT
backgroundQueue = dispatch_queue_create(backgroundQueueLabel, DISPATCH_QUEUE_SERIAL);
// reachability callback
if ((_reachability = SCNetworkReachabilityCreateWithName(NULL, domainURL)) != NULL) {
SCNetworkReachabilityContext context = {0, (__bridge void*)self, NULL, NULL, NULL};
if (SCNetworkReachabilitySetCallback(_reachability, CleverTapReachabilityHandler, &context)) {
if (!SCNetworkReachabilitySetDispatchQueue(_reachability, backgroundQueue)) {
SCNetworkReachabilitySetCallback(_reachability, NULL, NULL);
}
}
}
_networkInfo = [CTTelephonyNetworkInfo new];
#endif
[self initDeviceID:cleverTapID];
}
return self;
Expand Down
17 changes: 17 additions & 0 deletions CleverTapSDK/CTFlexibleIdentityRepo.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
//
// CTFlexibleIdentityRepo.h
// CleverTapSDK
//
// Created by Akash Malhotra on 05/12/21.
// Copyright © 2021 CleverTap. All rights reserved.
//

#import <Foundation/Foundation.h>
#import "CTIdentityRepo.h"
#import "CleverTapInstanceConfig.h"
#import "CTDeviceInfo.h"
#import "CTValidationResultStack.h"

@interface CTFlexibleIdentityRepo : NSObject<CTIdentityRepo>
- (instancetype)initWithConfig:(CleverTapInstanceConfig*)config deviceInfo:(CTDeviceInfo*)deviceInfo validationResultStack:(CTValidationResultStack*)validationResultStack;
@end
98 changes: 98 additions & 0 deletions CleverTapSDK/CTFlexibleIdentityRepo.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
//
// CTFlexibleIdentityRepo.m
// CleverTapSDK
//
// Created by Akash Malhotra on 05/12/21.
// Copyright © 2021 CleverTap. All rights reserved.
//

#import "CTFlexibleIdentityRepo.h"
#import "CTConstants.h"
#import "CTLoginInfoProvider.h"
#import "CleverTapInstanceConfigPrivate.h"


@interface CTFlexibleIdentityRepo () {}
@property (nonatomic, strong) NSArray *identities;
@property (nonatomic, strong) CleverTapInstanceConfig *config;
@property (nonatomic, strong) CTDeviceInfo *deviceInfo;
@property (nonatomic, strong) CTValidationResultStack *validationResultStack;
@property (nonatomic, strong) CTLoginInfoProvider *loginInfoProvider;
@end

@implementation CTFlexibleIdentityRepo

- (instancetype)initWithConfig:(CleverTapInstanceConfig*)config deviceInfo:(CTDeviceInfo*)deviceInfo validationResultStack:(CTValidationResultStack*)validationResultStack
{
self = [super init];
if (self) {
self.config = config;
self.deviceInfo = deviceInfo;
self.validationResultStack = validationResultStack;
self.loginInfoProvider = [[CTLoginInfoProvider alloc]initWithDeviceInfo:deviceInfo config:config];
[self loadIdentities];
}
return self;
}

- (NSArray *)getIdentities {
return self.identities;
}

- (BOOL)isIdentity:(NSString *)key {
return [self.identities containsObject:key];
}

- (void)loadIdentities {
// CHECK IF ITS A LEGACY USER
NSString *cachedIdentities = [self.loginInfoProvider getCachedIdentities];
NSArray *finalIdentityKeys;

// NEW USER
// GET IDENTIFIERS FROM PLIST IF DEFAULT INSTANCE ELSE CONFIG SETTER
NSArray *configIdentifiers = [self getConfigIdentifiers];

// RAISE ERROR IF CACHED AND PLIST IDENTITIES ARE NOT EQUAL
NSArray *cachedIdentityKeys = [cachedIdentities componentsSeparatedByString: @","];
if (cachedIdentityKeys.count > 0 && ![cachedIdentityKeys isEqualToArray: configIdentifiers]) {
CTValidationResult *error = [[CTValidationResult alloc] init];
NSString *errString = @"Profile Identifiers mismatch with the previously saved ones";
[error setErrorCode:531];
[error setErrorDesc:errString];
[self.validationResultStack pushValidationResult:error];
CleverTapLogDebug(self.config.logLevel, @"%@: %@", self, errString);
}

// USE CACHED IDENTITIES IF AVAILABLE, ELSE USE PLIST/SETTER, ELSE USE DEFAULT CONSTANTS
if (cachedIdentityKeys && cachedIdentityKeys.count > 0) {
finalIdentityKeys = cachedIdentityKeys;
}
else if (configIdentifiers && configIdentifiers.count > 0) {
finalIdentityKeys = configIdentifiers;
}
else {
finalIdentityKeys = CLTAP_PROFILE_IDENTIFIER_KEYS;
}

// SAVE IDENTITIES TO CACHE IF NOT ALREADY
if (!cachedIdentityKeys || cachedIdentityKeys.count == 0) {
[self.loginInfoProvider setCachedIdentities: [configIdentifiers componentsJoinedByString: @","]];
}
self.identities = finalIdentityKeys;
}

- (NSArray *)getConfigIdentifiers {
// IF DEFAULT INSTANCE, GET KEYS FROM PLIST, ELSE GET FROM SETTER
if (self.config.isDefaultInstance) {
// ONLY ADD SUPPORTED KEYS
NSArray *clevertapIdentifiers = [[NSBundle mainBundle].infoDictionary objectForKey:@"CleverTapIdentifiers"];
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"self IN %@", CLTAP_ALL_PROFILE_IDENTIFIER_KEYS];
NSArray *result = [clevertapIdentifiers filteredArrayUsingPredicate:predicate];
return result;
}
else {
return self.config.identityKeys;
}
}

@end
15 changes: 15 additions & 0 deletions CleverTapSDK/CTIdentityRepo.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
//
// CTIdentityRepo.h
// CleverTapSDK
//
// Created by Akash Malhotra on 05/12/21.
// Copyright © 2021 CleverTap. All rights reserved.
//

#import <Foundation/Foundation.h>

@protocol CTIdentityRepo <NSObject>

- (NSArray*)getIdentities;
- (BOOL)isIdentity: (NSString*)key;
@end
19 changes: 19 additions & 0 deletions CleverTapSDK/CTIdentityRepoFactory.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
//
// CTIdentityRepoFactory.h
// CleverTapSDK
//
// Created by Akash Malhotra on 05/12/21.
// Copyright © 2021 CleverTap. All rights reserved.
//

#import <Foundation/Foundation.h>
#import "CTIdentityRepo.h"
#import "CleverTapInstanceConfig.h"
#import "CTDeviceInfo.h"
#import "CTValidationResultStack.h"

@interface CTIdentityRepoFactory : NSObject

+ (id<CTIdentityRepo>)getRepoForConfig:(CleverTapInstanceConfig*)config deviceInfo:(CTDeviceInfo*)deviceInfo validationResultStack:(CTValidationResultStack*)validationResultStack;

@end
29 changes: 29 additions & 0 deletions CleverTapSDK/CTIdentityRepoFactory.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
//
// CTIdentityRepoFactory.m
// CleverTapSDK
//
// Created by Akash Malhotra on 05/12/21.
// Copyright © 2021 CleverTap. All rights reserved.
//

#import "CTIdentityRepoFactory.h"
#import "CTLoginInfoProvider.h"
#import "CTLegacyIdentityRepo.h"
#import "CTFlexibleIdentityRepo.h"

@implementation CTIdentityRepoFactory

+ (id<CTIdentityRepo>)getRepoForConfig:(CleverTapInstanceConfig*)config deviceInfo:(CTDeviceInfo*)deviceInfo validationResultStack:(CTValidationResultStack*)validationResultStack {

id<CTIdentityRepo> identityRepo;
CTLoginInfoProvider *loginInfoProvider = [[CTLoginInfoProvider alloc]initWithDeviceInfo:deviceInfo config:config];
if ([loginInfoProvider isLegacyProfileLoggedIn]) {
identityRepo = [[CTLegacyIdentityRepo alloc]init];
}
else {
identityRepo = [[CTFlexibleIdentityRepo alloc]initWithConfig:config deviceInfo:deviceInfo validationResultStack:validationResultStack];
}
return identityRepo;
}

@end
14 changes: 14 additions & 0 deletions CleverTapSDK/CTLegacyIdentityRepo.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
//
// CTLegacyIdentityRepo.h
// CleverTapSDK
//
// Created by Akash Malhotra on 05/12/21.
// Copyright © 2021 CleverTap. All rights reserved.
//

#import <Foundation/Foundation.h>
#import "CTIdentityRepo.h"

@interface CTLegacyIdentityRepo : NSObject<CTIdentityRepo>

@end
35 changes: 35 additions & 0 deletions CleverTapSDK/CTLegacyIdentityRepo.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
//
// CTLegacyIdentityRepo.m
// CleverTapSDK
//
// Created by Akash Malhotra on 05/12/21.
// Copyright © 2021 CleverTap. All rights reserved.
//

#import "CTLegacyIdentityRepo.h"
#import "CTConstants.h"

@interface CTLegacyIdentityRepo () {}
@property (nonatomic, strong) NSArray *identities;
@end

@implementation CTLegacyIdentityRepo

- (instancetype)init
{
self = [super init];
if (self) {
self.identities = CLTAP_PROFILE_IDENTIFIER_KEYS;
}
return self;
}

- (NSArray *)getIdentities {
return self.identities;
}

- (BOOL)isIdentity:(NSString *)key {
return [self.identities containsObject:key];
}

@end
Loading

0 comments on commit e788bca

Please sign in to comment.