androidhtmliosmobile

Making an iOS and Android app that will only show a specified web page and have the option to include forward/back buttons


I need to make an app that will only display a public web URL that mainly contains HTML, I want to be able to include back and forward buttons if a exact specific URL is displayed or users can swipe from the side or something to display them (NO swiping from the side or bottom). I should be able to specify which domains and subdomains should be shown in the app and everything else would be opened in Safari.

I would really appreciate if someone could find some kind of (free) solution or if they would like, they could make something for anyone else who is interested in having an Web Based App Template like this. Bonus points for Android and iOS versions and even more for iOS and iPad versions. Greatly Appreciated!


Solution

  • This would be quite easy using UIWebView (on iOS)... define your webview inside let's say the main UIViewController

    UIWebView *webView = [UIWebView alloc]init];
    webView.delegate = self
    [webView loadHTMLString:@"yoursite.com" baseURL:nil]
    

    on the delegate you should implement

    - (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType {
    
      if(request.url.absoluteString isEqualToString:@"any of the strings you want") {
         return YES;
      }
    
      else  {
         [[UIApplication sharedApplication] openURL:request.url]
    
         return NO;
      }
    
    
    }
    

    code is actually not tested but something by this idea should work on iOS... i only can help you with the iOS part though... hope this helps you...

    PS: to use the back and forward you should create a UIToolBar with two buttons and enable and disable them using

    if(webView.canGoBack)
       backButton.enabled=YES;
    
    if(webView.canGoForwad)
       forwardButton.enabled=YES;
    

    and this buttons calls the method goBack and goForward of the UIWebView..