Skip to content

Commit e989e60

Browse files
authored
Merge pull request #348 from Countly/widget-url-fix
Fixed feedback widget url encoding issue for custom string
2 parents 3ba6847 + 0199e24 commit e989e60

File tree

7 files changed

+51
-36
lines changed

7 files changed

+51
-36
lines changed

CHANGELOG.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
## x.x.x
1+
## 24.7.4
2+
* Mitigated an issue with the feedback widget URL encoding on iOS 16 and earlier, which prevented the widget from displaying
3+
* Mitigated an issue with content fetch URL encoding on iOS 16 and earlier, which caused the request to fail
4+
25
* Added `CountlyFeedbacks:` interface with new view methods (Access with `Countly.sharedInstance.feedback`):
36
* Method to present feedback widget (wih an optional widget selector(name, ID or tag) string and a Callback):
47
* `presentNPS`

Countly-PL.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Pod::Spec.new do |s|
22
s.name = 'Countly-PL'
3-
s.version = '24.7.3'
3+
s.version = '24.7.4'
44
s.license = { :type => 'MIT', :file => 'LICENSE' }
55
s.summary = 'Countly is an innovative, real-time, open source mobile analytics platform.'
66
s.homepage = 'https://github.com/Countly/countly-sdk-ios'

Countly.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Pod::Spec.new do |s|
22
s.name = 'Countly'
3-
s.version = '24.7.3'
3+
s.version = '24.7.4'
44
s.license = { :type => 'MIT', :file => 'LICENSE' }
55
s.summary = 'Countly is an innovative, real-time, open source mobile analytics platform.'
66
s.homepage = 'https://github.com/Countly/countly-sdk-ios'

Countly.xcodeproj/project.pbxproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -734,7 +734,7 @@
734734
"@loader_path/Frameworks",
735735
);
736736
MACOSX_DEPLOYMENT_TARGET = 10.14;
737-
MARKETING_VERSION = 24.7.3;
737+
MARKETING_VERSION = 24.7.4;
738738
PRODUCT_BUNDLE_IDENTIFIER = ly.count.CountlyiOSSDK;
739739
PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)";
740740
PROVISIONING_PROFILE_SPECIFIER = "";
@@ -766,7 +766,7 @@
766766
"@loader_path/Frameworks",
767767
);
768768
MACOSX_DEPLOYMENT_TARGET = 10.14;
769-
MARKETING_VERSION = 24.7.3;
769+
MARKETING_VERSION = 24.7.4;
770770
PRODUCT_BUNDLE_IDENTIFIER = ly.count.CountlyiOSSDK;
771771
PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)";
772772
PROVISIONING_PROFILE_SPECIFIER = "";

CountlyCommon.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ @interface CountlyCommon ()
2929
#endif
3030
@end
3131

32-
NSString* const kCountlySDKVersion = @"24.7.3";
32+
NSString* const kCountlySDKVersion = @"24.7.4";
3333
NSString* const kCountlySDKName = @"objc-native-ios";
3434

3535
NSString* const kCountlyErrorDomain = @"ly.count.ErrorDomain";

CountlyContentBuilderInternal.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ - (NSURLRequest *)fetchContentsRequest
133133
NSString* queryString = [CountlyConnectionManager.sharedInstance queryEssentials];
134134
NSString *resolutionJson = [self resolutionJson];
135135
queryString = [queryString stringByAppendingFormat:@"&%@=%@",
136-
@"resolution", resolutionJson];
136+
@"resolution", resolutionJson.cly_URLEscaped];
137137

138138
queryString = [CountlyConnectionManager.sharedInstance appendChecksum:queryString];
139139

CountlyFeedbackWidget.m

Lines changed: 41 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -193,47 +193,59 @@ - (NSURLRequest *)dataRequest
193193
}
194194
}
195195

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

207-
queryString = [queryString stringByAppendingFormat:@"&%@=%@",
208-
kCountlyAppVersionKey, CountlyDeviceInfo.appVersion];
203+
// Create a dictionary for query parameters
204+
NSDictionary *queryParams = @{
205+
kCountlyQSKeyAppKey: CountlyConnectionManager.sharedInstance.appKey.cly_URLEscaped,
206+
kCountlyQSKeyDeviceID: CountlyDeviceInfo.sharedInstance.deviceID.cly_URLEscaped,
207+
kCountlyQSKeySDKName: CountlyCommon.sharedInstance.SDKName,
208+
kCountlyQSKeySDKVersion: CountlyCommon.sharedInstance.SDKVersion,
209+
kCountlyFBKeyAppVersion: CountlyDeviceInfo.appVersion,
210+
kCountlyFBKeyPlatform: CountlyDeviceInfo.osName,
211+
kCountlyFBKeyWidgetID: self.ID,
212+
kCountlyAppVersionKey: CountlyDeviceInfo.appVersion,
213+
};
209214

215+
// Create the query string
216+
NSMutableArray *queryItems = [NSMutableArray array];
217+
[queryParams enumerateKeysAndObjectsUsingBlock:^(id key, id obj, BOOL *stop) {
218+
[queryItems addObject:[NSString stringWithFormat:@"%@=%@", key, obj]];
219+
}];
220+
221+
NSString *queryString = [queryItems componentsJoinedByString:@"&"];
222+
223+
// Append checksum to the query string
210224
queryString = [CountlyConnectionManager.sharedInstance appendChecksum:queryString];
211225

212-
NSMutableString* URL = CountlyConnectionManager.sharedInstance.host.mutableCopy;
213-
[URL appendString:kCountlyEndpointFeedback];
214-
NSString* feedbackTypeEndpoint = [@"/" stringByAppendingString:self.type];
215-
[URL appendString:feedbackTypeEndpoint];
226+
// Add the query string to the URL
216227
[URL appendFormat:@"?%@", queryString];
217228

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

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

230-
// Append custom parameter
231-
[URL appendString:customString];
236+
if (!jsonData) {
237+
NSLog(@"Failed to serialize JSON: %@", error);
238+
} else {
239+
NSString *customString = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
240+
// Append the custom parameter to the URL
241+
[URL appendFormat:@"&custom=%@", customString.cly_URLEscaped];
242+
}
232243

233-
NSURLRequest* request = [NSURLRequest requestWithURL:[NSURL URLWithString:URL]];
234-
return request;
244+
// Create and return the NSURLRequest
245+
return [NSURLRequest requestWithURL:[NSURL URLWithString:URL]];
235246
}
236247

248+
237249
- (void)recordReservedEventForDismissing
238250
{
239251
[self recordReservedEventWithSegmentation:@{kCountlyFBKeyClosed: @1}];

0 commit comments

Comments
 (0)