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

Fixed feedback widget url encoding issue for custom string #348

Merged
merged 9 commits into from
Oct 24, 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
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
## x.x.x
## 24.7.4
* Mitigated an issue with the feedback widget URL encoding on iOS 16 and earlier, which prevented the widget from displaying
* Mitigated an issue with content fetch URL encoding on iOS 16 and earlier, which caused the request to fail

* Added `CountlyFeedbacks:` interface with new view methods (Access with `Countly.sharedInstance.feedback`):
* Method to present feedback widget (wih an optional widget selector(name, ID or tag) string and a Callback):
* `presentNPS`
Expand Down
2 changes: 1 addition & 1 deletion Countly-PL.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = 'Countly-PL'
s.version = '24.7.3'
s.version = '24.7.4'
s.license = { :type => 'MIT', :file => 'LICENSE' }
s.summary = 'Countly is an innovative, real-time, open source mobile analytics platform.'
s.homepage = 'https://github.com/Countly/countly-sdk-ios'
Expand Down
2 changes: 1 addition & 1 deletion Countly.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = 'Countly'
s.version = '24.7.3'
s.version = '24.7.4'
s.license = { :type => 'MIT', :file => 'LICENSE' }
s.summary = 'Countly is an innovative, real-time, open source mobile analytics platform.'
s.homepage = 'https://github.com/Countly/countly-sdk-ios'
Expand Down
4 changes: 2 additions & 2 deletions Countly.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -734,7 +734,7 @@
"@loader_path/Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 10.14;
MARKETING_VERSION = 24.7.3;
MARKETING_VERSION = 24.7.4;
PRODUCT_BUNDLE_IDENTIFIER = ly.count.CountlyiOSSDK;
PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)";
PROVISIONING_PROFILE_SPECIFIER = "";
Expand Down Expand Up @@ -766,7 +766,7 @@
"@loader_path/Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 10.14;
MARKETING_VERSION = 24.7.3;
MARKETING_VERSION = 24.7.4;
PRODUCT_BUNDLE_IDENTIFIER = ly.count.CountlyiOSSDK;
PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)";
PROVISIONING_PROFILE_SPECIFIER = "";
Expand Down
2 changes: 1 addition & 1 deletion CountlyCommon.m
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ @interface CountlyCommon ()
#endif
@end

NSString* const kCountlySDKVersion = @"24.7.3";
NSString* const kCountlySDKVersion = @"24.7.4";
NSString* const kCountlySDKName = @"objc-native-ios";

NSString* const kCountlyErrorDomain = @"ly.count.ErrorDomain";
Expand Down
2 changes: 1 addition & 1 deletion CountlyContentBuilderInternal.m
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ - (NSURLRequest *)fetchContentsRequest
NSString* queryString = [CountlyConnectionManager.sharedInstance queryEssentials];
NSString *resolutionJson = [self resolutionJson];
queryString = [queryString stringByAppendingFormat:@"&%@=%@",
@"resolution", resolutionJson];
@"resolution", resolutionJson.cly_URLEscaped];

queryString = [CountlyConnectionManager.sharedInstance appendChecksum:queryString];

Expand Down
70 changes: 41 additions & 29 deletions CountlyFeedbackWidget.m
Original file line number Diff line number Diff line change
Expand Up @@ -193,47 +193,59 @@ - (NSURLRequest *)dataRequest
}
}

- (NSURLRequest *)displayRequest
{
NSString* queryString = [NSString stringWithFormat:@"%@=%@&%@=%@&%@=%@&%@=%@&%@=%@&%@=%@&%@=%@",
kCountlyQSKeyAppKey, CountlyConnectionManager.sharedInstance.appKey.cly_URLEscaped,
kCountlyQSKeyDeviceID, CountlyDeviceInfo.sharedInstance.deviceID.cly_URLEscaped,
kCountlyQSKeySDKName, CountlyCommon.sharedInstance.SDKName,
kCountlyQSKeySDKVersion, CountlyCommon.sharedInstance.SDKVersion,
kCountlyFBKeyAppVersion, CountlyDeviceInfo.appVersion,
kCountlyFBKeyPlatform, CountlyDeviceInfo.osName,
kCountlyFBKeyWidgetID, self.ID];
- (NSURLRequest *)displayRequest {
// Create the base URL with endpoint and feedback type
NSMutableString *URL = [NSMutableString stringWithFormat:@"%@%@/%@",
CountlyConnectionManager.sharedInstance.host,
kCountlyEndpointFeedback,
self.type];

queryString = [queryString stringByAppendingFormat:@"&%@=%@",
kCountlyAppVersionKey, CountlyDeviceInfo.appVersion];
// Create a dictionary for query parameters
NSDictionary *queryParams = @{
kCountlyQSKeyAppKey: CountlyConnectionManager.sharedInstance.appKey.cly_URLEscaped,
kCountlyQSKeyDeviceID: CountlyDeviceInfo.sharedInstance.deviceID.cly_URLEscaped,
kCountlyQSKeySDKName: CountlyCommon.sharedInstance.SDKName,
kCountlyQSKeySDKVersion: CountlyCommon.sharedInstance.SDKVersion,
kCountlyFBKeyAppVersion: CountlyDeviceInfo.appVersion,
kCountlyFBKeyPlatform: CountlyDeviceInfo.osName,
kCountlyFBKeyWidgetID: self.ID,
kCountlyAppVersionKey: CountlyDeviceInfo.appVersion,
};

// Create the query string
NSMutableArray *queryItems = [NSMutableArray array];
[queryParams enumerateKeysAndObjectsUsingBlock:^(id key, id obj, BOOL *stop) {
[queryItems addObject:[NSString stringWithFormat:@"%@=%@", key, obj]];
}];

NSString *queryString = [queryItems componentsJoinedByString:@"&"];

// Append checksum to the query string
queryString = [CountlyConnectionManager.sharedInstance appendChecksum:queryString];

NSMutableString* URL = CountlyConnectionManager.sharedInstance.host.mutableCopy;
[URL appendString:kCountlyEndpointFeedback];
NSString* feedbackTypeEndpoint = [@"/" stringByAppendingString:self.type];
[URL appendString:feedbackTypeEndpoint];
// Add the query string to the URL
[URL appendFormat:@"?%@", queryString];

// customParams is an NSDictionary containing the custom key-value pairs
// Create custom parameters
NSDictionary *customParams = @{@"tc": @"1"};

// Build custom parameter string
NSMutableString *customString = [NSMutableString stringWithString:@"&custom="];
[customString appendString:@"{"];
[customParams enumerateKeysAndObjectsUsingBlock:^(id key, id obj, BOOL *stop) {
[customString appendFormat:@"\"%@\":%@,", key, obj];
}];
[customString deleteCharactersInRange:NSMakeRange(customString.length - 1, 1)]; // Remove the last comma
[customString appendString:@"}"];
// Create JSON data from custom parameters
NSError *error;
NSData *jsonData = [NSJSONSerialization dataWithJSONObject:customParams options:0 error:&error];

// Append custom parameter
[URL appendString:customString];
if (!jsonData) {
NSLog(@"Failed to serialize JSON: %@", error);
} else {
NSString *customString = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
// Append the custom parameter to the URL
[URL appendFormat:@"&custom=%@", customString.cly_URLEscaped];
}

NSURLRequest* request = [NSURLRequest requestWithURL:[NSURL URLWithString:URL]];
return request;
// Create and return the NSURLRequest
return [NSURLRequest requestWithURL:[NSURL URLWithString:URL]];
}


- (void)recordReservedEventForDismissing
{
[self recordReservedEventWithSegmentation:@{kCountlyFBKeyClosed: @1}];
Expand Down
Loading