This is a migrated thread and some comments may be shown as answers.

iOS Application Opens Safari

3 Answers 103 Views
General Discussion
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Travis
Top achievements
Rank 1
Travis asked on 19 Jun 2017, 09:03 PM

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

3 Answers, 1 is accepted

Sort by
0
Martin
Telerik team
answered on 22 Jun 2017, 02:39 PM

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.

 
0
Travis
Top achievements
Rank 1
answered on 22 Jun 2017, 04:12 PM

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

0
Martin
Telerik team
answered on 27 Jun 2017, 12:44 PM

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.

 
Tags
General Discussion
Asked by
Travis
Top achievements
Rank 1
Answers by
Martin
Telerik team
Travis
Top achievements
Rank 1
Share this question
or