Post

Replies

Boosts

Views

Activity

Reply to WKWebview ignoring form Posts
This is for a Cordova app. I'm by no means an Objective-C dev, just read some intro book before, so check for errors. :-) /** * Cordova web view handler calls this method for every page navigation. * https://github.com/apache/cordova-ios/blob/master/CordovaLib/Classes/Private/Plugins/CDVWebViewEngine/CDVWebViewEngine.m#L538 */ - (BOOL) shouldOverrideLoadWithRequest:(NSURLRequest*)request navigationType:(WKNavigationType)navType { NSString* contentType = [request valueForHTTPHeaderField:@"content-type"]; if (navType == WKNavigationTypeFormSubmitted && [contentType isEqual:@"application/x-www-form-urlencoded"]) { NSData* data = request.HTTPBody; NSString* textData = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding]; NSString* queryString = [NSString stringWithFormat:@"?%@", textData]; NSURLComponents* urlComponents = [NSURLComponents componentsWithString:queryString]; for (NSURLQueryItem *item in urlComponents.queryItems) { // etc
Topic: Safari & Web SubTopic: General Tags:
Jul ’21