Reply To: iOS issue

Welcome! Forums Unity Plugins In-App Web Browser iOS issue Reply To: iOS issue

#1349
MeMyself
Participant

OK I found it.
it seems there is a bug (don’t know where it come from). Sometimes the url string gets a linebreak at the end (I’m sure it doesn’t come from my url because I have the same test string variable sometimes working, sometimes not). So this line in AppBrowserViewController.mm startLoadingWebView was returning null
NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:_URL]];

So here’s what I did

(void)startLoadingWebView {
    _webView.delegate = self;
    if (_HTML) {
        [_webView loadHTMLString:_HTML baseURL:nil];
    } else {
        NSString *webStringURL = _URL;
        NSArray *split = [webStringURL componentsSeparatedByCharactersInSet:[NSCharacterSet newlineCharacterSet]];
        split = [split filteredArrayUsingPredicate:[NSPredicate predicateWithFormat:@"length > 0"]];
        webStringURL = [split componentsJoinedByString:@""];
        NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:webStringURL]];
        [_webView loadRequest: request];
    }

There must be a cleaner way, but it works.