Skip to content

Commit

Permalink
Merge pull request #342 from Countly/content-changes
Browse files Browse the repository at this point in the history
Added missing iOS macros check for content config
  • Loading branch information
turtledreams authored Sep 9, 2024
2 parents a23584b + 6c2be25 commit 2d9eac4
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 4 deletions.
2 changes: 2 additions & 0 deletions CountlyConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions CountlyConfig.m
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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
15 changes: 11 additions & 4 deletions CountlyContentBuilderInternal.m
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}];

Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 2d9eac4

Please sign in to comment.