Skip to content

Commit 2a4fda8

Browse files
authored
updated underlying iOS SDK with latest changes (#127)
1 parent b77e0c2 commit 2a4fda8

13 files changed

+86
-19
lines changed

ios/Classes/CountlyiOS/CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
- Added `enableAutomaticViewTracking` config for automatic track views
1919
- Added `automaticViewTrackingExclusionList` config for automatic view tracking exclusion list
2020
- Added `globalViewSegmentation` config to add set global view segmentation.
21+
- Added `enrollABOnRCDownload` config method to auto enroll users to AB tests when downloading RC values.
22+
- Added `enableManualSessionControlHybridMode` config. With this mode 'updateSession' calls will automatically be handled by SDK for manual session handling.
2123
- Deprecated `giveConsentForAllFeatures` method
2224
- Deprecated `CLYAutoViewTracking` in config
2325
- Deprecated existing view tracking methods and variables:

ios/Classes/CountlyiOS/Countly-PL.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ Pod::Spec.new do |s|
1717

1818
s.subspec 'Core' do |core|
1919
core.source_files = '*.{h,m}'
20-
core.public_header_files = 'Countly.h', 'CountlyUserDetails.h', 'CountlyConfig.h', 'CountlyFeedbackWidget.h', 'CountlyRCData.h', 'CountlyRemoteConfig.h'
20+
core.public_header_files = 'Countly.h', 'CountlyUserDetails.h', 'CountlyConfig.h', 'CountlyFeedbackWidget.h', 'CountlyRCData.h', 'CountlyRemoteConfig.h', 'CountlyViewTracking.h'
2121
core.preserve_path = 'countly_dsym_uploader.sh'
2222
core.ios.frameworks = ['Foundation', 'UIKit', 'UserNotifications', 'CoreLocation', 'WebKit', 'CoreTelephony', 'WatchConnectivity']
2323
end

ios/Classes/CountlyiOS/Countly.h

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -625,6 +625,24 @@ NS_ASSUME_NONNULL_BEGIN
625625
*/
626626
- (void)presentRatingWidgetWithID:(NSString *)widgetID completionHandler:(void (^)(NSError * __nullable error))completionHandler;
627627

628+
/**
629+
* Presents rating widget with given ID in a WKWebView placed in a UIViewController.
630+
* @discussion First, the availability of the rating widget will be checked asynchronously.
631+
* @discussion If the rating widget with given ID is available, it will be modally presented.
632+
* @discussion Otherwise, @c completionHandler will be executed with an @c NSError.
633+
* @discussion @c completionHandler will also be executed with @c nil when the rating widget is dismissed by user.
634+
* @discussion Calls to this method will be ignored and @c completionHandler will not be executed if:
635+
* @discussion - Consent for @c CLYConsentFeedback is not given, while @c requiresConsent flag is set on initial configuration.
636+
* @discussion - Current device ID is @c CLYTemporaryDeviceID.
637+
* @discussion - @c widgetID is not a non-zero length valid string.
638+
* @discussion This is a legacy method for presenting Rating type feedback widgets only.
639+
* @discussion Passing widget ID's of Survey or NPS type feedback widgets will not work.
640+
* @param widgetID ID of the rating widget created on Countly Server.
641+
* @param closeButtonText text for close button
642+
* @param completionHandler A completion handler block to be executed when the rating widget is dismissed by user or there is an error.
643+
*/
644+
//- (void)presentRatingWidgetWithID:(NSString *)widgetID closeButtonText:(NSString * _Nullable)closeButtonText completionHandler:(void (^)(NSError * __nullable error))completionHandler;
645+
628646
/**
629647
* Manually records rating widget result with given ID and other info.
630648
* @discussion Calls to this method will be ignored if:

ios/Classes/CountlyiOS/Countly.m

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ - (void)startWithConfig:(CountlyConfig *)config
124124
CountlyPersistency.sharedInstance.storedRequestsLimit = MAX(1, config.storedRequestsLimit);
125125

126126
CountlyCommon.sharedInstance.manualSessionHandling = config.manualSessionHandling;
127+
CountlyCommon.sharedInstance.enableManualSessionControlHybridMode = config.enableManualSessionControlHybridMode;
127128

128129
CountlyCommon.sharedInstance.attributionID = config.attributionID;
129130

@@ -209,6 +210,9 @@ - (void)startWithConfig:(CountlyConfig *)config
209210
if(config.getRemoteConfigGlobalCallbacks) {
210211
CountlyRemoteConfigInternal.sharedInstance.remoteConfigGlobalCallbacks = config.getRemoteConfigGlobalCallbacks;
211212
}
213+
if(config.enrollABOnRCDownload) {
214+
CountlyRemoteConfigInternal.sharedInstance.enrollABOnRCDownload = config.enrollABOnRCDownload;
215+
}
212216
[CountlyRemoteConfigInternal.sharedInstance downloadRemoteConfigAutomatically];
213217

214218
CountlyPerformanceMonitoring.sharedInstance.isEnabledOnInitialConfig = config.enablePerformanceMonitoring;
@@ -240,7 +244,14 @@ - (void)onTimer:(NSTimer *)timer
240244
return;
241245

242246
if (!CountlyCommon.sharedInstance.manualSessionHandling)
247+
{
243248
[CountlyConnectionManager.sharedInstance updateSession];
249+
}
250+
// this condtion is called only when both manual session handling and hybrid mode is enabled.
251+
else if(CountlyCommon.sharedInstance.enableManualSessionControlHybridMode)
252+
{
253+
[CountlyConnectionManager.sharedInstance updateSession];
254+
}
244255

245256
[CountlyConnectionManager.sharedInstance sendEvents];
246257
}
@@ -1037,15 +1048,23 @@ - (void)askForStarRating:(void(^)(NSInteger rating))completion
10371048
- (void)presentFeedbackWidgetWithID:(NSString *)widgetID completionHandler:(void (^)(NSError * error))completionHandler
10381049
{
10391050
CLY_LOG_I(@"%s %@ %@", __FUNCTION__, widgetID, completionHandler);
1040-
1041-
[CountlyFeedbacks.sharedInstance checkFeedbackWidgetWithID:widgetID completionHandler:completionHandler];
1051+
1052+
[self presentRatingWidgetWithID:widgetID closeButtonText:nil completionHandler:completionHandler];
10421053
}
10431054

10441055
- (void)presentRatingWidgetWithID:(NSString *)widgetID completionHandler:(void (^)(NSError * error))completionHandler
10451056
{
10461057
CLY_LOG_I(@"%s %@ %@", __FUNCTION__, widgetID, completionHandler);
1058+
1059+
[self presentRatingWidgetWithID:widgetID closeButtonText:nil completionHandler:completionHandler];
1060+
}
10471061

1048-
[CountlyFeedbacks.sharedInstance checkFeedbackWidgetWithID:widgetID completionHandler:completionHandler];
1062+
- (void)presentRatingWidgetWithID:(NSString *)widgetID closeButtonText:(NSString * _Nullable)closeButtonText completionHandler:(void (^)(NSError * __nullable error))completionHandler
1063+
{
1064+
1065+
CLY_LOG_I(@"%s %@ %@ %@", __FUNCTION__, widgetID, closeButtonText, completionHandler);
1066+
1067+
[CountlyFeedbacks.sharedInstance presentRatingWidgetWithID:widgetID closeButtonText:closeButtonText completionHandler:completionHandler];
10491068
}
10501069

10511070
- (void)recordRatingWidgetWithID:(NSString *)widgetID rating:(NSInteger)rating email:(NSString * _Nullable)email comment:(NSString * _Nullable)comment userCanBeContacted:(BOOL)userCanBeContacted

ios/Classes/CountlyiOS/Countly.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ Pod::Spec.new do |s|
1717

1818
s.subspec 'Core' do |core|
1919
core.source_files = '*.{h,m}'
20-
core.public_header_files = 'Countly.h', 'CountlyUserDetails.h', 'CountlyConfig.h', 'CountlyFeedbackWidget.h', 'CountlyRCData.h', 'CountlyRemoteConfig.h'
20+
core.public_header_files = 'Countly.h', 'CountlyUserDetails.h', 'CountlyConfig.h', 'CountlyFeedbackWidget.h', 'CountlyRCData.h', 'CountlyRemoteConfig.h', 'CountlyViewTracking.h'
2121
core.preserve_path = 'countly_dsym_uploader.sh'
2222
core.ios.frameworks = ['Foundation', 'UIKit', 'UserNotifications', 'CoreLocation', 'WebKit', 'CoreTelephony', 'WatchConnectivity']
2323
end

ios/Classes/CountlyiOS/CountlyCommon.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ extern NSString* const kCountlySDKName;
8080
@property (nonatomic) CLYInternalLogLevel internalLogLevel;
8181
@property (nonatomic, copy) NSString* attributionID;
8282
@property (nonatomic) BOOL manualSessionHandling;
83+
@property (nonatomic) BOOL enableManualSessionControlHybridMode;
8384
@property (nonatomic) BOOL enableOrientationTracking;
8485
@property (nonatomic) BOOL enableServerConfiguration;
8586

@@ -122,6 +123,7 @@ void CountlyPrint(NSString *stringToPrint);
122123
@interface CLYButton : UIButton
123124
@property (nonatomic, copy) void (^onClick)(id sender);
124125
+ (CLYButton *)dismissAlertButton;
126+
+ (CLYButton *)dismissAlertButton:(NSString * _Nullable)closeButtonText;
125127
- (void)positionToTopRight;
126128
- (void)positionToTopRightConsideringStatusBar;
127129
@end

ios/Classes/CountlyiOS/CountlyCommon.m

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -351,21 +351,29 @@ - (void)touchUpInside:(id)sender
351351
self.onClick(self);
352352
}
353353

354-
+ (CLYButton *)dismissAlertButton
354+
+ (CLYButton *)dismissAlertButton:(NSString * _Nullable)closeButtonText
355355
{
356+
if(!closeButtonText) {
357+
closeButtonText = @"x";
358+
}
356359
CLYButton* dismissButton = [CLYButton buttonWithType:UIButtonTypeCustom];
357360
dismissButton.frame = (CGRect){CGPointZero, kCountlyDismissButtonSize, kCountlyDismissButtonSize};
358-
[dismissButton setTitle:@"" forState:UIControlStateNormal];
361+
[dismissButton setTitle:closeButtonText forState:UIControlStateNormal];
359362
[dismissButton setTitleColor:UIColor.whiteColor forState:UIControlStateNormal];
360363
dismissButton.backgroundColor = [UIColor.blackColor colorWithAlphaComponent:0.5];
361364
dismissButton.layer.cornerRadius = dismissButton.bounds.size.width * 0.5;
362365
dismissButton.layer.borderColor = [UIColor.blackColor colorWithAlphaComponent:0.7].CGColor;
363366
dismissButton.layer.borderWidth = 1.0;
364367
dismissButton.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleBottomMargin;
365-
368+
366369
return dismissButton;
367370
}
368371

372+
+ (CLYButton *)dismissAlertButton
373+
{
374+
return [CLYButton dismissAlertButton:nil];
375+
}
376+
369377
- (void)positionToTopRight
370378
{
371379
[self positionToTopRight:NO];

ios/Classes/CountlyiOS/CountlyConfig.h

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -403,6 +403,14 @@ typedef enum : NSUInteger
403403
*/
404404
@property (nonatomic) BOOL manualSessionHandling;
405405

406+
/**
407+
* For handling start and stop sessions manually.
408+
* @discussion If set, SDK does not handle beginning and ending sessions automatically. Methods @c beginSession and @c endSession need to be called manually.
409+
* update session will handle auto automatically, no need to call @c updateSession when hybrid mode is enabled.
410+
* NOTE: It will work only when manualSessionHandling is enabled.
411+
*/
412+
@property (nonatomic) BOOL enableManualSessionControlHybridMode;
413+
406414
#pragma mark -
407415

408416
/**
@@ -575,6 +583,13 @@ typedef enum : NSUInteger
575583
*/
576584
- (NSMutableArray<RCDownloadCallback> *) getRemoteConfigGlobalCallbacks;
577585

586+
/**
587+
* For enabling automatic AB enrolling on download.
588+
* @discussion If set, user will will automatically be enrolled in relevant AB tests when downloading RC values.
589+
*/
590+
@property (nonatomic) BOOL enrollABOnRCDownload;
591+
592+
578593
#pragma mark -
579594

580595
/**

ios/Classes/CountlyiOS/CountlyFeedbacks.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ extern NSString* const kCountlyReservedEventStarRating;
2020
+ (instancetype)sharedInstance;
2121

2222
- (void)showDialog:(void(^)(NSInteger rating))completion;
23-
- (void)checkFeedbackWidgetWithID:(NSString *)widgetID completionHandler:(void (^)(NSError * error))completionHandler;
23+
- (void)presentRatingWidgetWithID:(NSString *)widgetID closeButtonText:(NSString *)closeButtonText completionHandler:(void (^)(NSError * error))completionHandler;
2424
- (void)recordRatingWidgetWithID:(NSString *)widgetID rating:(NSInteger)rating email:(NSString *)email comment:(NSString *)comment userCanBeContacted:(BOOL)userCanBeContacted;
2525
- (void)checkForStarRatingAutoAsk;
2626

ios/Classes/CountlyiOS/CountlyFeedbacks.m

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -234,11 +234,11 @@ - (UIColor *)passiveStarColor
234234

235235
#pragma mark - Feedbacks (Ratings) (Legacy Feedback Widget)
236236

237-
- (void)checkFeedbackWidgetWithID:(NSString *)widgetID completionHandler:(void (^)(NSError * error))completionHandler
237+
- (void)presentRatingWidgetWithID:(NSString *)widgetID closeButtonText:(NSString *)closeButtonText completionHandler:(void (^)(NSError * error))completionHandler
238238
{
239239
if (!CountlyServerConfig.sharedInstance.networkingEnabled)
240240
{
241-
CLY_LOG_D(@"'checkFeedbackWidgetWithID' is aborted: SDK Networking is disabled from server config!");
241+
CLY_LOG_D(@"'presentRatingWidgetWithID' is aborted: SDK Networking is disabled from server config!");
242242
return;
243243
}
244244

@@ -289,14 +289,14 @@ - (void)checkFeedbackWidgetWithID:(NSString *)widgetID completionHandler:(void (
289289

290290
dispatch_async(dispatch_get_main_queue(), ^
291291
{
292-
[self presentFeedbackWidgetWithID:widgetID completionHandler:completionHandler];
292+
[self presentRatingWidgetInternal:widgetID closeButtonText:closeButtonText completionHandler:completionHandler];
293293
});
294294
}];
295295

296296
[task resume];
297297
}
298298

299-
- (void)presentFeedbackWidgetWithID:(NSString *)widgetID completionHandler:(void (^)(NSError * error))completionHandler
299+
- (void)presentRatingWidgetInternal:(NSString *)widgetID closeButtonText:(NSString *)closeButtonText completionHandler:(void (^)(NSError * error))completionHandler
300300
{
301301
__block CLYInternalViewController* webVC = CLYInternalViewController.new;
302302
webVC.view.backgroundColor = UIColor.whiteColor;
@@ -309,7 +309,7 @@ - (void)presentFeedbackWidgetWithID:(NSString *)widgetID completionHandler:(void
309309
NSURL* widgetDisplayURL = [self widgetDisplayURL:widgetID];
310310
[webView loadRequest:[NSURLRequest requestWithURL:widgetDisplayURL]];
311311

312-
CLYButton* dismissButton = [CLYButton dismissAlertButton];
312+
CLYButton* dismissButton = [CLYButton dismissAlertButton:closeButtonText];
313313
dismissButton.onClick = ^(id sender)
314314
{
315315
[webVC dismissViewControllerAnimated:YES completion:^

0 commit comments

Comments
 (0)