diff --git a/CountlyConfig.h b/CountlyConfig.h index a3b6246d..dfc0397f 100644 --- a/CountlyConfig.h +++ b/CountlyConfig.h @@ -661,11 +661,13 @@ typedef enum : NSUInteger */ @property (nonatomic) BOOL enableServerConfiguration; +#if (TARGET_OS_IOS) /** * Variable to access content configurations. * @discussion Content configurations for developer to interact with SDK. */ - (CountlyContentConfig *) content; +#endif /** * This is an experimental feature and it can have breaking changes diff --git a/CountlyConfig.m b/CountlyConfig.m index 47a38968..9795ddc2 100644 --- a/CountlyConfig.m +++ b/CountlyConfig.m @@ -37,7 +37,10 @@ @implementation CountlyConfig CountlyCrashesConfig *crashes = nil; CountlySDKLimitsConfig *sdkLimitsConfig = nil; CountlyExperimentalConfig *experimental = nil; + +#if (TARGET_OS_IOS) CountlyContentConfig *content = nil; +#endif //NOTE: Device ID options NSString* const CLYDefaultDeviceID = @""; //NOTE: It will be overridden to default device ID mechanism, depending on platform. @@ -133,11 +136,13 @@ - (nonnull CountlyExperimentalConfig *)experimental { return experimental; } +#if (TARGET_OS_IOS) - (nonnull CountlyContentConfig *)content { if (content == nil) { content = CountlyContentConfig.new; } return content; } +#endif @end diff --git a/CountlyContentBuilderInternal.m b/CountlyContentBuilderInternal.m index 4a0ef01b..9af91e28 100644 --- a/CountlyContentBuilderInternal.m +++ b/CountlyContentBuilderInternal.m @@ -105,8 +105,9 @@ - (void)fetchContents { NSDictionary *jsonResponse = [NSJSONSerialization JSONObjectWithData:data options:0 error:nil]; NSString *pathToHtml = jsonResponse[@"pathToHtml"]; NSDictionary *placementCoordinates = jsonResponse[@"placementCoordinates"]; - - [self showContentWithHtmlPath:pathToHtml placementCoordinates:placementCoordinates]; + if(pathToHtml) { + [self showContentWithHtmlPath:pathToHtml placementCoordinates:placementCoordinates]; + } self->_isRequestQueueLocked = NO; }]; @@ -162,9 +163,15 @@ - (NSString *)resolutionJson { return [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding]; } -- (void)showContentWithHtmlPath:(NSString *)pathToHtml placementCoordinates:(NSDictionary *)placementCoordinates { +- (void)showContentWithHtmlPath:(NSString *)urlString placementCoordinates:(NSDictionary *)placementCoordinates { // Convert pathToHtml to NSURL - NSURL *url = [NSURL URLWithString:pathToHtml]; + NSURL *url = [NSURL URLWithString:urlString]; + + if (!url || !url.scheme || !url.host) { + NSLog(@"The URL is not valid: %@", urlString); + return; + } + dispatch_async(dispatch_get_main_queue(), ^ { // Detect screen orientation