iOS Application Opens Safari

4 posts, 0 answers
  1. Travis
    Travis avatar
    4 posts
    Member since:
    Mar 2017

    Posted 19 Jun Link to this post

    Hello,

    I'm currently building an application and after the user logs in the application gets imported into the project. With android i was allowed to use the code below in the config XML file which will port my app from that URL.

    ````<allow-navigation href="http://*/Web/*" />````

    Current iOS = PLATFORM_VERSION_BUILD_LABEL = '4.3.1';

    However with iOS this solution doesn't work. I've read many stack overflows and forums with no luck. Does anyone know what I can do to stop safari from opening and use the applications native view.  Thanks.

     

    - Travis

  2. Martin
    Admin
    Martin avatar
    103 posts

    Posted 22 Jun Link to this post

    Hi Travis,

    I assume you want to navigate to an existing web application inside the WebView. You may achieve this using the InAppBrowser plugin. Also setting the <allow-navigation> in iOS config.xml (here is how to set it up) should apply to iOS as well for cordova-ios 4.x and up, as stated in the iOS Whitelisting documentation.

    Let me know if this has worked on your side.

    Regards,
    Martin
    Progress Telerik
     

    Visit the Telerik Verified Plugins Marketplace and get the custom Cordova plugin you need, already tweaked to work seamlessly with AppBuilder.

     
  3. Travis
    Travis avatar
    4 posts
    Member since:
    Mar 2017

    Posted 22 Jun in reply to Martin Link to this post

    Martin,

    The problem is then I lose all access to the cordova api list. We are trying to store our application software on our server so updates get made without re-deploying apps. So with android we replace the app files with files from the server and we are allowed to use the default UIWebView using the window.location.replace method. We still need to be able to access the scanner from the cordova api. However in iOS that doesnt work. iOS will open safari.

    - Travis

  4. Martin
    Admin
    Martin avatar
    103 posts

    Posted 27 Jun Link to this post

    Hi Travis,

    I see you are trying to load a website as a mobile app - you may review this article. Please note that  Apple App Store may reject your app if it only opens a web page inside an app.

    As to your question - to load the content in the WebView:

    • without using the inAppBrowser plugin - set the allow-navigation tag in your iOS config file so that the WebView itself can be allowed navigation to a specific site without opening Safari
    • when using inAppBrowser - open the link by setting the target to "_self" which would open the URL in the Cordova WebView

    Still, event with the above method you would loose the access to Cordova Native APIs. In general in a Hybrid app you have a starting/main index.html and when you navigate to different views, the same index.html gets different DOM elements added/hidden and thus different views are shown/removed. Thus a Hybrid app is similar to a single-page application - you navigate through the different DOM elements of that page and not through different pages.

    All app logic is saved in window.app object of the loaded index.html. When loading the page, cordova.js is loading the Cordova Native APIs in the window object as well. Therefore, when you navigate to a different .html page all data and methods are lost (window object is overwritten as well as all methods and data saved, as if the application is closed).

    I hope this has helped.

    Regards,
    Martin
    Progress Telerik
     

    Visit the Telerik Verified Plugins Marketplace and get the custom Cordova plugin you need, already tweaked to work seamlessly with AppBuilder.

     
Back to Top