Search code examples
titaniumappceleratortitanium-mobile

can't able to access URL using webview in Titanium Appcelerator


I am tring to access a url from a server into my webview. But it's returning following error;

[ERROR] : Error loading: (null), Error: Error Domain=WebKitErrorDomain Code=101 "The operation couldn’t be completed. (WebKitErrorDomain error 101.)"

When i hardCoded that same URL(from webservice) into webview, I am able to get corresponding webpages.[url : "https:\...........%20n%20..."]

webview = Ti.UI.createWebView({
    height : Ti.UI.SIZE,
    top : 0,
    width : Ti.UI.SIZE,
    html : service.sampleURL,
});

How can i consume URL directly from server instead of hardcoding it?


Solution

  • WebKitErrorDomain error 101 means WebKitErrorCannotShowURL. Check how exactly url retrieved from the server looks like and is it encoded, if so use decodeURIComponent().

    Also creation of WebView should looks like:

    webview = Ti.UI.createWebView({
        height : Ti.UI.SIZE,
        top : 0,
        width : Ti.UI.SIZE,
        url : service.sampleURL,
    });
    

    If it doesn't work, provide more code so we could see more exactly where is a problem.