Skip to content

Commit

Permalink
Merge pull request #18 from CleverTap/3.4.0
Browse files Browse the repository at this point in the history
3.4.0
  • Loading branch information
Aditi3 authored Jan 14, 2019
2 parents 9defdb2 + ff78b62 commit 31bd16b
Show file tree
Hide file tree
Showing 292 changed files with 33,469 additions and 2,060 deletions.
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "Vendors/SDWebImage"]
path = Vendors/SDWebImage
url = https://github.com/SDWebImage/SDWebImage.git
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# CHANGE LOG

## Version 3.4.0 (January 14, 2019)
* Adds support for App Inbox

## Version 3.3.0 (October 26, 2018)
* Adds support for Native InApp Notifications

Expand Down
7 changes: 4 additions & 3 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.3.0"
s.version = "3.4.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 @@ -9,10 +9,11 @@ s.source = { :git => "https://github.com/CleverTap/clevertap-
s.requires_arc = true
s.module_name = 'CleverTapSDK'
s.resources = 'CleverTapSDK/*.crt'
s.ios.resources = 'CleverTapSDK/**/*.{png,xib}'
s.ios.dependency 'SDWebImage/GIF'
s.ios.resources = 'CleverTapSDK/**/*.{png,xib}', 'CleverTapSDK/**/*.xcdatamodeld'
s.ios.deployment_target = '8.0'
s.ios.source_files = 'CleverTapSDK/**/*.{h,m}'
s.ios.public_header_files = 'CleverTapSDK/CleverTap.h', 'CleverTapSDK/CleverTap+SSLPinning.h', 'CleverTapSDK/CleverTapInstanceConfig.h', 'CleverTapSDK/CleverTapBuildInfo.h', 'CleverTapSDK/CleverTapEventDetail.h', 'CleverTapSDK/CleverTapInAppNotificationDelegate.h', 'CleverTapSDK/CleverTapSyncDelegate.h', 'CleverTapSDK/CleverTapTrackedViewController.h', 'CleverTapSDK/CleverTapUTMDetail.h'
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'
s.tvos.deployment_target = '9.0'
s.tvos.source_files = 'CleverTapSDK/*.{h,m}'
s.tvos.public_header_files = 'CleverTapSDK/CleverTap.h', 'CleverTapSDK/CleverTap+SSLPinning.h', 'CleverTapSDK/CleverTapInstanceConfig.h', 'CleverTapSDK/CleverTapBuildInfo.h', 'CleverTapSDK/CleverTapEventDetail.h', 'CleverTapSDK/CleverTapSyncDelegate.h', 'CleverTapSDK/CleverTapTrackedViewController.h', 'CleverTapSDK/CleverTapUTMDetail.h'
Expand Down
291 changes: 267 additions & 24 deletions CleverTapSDK.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?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/>
</plist>
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1000"
LastUpgradeVersion = "1010"
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 = "1000"
LastUpgradeVersion = "1010"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
6 changes: 6 additions & 0 deletions CleverTapSDK/CTConstants.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ extern NSString *const kCTApiDomain;
#define CLTAP_INAPP_NOTIF_DARKEN_SCREEN @"dk"
#define CLTAP_INAPP_NOTIF_SHOW_CLOSE @"sc"
#define CLTAP_INAPP_JSON_RESPONSE_KEY @"inapp_notifs"
#define CLTAP_INBOX_MSG_JSON_RESPONSE_KEY @"inbox_notifs"
#define CLTAP_PREFS_INAPP_KEY @"inapp_notifs"
#define CLTAP_INAPP_CLOSE_IV_WIDTH 40
#define CLTAP_NOTIFICATION_ID_TAG @"wzrk_id"
Expand Down Expand Up @@ -92,5 +93,10 @@ extern NSString *const kCTApiDomain;
#define CLTAP_PROFILE_DID_INITIALIZE_NOTIFICATION @"CleverTapProfileDidInitializeNotification"
#define CLTAP_PROFILE_DID_CHANGE_NOTIFICATION @"CleverTapProfileDidChangeNotification"

// inbox notifications
#define CLTAP_INBOX_MESSAGE_TAPPED_NOTIFICATION @"CleverTapInboxMessageTappedNotification"
#define CLTAP_INBOX_MESSAGE_MEDIA_PLAYING_NOTIFICATION @"CleverTapInboxMediaPlayingNotification"
#define CLTAP_INBOX_MESSAGE_MEDIA_MUTED_NOTIFICATION @"CleverTapInboxMediaMutedNotification"

// valid profile identifier keys
#define CLTAP_PROFILE_IDENTIFIER_KEYS @[@"Identity", @"Email", @"FBID", @"GPID"]
6 changes: 6 additions & 0 deletions CleverTapSDK/CTEventBuilder.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

@class CTValidationResult;
@class CTInAppNotification;
@class CleverTapInboxMessage;

@interface CTEventBuilder : NSObject

Expand All @@ -20,4 +21,9 @@
andQueryParameters:(NSDictionary *)params
completionHandler:(void(^ _Nonnull )(NSDictionary* _Nullable event, NSArray<CTValidationResult*>* _Nullable errors))completion;

+ (void)buildInboxMessageStateEvent:(BOOL)clicked
forMessage:(CleverTapInboxMessage *)message
andQueryParameters:(NSDictionary *)params
completionHandler:(void(^)(NSDictionary* event, NSArray<CTValidationResult*> *errors))completion;

@end
34 changes: 34 additions & 0 deletions CleverTapSDK/CTEventBuilder.m
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#import "CTPreferences.h"
#import "CTUtils.h"
#import "CTInAppNotification.h"
#import "CleverTap+Inbox.h"

NSString *const kCHARGED_EVENT = @"Charged";

Expand Down Expand Up @@ -319,4 +320,37 @@ + (void)buildInAppNotificationStateEvent:(BOOL)clicked
completion(nil, nil);
}
}

/**
* Raises the Inbox Message Clicked event, if clicked is true,
* otherwise the Inbox Message Viewed event, if clicked is false.
*
*/
+ (void)buildInboxMessageStateEvent:(BOOL)clicked
forMessage:(CleverTapInboxMessage *)message
andQueryParameters:(NSDictionary *)params
completionHandler:(void(^)(NSDictionary* event, NSArray<CTValidationResult*> *errors))completion {
NSMutableDictionary *event = [[NSMutableDictionary alloc] init];
NSMutableDictionary *notif = [[NSMutableDictionary alloc] init];
@try {
NSDictionary *data = message.json;
for (NSString *x in [data allKeys]) {
if (![CTUtils doesString:x startWith:@"wzrk_"])
continue;
id value = data[x];
notif[x] = value;
}
if (params) {
[notif addEntriesFromDictionary:params];
}
if ([notif count] == 0) {
CleverTapLogStaticInternal(@"Inbox Message does not have any wzrk_* field");
}
event[@"evtName"] = clicked ? CLTAP_NOTIFICATION_CLICKED_EVENT_NAME : CLTAP_NOTIFICATION_VIEWED_EVENT_NAME;
event[@"evtData"] = notif;
completion(event, nil);
} @catch (NSException *e) {
completion(nil, nil);
}
}
@end
9 changes: 7 additions & 2 deletions CleverTapSDK/CTInAppNotification.m
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
#import "CTInAppNotification.h"
#import "CTConstants.h"
#import "FLAnimatedImage.h"
#if !(TARGET_OS_TV)
#import <SDWebImage/FLAnimatedImageView+WebCache.h>
#import <SDWebImage/UIImageView+WebCache.h>
#endif

@interface CTInAppNotification() {
}
Expand Down Expand Up @@ -216,6 +219,7 @@ - (BOOL)mediaIsVideo {
}

- (void)prepareWithCompletionHandler: (void (^)(void))completionHandler {
#if !(TARGET_OS_TV)
if ([NSThread isMainThread]) {
self.error = [NSString stringWithFormat:@"[%@ prepareWithCompletionHandler] should not be called on the main thread", [self class]];
completionHandler();
Expand All @@ -237,7 +241,8 @@ - (void)prepareWithCompletionHandler: (void (^)(void))completionHandler {
self.image = self.error ? nil : imageData;
}
}

#endif

completionHandler();
}

Expand Down
8 changes: 4 additions & 4 deletions CleverTapSDK/CTValidator.m
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ @implementation CTValidator
* and the error code(if any)
*/
+ (CTValidationResult *)cleanEventName:(NSString *)name {
NSArray *eventNameCharsNotAllowed = @[@".", @":", @"$", @"'", @"\"", @"\\", @"|"];
NSArray *eventNameCharsNotAllowed = @[@".", @":", @"$", @"'", @"\"", @"\\"];
CTValidationResult *vr = [[CTValidationResult alloc] init];

name = [name stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
Expand Down Expand Up @@ -52,7 +52,7 @@ + (CTValidationResult *)cleanEventName:(NSString *)name {
* and the error code(if any)
*/
+ (CTValidationResult *)cleanObjectKey:(NSString *)name {
NSArray *objectKeyCharsNotAllowed = @[@".", @":", @"$", @"'", @"\"", @"\\", @"|"];
NSArray *objectKeyCharsNotAllowed = @[@".", @":", @"$", @"'", @"\"", @"\\"];
CTValidationResult *vr = [[CTValidationResult alloc] init];
name = [name stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
for (NSString *x in objectKeyCharsNotAllowed)
Expand Down Expand Up @@ -117,7 +117,7 @@ + (CTValidationResult *)cleanMultiValuePropertyValue:(NSString *)value {
value = [value lowercaseString];

// remove reserved characters
NSArray *objectValueCharsNotAllowed = @[@"'", @"\"", @"\\", @"|"];
NSArray *objectValueCharsNotAllowed = @[@"'", @"\"", @"\\"];
for (NSString *x in objectValueCharsNotAllowed)
value = [value stringByReplacingOccurrencesOfString:x withString:@""];

Expand Down Expand Up @@ -166,7 +166,7 @@ + (CTValidationResult *)cleanObjectValue:(NSObject *)o context:(CTValidatorConte
NSString *value = (NSString *) o;
value = [value stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];

NSArray *objectValueCharsNotAllowed = @[@"'", @"\"", @"\\", @"|"];
NSArray *objectValueCharsNotAllowed = @[@"'", @"\"", @"\\"];
for (NSString *x in objectValueCharsNotAllowed)
value = [value stringByReplacingOccurrencesOfString:x withString:@""];

Expand Down
Loading

0 comments on commit 31bd16b

Please sign in to comment.