Skip to content

Commit

Permalink
Merge pull request #224 from CleverTap/develop
Browse files Browse the repository at this point in the history
Release v4.2.0
  • Loading branch information
nishant-clevertap authored Dec 13, 2022
2 parents 084293f + 8625957 commit 7d0858a
Show file tree
Hide file tree
Showing 30 changed files with 875 additions and 56 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
# Change Log
All notable changes to this project will be documented in this file.

### [Version 4.2.0](https://github.com/CleverTap/clevertap-ios-sdk/releases/tag/4.2.0) (December 13, 2022)

#### Added
- Adds a new `CTLocalInApp` builder class to create half-interstitial & alert local in-apps.
- Adds below new public APIs for supporting push notification runtime permission.
- `promptPushPrimer`, `promptForPushPermission`, and `getNotificationPermissionStatusWithCompletionHandler`
- Adds push permission callback method `onPushPermissionResponse` which returns true/false after user allow/deny notification permission.
- Refer [Push Primer doc](/docs/PushPrimer.md) for more details.
- Updated `SDWebImage` dependency.

### [Version 4.1.6](https://github.com/CleverTap/clevertap-ios-sdk/releases/tag/4.1.6) (November 28, 2022)

#### Added
Expand Down
6 changes: 3 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 = "4.1.6"
s.version = "4.2.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,11 +9,11 @@ s.source = { :git => "https://github.com/CleverTap/clevertap-
s.requires_arc = true
s.module_name = 'CleverTapSDK'
s.resources = 'CleverTapSDK/*.cer'
s.ios.dependency 'SDWebImage', '~> 5.11.1'
s.ios.dependency 'SDWebImage', '~> 5.11'
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', 'CleverTapSDK/CleverTap+InAppNotifications.h', 'CleverTapSDK/CleverTap+SCDomain.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', 'CleverTapSDK/CleverTapJSInterface.h', 'CleverTapSDK/CleverTap+DisplayUnit.h', 'CleverTapSDK/CleverTap+FeatureFlags.h', 'CleverTapSDK/CleverTap+ProductConfig.h', 'CleverTapSDK/CleverTapPushNotificationDelegate.h', 'CleverTapSDK/CleverTapURLDelegate.h', 'CleverTapSDK/CleverTap+InAppNotifications.h', 'CleverTapSDK/CleverTap+SCDomain.h', 'CleverTapSDK/CleverTap+PushPermission.h', 'CleverTapSDK/InApps/CTLocalInApp.h'
s.tvos.deployment_target = '9.0'
s.tvos.source_files = 'CleverTapSDK/*.{h,m}', 'CleverTapSDK/ProductConfig/**/*.{h,m}', 'CleverTapSDK/FeatureFlags/**/*.{h,m}'
s.tvos.exclude_files = 'CleverTapSDK/CleverTapJSInterface.{h,m}'
Expand Down
12 changes: 12 additions & 0 deletions CleverTapSDK.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,9 @@
07D8C08B21DDEC54006F5A1B /* CTCarouselImageView.h in Headers */ = {isa = PBXBuildFile; fileRef = 07D8C08A21DDEC54006F5A1B /* CTCarouselImageView.h */; settings = {ATTRIBUTES = (Private, ); }; };
07FD65A2223BC26300A845B7 /* CTCoverViewController~iphoneland.xib in Resources */ = {isa = PBXBuildFile; fileRef = 07FD65A1223BC26300A845B7 /* CTCoverViewController~iphoneland.xib */; };
07FD65A4223BCB8200A845B7 /* CTCoverViewController~ipadland.xib in Resources */ = {isa = PBXBuildFile; fileRef = 07FD65A3223BCB8200A845B7 /* CTCoverViewController~ipadland.xib */; };
4808030E292EB4FB00C06E2F /* CleverTap+PushPermission.h in Headers */ = {isa = PBXBuildFile; fileRef = 4808030D292EB4FB00C06E2F /* CleverTap+PushPermission.h */; };
48080311292EB50D00C06E2F /* CTLocalInApp.h in Headers */ = {isa = PBXBuildFile; fileRef = 4808030F292EB50D00C06E2F /* CTLocalInApp.h */; };
48080312292EB50D00C06E2F /* CTLocalInApp.m in Sources */ = {isa = PBXBuildFile; fileRef = 48080310292EB50D00C06E2F /* CTLocalInApp.m */; };
4987C665251B5E79003E6BE8 /* CTImageInAppViewController.h in Headers */ = {isa = PBXBuildFile; fileRef = 4987C663251B5E79003E6BE8 /* CTImageInAppViewController.h */; };
4987C666251B5E79003E6BE8 /* CTImageInAppViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 4987C664251B5E79003E6BE8 /* CTImageInAppViewController.m */; };
4987C668251B5F9E003E6BE8 /* CTImageInAppViewControllerPrivate.h in Headers */ = {isa = PBXBuildFile; fileRef = 4987C667251B5F9E003E6BE8 /* CTImageInAppViewControllerPrivate.h */; };
Expand Down Expand Up @@ -550,6 +553,9 @@
203C2B553FF6FBADEE051C68 /* Pods-shared-CleverTapSDKTests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-shared-CleverTapSDKTests.release.xcconfig"; path = "Target Support Files/Pods-shared-CleverTapSDKTests/Pods-shared-CleverTapSDKTests.release.xcconfig"; sourceTree = "<group>"; };
2108AFE9090417CC69A0E3EB /* libPods-shared-CleverTapSDKTestsApp.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-shared-CleverTapSDKTestsApp.a"; sourceTree = BUILT_PRODUCTS_DIR; };
37D3A7E5589257CFA37243C3 /* libPods-shared-CleverTapSDKUITests.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-shared-CleverTapSDKUITests.a"; sourceTree = BUILT_PRODUCTS_DIR; };
4808030D292EB4FB00C06E2F /* CleverTap+PushPermission.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "CleverTap+PushPermission.h"; sourceTree = "<group>"; };
4808030F292EB50D00C06E2F /* CTLocalInApp.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CTLocalInApp.h; sourceTree = "<group>"; };
48080310292EB50D00C06E2F /* CTLocalInApp.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CTLocalInApp.m; sourceTree = "<group>"; };
4987C663251B5E79003E6BE8 /* CTImageInAppViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CTImageInAppViewController.h; sourceTree = "<group>"; };
4987C664251B5E79003E6BE8 /* CTImageInAppViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = CTImageInAppViewController.m; sourceTree = "<group>"; };
4987C667251B5F9E003E6BE8 /* CTImageInAppViewControllerPrivate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CTImageInAppViewControllerPrivate.h; sourceTree = "<group>"; };
Expand Down Expand Up @@ -758,6 +764,8 @@
071EB476217F6427008F0FAB /* InApps */ = {
isa = PBXGroup;
children = (
4808030F292EB50D00C06E2F /* CTLocalInApp.h */,
48080310292EB50D00C06E2F /* CTLocalInApp.m */,
49F9E6BA2552E97000EF2E5C /* resources */,
071EB4AF217F6427008F0FAB /* CTDismissButton.h */,
071EB478217F6427008F0FAB /* CTDismissButton.m */,
Expand Down Expand Up @@ -1079,6 +1087,7 @@
D0C7BBBF207D82C0001345EF /* CleverTapSDK */ = {
isa = PBXGroup;
children = (
4808030D292EB4FB00C06E2F /* CleverTap+PushPermission.h */,
4E64855A287440BA00C2F409 /* AmazonRootCA1.cer */,
D0BD7598241760A30006EE55 /* ProductConfig */,
D0D4C9E62414CBA30029477E /* FeatureFlags */,
Expand Down Expand Up @@ -1339,10 +1348,12 @@
D0213D50207D905800FE5740 /* CleverTapEventDetail.h in Headers */,
07B94550219EA39000D4C542 /* CleverTap+Inbox.h in Headers */,
071EB4F9217F6427008F0FAB /* CTNotificationButton.h in Headers */,
48080311292EB50D00C06E2F /* CTLocalInApp.h in Headers */,
D0213D4D207D905800FE5740 /* CleverTapTrackedViewController.h in Headers */,
4E25E3C5278887A70008C888 /* CTFlexibleIdentityRepo.h in Headers */,
071EB512217F6427008F0FAB /* CTInAppHTMLViewController.h in Headers */,
D01A0894207EC2D400423D6F /* CleverTapInstanceConfig.h in Headers */,
4808030E292EB4FB00C06E2F /* CleverTap+PushPermission.h in Headers */,
071EB50C217F6427008F0FAB /* CTCoverImageViewController.h in Headers */,
D0213D4B207D905800FE5740 /* CleverTapInAppNotificationDelegate.h in Headers */,
072F9E4221B14ECC00BC6313 /* CTInboxMessageActionView.h in Headers */,
Expand Down Expand Up @@ -1822,6 +1833,7 @@
071EB4FA217F6427008F0FAB /* CTAVPlayerViewController.m in Sources */,
071EB506217F6427008F0FAB /* CTInAppFCManager.m in Sources */,
4E25E3C3278887A70008C888 /* CTFlexibleIdentityRepo.m in Sources */,
48080312292EB50D00C06E2F /* CTLocalInApp.m in Sources */,
D01651B72097B81400660178 /* CTKnownProfileFields.m in Sources */,
07B94545219EA34300D4C542 /* CTUserMO+CoreDataProperties.m in Sources */,
07B94542219EA34300D4C542 /* CleverTapInboxViewController.m in Sources */,
Expand Down
3 changes: 3 additions & 0 deletions CleverTapSDK/CTDeviceInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,8 @@
- (void)forceNewDeviceID;
- (void)forceUpdateCustomDeviceID:(NSString *)cleverTapID;
- (BOOL)isErrorDeviceID;
- (void)setDirectCallSDKVersion: (NSString *)version;
- (void)incrementLocalInAppCount;
- (int)getLocalInAppCount;
- (void)setSignedCallSDKVersion: (NSString *)version;
@end
12 changes: 12 additions & 0 deletions CleverTapSDK/CTDeviceInfo.m
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
NSString *const kCLTAP_DEVICE_ID_TAG = @"deviceId";
NSString *const kCLTAP_FALLBACK_DEVICE_ID_TAG = @"fallbackDeviceId";
NSString *const kCLTAP_ERROR_PROFILE_PREFIX = @"-i";
NSString *const kCLTAP_LOCAL_INAPP_COUNT = @"local_in_app_count";

static BOOL _wifi;

Expand Down Expand Up @@ -54,6 +55,7 @@ @interface CTDeviceInfo () {}
@property (strong, readwrite) NSString *fallbackDeviceId;
@property (strong, readwrite) NSString *vendorIdentifier;
@property (strong, readwrite) NSMutableArray *validationErrors;
@property (assign, readwrite) int localInAppCount;

@end

Expand Down Expand Up @@ -478,4 +480,14 @@ - (NSString *)signedCallSDKVersion {
return _signedCallSDKVersion;
}

- (void)incrementLocalInAppCount {
self.localInAppCount = self.localInAppCount + 1;
[CTPreferences putInt:self.localInAppCount forKey:kCLTAP_LOCAL_INAPP_COUNT];
}

- (int)getLocalInAppCount {
self.localInAppCount = (int) [CTPreferences getIntForKey:kCLTAP_LOCAL_INAPP_COUNT withResetValue:0];
return self.localInAppCount;
}

@end
11 changes: 11 additions & 0 deletions CleverTapSDK/CTInAppDisplayViewController.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,17 @@
@protocol CTInAppNotificationDisplayDelegate <NSObject>
- (void)handleNotificationCTA:(NSURL*)ctaURL buttonCustomExtras:(NSDictionary *)buttonCustomExtras forNotification:(CTInAppNotification*)notification fromViewController:(CTInAppDisplayViewController*)controller withExtras:(NSDictionary*)extras;
- (void)notificationDidDismiss:(CTInAppNotification*)notification fromViewController:(CTInAppDisplayViewController*)controller;
/**
Called when in-app button is tapped for requesting push permission.
*/
- (void)handleInAppPushPrimer:(CTInAppNotification*)notification
fromViewController:(CTInAppDisplayViewController*)controller
withFallbackToSettings:(BOOL)isFallbackToSettings;

/**
Called to notify that local in-app push primer is dismissed.
*/
- (void)inAppPushPrimerDidDismissed;
@optional
- (void)notificationDidShow:(CTInAppNotification*)notification fromViewController:(CTInAppDisplayViewController*)controller;
@end
Expand Down
25 changes: 25 additions & 0 deletions CleverTapSDK/CTInAppDisplayViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,31 @@ - (void)handleButtonClickFromIndex:(int)index {
campaignId = @"";
}

if (self.notification.isLocalInApp) {
if (index == 0) {
if (self.delegate && [self.delegate respondsToSelector:@selector(handleInAppPushPrimer:fromViewController:withFallbackToSettings:)]) {
[self.delegate handleInAppPushPrimer:self.notification
fromViewController:self
withFallbackToSettings:self.notification.fallBackToNotificationSettings];
}
} else if (index == 1) {
if (self.delegate && [self.delegate respondsToSelector:@selector(inAppPushPrimerDidDismissed)]) {
[self.delegate inAppPushPrimerDidDismissed];
}
}
return;
}

// For showing Push Permission through InApp Campaign, positive button type is "rfp".
if ([button.type isEqual:@"rfp"]) {
if (self.delegate && [self.delegate respondsToSelector:@selector(handleInAppPushPrimer:fromViewController:withFallbackToSettings:)]) {
[self.delegate handleInAppPushPrimer:self.notification
fromViewController:self
withFallbackToSettings:button.fallbackToSettings];
}
return;
}

if (self.delegate && [self.delegate respondsToSelector:@selector(handleNotificationCTA:buttonCustomExtras:forNotification:fromViewController:withExtras:)]) {
[self.delegate handleNotificationCTA:buttonCTA buttonCustomExtras:buttonCustomExtras forNotification:self.notification fromViewController:self withExtras:@{@"wzrk_id":campaignId, @"wzrk_c2a": buttonText}];
}
Expand Down
5 changes: 5 additions & 0 deletions CleverTapSDK/CTInAppNotification.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,11 @@
@property (nonatomic, copy, readonly) NSDictionary *customExtras;
@property (nonatomic, copy, readwrite) NSDictionary *actionExtras;

@property (nonatomic, readonly) BOOL isLocalInApp;
@property (nonatomic, readonly) BOOL isPushSettingsSoftAlert;
@property (nonatomic, readonly) BOOL fallBackToNotificationSettings;
@property (nonatomic, readonly) BOOL skipSettingsAlert;

- (instancetype)init __unavailable;
- (instancetype)initWithJSON:(NSDictionary*)json;

Expand Down
10 changes: 10 additions & 0 deletions CleverTapSDK/CTInAppNotification.m
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,11 @@ @interface CTInAppNotification() {
@property (nonatomic, copy, readwrite) NSDictionary *jsonDescription;
@property (nonatomic, copy, readwrite) NSDictionary *customExtras;

@property (nonatomic, readwrite) BOOL isLocalInApp;
@property (nonatomic, readwrite) BOOL isPushSettingsSoftAlert;
@property (nonatomic, readwrite) BOOL fallBackToNotificationSettings;
@property (nonatomic, readwrite) BOOL skipSettingsAlert;

@property (nonatomic, readwrite) NSString *error;

@end
Expand All @@ -77,6 +82,11 @@ - (instancetype)initWithJSON:(NSDictionary *)jsonObject {
self.excludeFromCaps = [jsonObject[@"efc"] boolValue];
self.totalLifetimeCount = jsonObject[@"tlc"] ? [jsonObject[@"tlc"] intValue] : -1;
self.totalDailyCount = jsonObject[@"tdc"] ? [jsonObject[@"tdc"] intValue] : -1;
self.isLocalInApp = jsonObject[@"isLocalInApp"] ? [jsonObject[@"isLocalInApp"] boolValue] : NO;
self.isPushSettingsSoftAlert = jsonObject[@"isPushSettingsSoftAlert"] ? [jsonObject[@"isPushSettingsSoftAlert"] boolValue] : NO;
self.fallBackToNotificationSettings = jsonObject[@"fallbackToNotificationSettings"] ? [jsonObject[@"fallbackToNotificationSettings"] boolValue] : NO;
self.skipSettingsAlert = jsonObject[@"skipSettingsAlert"] ? [jsonObject[@"skipSettingsAlert"] boolValue] : NO;

if (jsonObject[@"ti"]) {
self.Id = [NSString stringWithFormat:@"%@", jsonObject[@"ti"]];
}
Expand Down
2 changes: 2 additions & 0 deletions CleverTapSDK/CTNotificationButton.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
@property (nonatomic, copy, readonly) NSString *borderRadius;
@property (nonatomic, copy, readonly) NSString *borderColor;
@property (nonatomic, copy, readonly) NSDictionary *customExtras;
@property (nonatomic, copy, readonly) NSString *type;
@property (nonatomic, readonly) BOOL fallbackToSettings;

@property (nonatomic, copy, readonly) NSString *backgroundColor;
@property (nonatomic, readonly) NSURL *actionURL;
Expand Down
4 changes: 4 additions & 0 deletions CleverTapSDK/CTNotificationButton.m
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ @interface CTNotificationButton () {
@property (nonatomic, copy, readwrite) NSString *borderColor;
@property (nonatomic, copy, readwrite) NSString *backgroundColor;
@property (nonatomic, copy, readwrite) NSDictionary *customExtras;
@property (nonatomic, copy, readwrite) NSString *type;
@property (nonatomic, readwrite) BOOL fallbackToSettings;
@property (nonatomic, readwrite) NSURL *actionURL;

@property (nonatomic, copy, readwrite) NSDictionary *jsonDescription;
Expand Down Expand Up @@ -41,6 +43,8 @@ - (instancetype)initWithJSON:(NSDictionary *)jsonObject {
self.error = [e debugDescription];
}
}
self.type = actions[@"type"];
self.fallbackToSettings = actions[@"fbSettings"] ? [actions[@"fbSettings"] boolValue] : NO;
}

} @catch (NSException *e) {
Expand Down
69 changes: 69 additions & 0 deletions CleverTapSDK/CleverTap+PushPermission.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
#import <Foundation/Foundation.h>
#import <UserNotifications/UserNotifications.h>
#import "CleverTap.h"

@protocol CleverTapPushPermissionDelegate <NSObject>

/*!
@discussion
When an user either allow or deny permission for push notifications,
this method will be called.
@param accepted The boolean will be true/false if notification permission is granted/denied.
*/
@optional
- (void)onPushPermissionResponse:(BOOL)accepted;
@end


@interface CleverTap (PushPermission)

/*!
@method
@abstract
The `CleverTapPushPermissionDelegate` protocol provides methods for notifying
your application (the adopting delegate) about push permission response.
@discussion
This sets the CleverTapPushPermissionDelegate.
@param delegate an object conforming to the CleverTapPushPermissionDelegate Protocol
*/
- (void)setPushPermissionDelegate:(id <CleverTapPushPermissionDelegate> _Nullable)delegate;

/*!
@method
@abstract
This method will create a push primer asking user to enable push notification.
@param json A NSDictionary which have all fields needed to display push primer.
*/
- (void)promptPushPrimer:(NSDictionary *_Nonnull)json;

/*!
@method
@abstract
This method will directly show OS hard dialog for requesting push permission.
@param showFallbackSettings If YES and permission is denied already, then we fallback to app’s notification settings.
*/
- (void)promptForPushPermission:(BOOL)showFallbackSettings;

/*!
@method
@abstract
Returns the push notification permission status inside completion block.
This method can be called before creating push primer and prompt push primer only if permission is denied.
@param completion the completion block to be executed when push permission status is retrieved.
*/

- (void)getNotificationPermissionStatusWithCompletionHandler:(void (^_Nonnull)(UNAuthorizationStatus status))completion API_AVAILABLE(ios(10.0));

@end

Loading

0 comments on commit 7d0858a

Please sign in to comment.