WKWebView ask twice for location permission - ios

I have a simple iOS Swift App
let url = URL(string: "https://www.mycustompage.com")!
webView.load(URLRequest(url: url))
In Info.plist I allowed all privacy-location permissions.
On https://www.mycustompage.com there is a HTML button which locates the user.
Now I have the problem that my app asks twice for the location permissions.
Once for the app and once for the WKWebView.
How can I disable the request for the WebView!?
Thanks

I'm guessing that this is because your webpage is asking for location and safari is basically another app running inside your viewcontroller. One way to bypass this is to simply not ask for the user location in your webpage. instead ask for the user location in the app, then inject then location into your webview with javascript using evaluateJavaScript(_:completionHandler:). Obviously you need to wait until you have both the location and for the page to be full loaded before you make the javascript call.

Related

Using browser location inside of SFSafariViewController

I have a webpage that uses location data from the browser that I want to open up inside an ios application.
If I open this page up inside a UIWebview I will see the page ask for location and after I respond the page finishes loading.
However, when I try to open this page up inside of a SFSafariViewController I do not get prompted for location which prevents the page from loading. I definitely want to use SFSafariViewController but I first need to fix this problem.
I've been unable to find any information about using location with SFSafariViewController. Does anyone know how to get this working?

inAppBrowser Ios hide location URL

I have a scenario where I have to load an external URL within an App. I also want to come back to the App from the external browser.
`var ref = cordova.InAppBrowser.open('http://apache.org', '_blank', 'location=yes');`
I tried this and this is giving a DONE button, which brings me back to the App. However this shows the URL of the external page. I dont want the user to see the external URL. Is there any solution to this? Please help!

Can app open browser, get user to login and receive file?

I'm trying to write an iOS Objective-C app to login to an old website. Note I don't have control of the website so I have no way of changing the login.
The procedure is:
Open browser at specific URL.
User enters their username and password.
Website returns a file called something like bad_link.smith.
App reads file to get key to use for API.
Is it possible to do this in iOS - open a URL from an app and have the file returned?
You could use UIWebView Delegates for this
Implement this https://developer.apple.com/library/prerelease/ios/documentation/UIKit/Reference/UIWebViewDelegate_Protocol/index.html#//apple_ref/occ/intfm/UIWebViewDelegate/webView:shouldStartLoadWithRequest:navigationType: delegate method and get the URL the user is going to and if the URL matches the URL you want to download then you can get the URL by the NSURLRequest and download it seperately. :) Hope I helped you.
What other thing you could do is make the code native and without the browser and simulating as a browser in the code. Can be used if no CAPTCHA is there. Do tell if you need more info on this.

iOS: Open a registered open URL from within the same app

I am running into a situation which I am not sure is possible from technical/design point of view. Please advise.
Here is what I need:
I have an open URL registered for my native iOS app. I expect a request ID to be passed along with it and once hit I open that request.
From within my native iOS app, I need to open a web page in the webview. This page has few buttons in it.
A tap on the button in the webview should open the request inside my app. So, I want to trigger the registered open URL in step #1.
Web page data is dynamic and will change on the fly.
Is this a feasible design. Shall I consider something else.
Any advise/pointers will be appreciated.
This should be possible. Here's a though:
1: Implement the UIWebview delegate method shouldStartLoadWithRequest.
2: when you intercept that your webview is attempting to access the url yourapp://blah-blah-blah you can return NO instead dip into your appdelegate can manually call the function handleOpenURL.
I've seen something similar in the past with supporting oAuth (I believe it was with instagram) within one of our apps. We basically loaded up the login page in a UIWebview and then when we detected the the post login redirect we parsed the oAuth token from the url and called it good.
Good luck

Invoking Safari on iOS without opening a new website

The situation is like this:
User opens app from a website using a custom urlscheme
User does stuff in the app
User clicks button in the app to return to the website in Safari.
I have tried opening a new tab containing a javascript:window.close() but this does not work on iOS 6.1.
So my question is: Is there a way to open Safari to view the website the user left from? Either with a working new tab that closes itself or a different route?
When you open the app with your custom url scheme, pass the actual page url as an argument.
mycustomUrlScheme://mydomain.com?objectid=1234&callback_url=encoded_url
In your app, handle the url for the content info and keep the page url to open it afterwards. It will make safari open a new tab. But that should be a good start.
As far as i understand you can do it.
user opens mobile safari for example http://www.example.com
user clicks a link that is appscheme://open and the application become active
user taps a button to open safari for example http://www.example.com?q=test
for the third step you can use [[UIApplication sharedApplication]openURL:url]

Resources