I have an iOS app that loads an HTML file from the bundle. The app downloads data to it's document directory and passes the document path to the javascript code to retrieve the downloaded data offline.
When we used the UIWebView this was working perfectly. but not working with WKWebView. The document path sent to the JS is not working although the data is present in the document location. The "downloadPaths" contain data like images, epub files, etc. In simulator it is working as expected but not on real device.
Am I missing anything? The HTML file is successfully loading in the WKWebView and other things like app login, resource downloads are working.
Code Block l NSMutableArray * bookrecords = [dbHandler getOfflineBookRecords:@"complete"]; if (!(bookrecords == nil || [bookrecords count] == 0)) { for (NSDictionary *dict in bookrecords) { NSString *downloadPaths = dict[@"localDownloadPaths"]; NSString *bookName = dict[@"bookName"]; bookName = [bookName stringByReplacingOccurrencesOfString:@"'" withString:@"####"]; NSString *level = dict[@"level"]; NSString *theme = dict[@"theme"]; NSArray *components = [downloadPaths componentsSeparatedByString:@","]; NSMutableArray *temp = [[NSMutableArray alloc] init]; for (NSString *path in components) { if ([path containsString:@"~/Documents"]) { NSString *path1 = [path stringByReplacingOccurrencesOfString:@"~/Documents" withString:[DocumentManager sharedInstance].documentRootPath]; [temp addObject:[path1 stringByAppendingString:@"/"]]; } } NSString *mergedPath = [temp componentsJoinedByString:@","]; if ([level isEqualToString:@"0"] && [theme isEqualToString:@"default"]) { [dict setValue:@"undefined" forKey:@"level"]; } [dict setValue:mergedPath forKey:@"localDownloadPaths"]; [dict setValue:bookName forKey:@"bookName"]; [dict setValue:[NSNumber numberWithBool:[dict[@"coaching_book"] boolValue]] forKey:@"coaching_book"]; } } NSMutableDictionary *offlineDetails = [[NSMutableDictionary alloc] init]; offlineDetails[@"username"] = dict[@"username"]; offlineDetails[@"method"] = dict[@"method"]; offlineDetails[@"offlineDetails"] = (bookrecords == nil || [bookrecords count] == 0) ? @[] :bookrecords; NSString *jsonString = [self dictionaryToJSON:offlineDetails]; NSString *tempJsonString = [jsonString stringByReplacingOccurrencesOfString:@"####" withString:@"\\\'"]; NSString * jsCallBack = [NSString stringWithFormat:@"NativeBridge.resultForCallback(%d,['%@'])", callbackID,tempJsonString]; [self.webView evaluateJavaScript:jsCallBack completionHandler:nil];
When we used the UIWebView this was working perfectly. but not working with WKWebView. The document path sent to the JS is not working although the data is present in the document location. The "downloadPaths" contain data like images, epub files, etc. In simulator it is working as expected but not on real device.
Am I missing anything? The HTML file is successfully loading in the WKWebView and other things like app login, resource downloads are working.