Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added missing iOS macros check for content config #342

Merged
merged 2 commits into from
Sep 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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