HTML5 gps inside a WebView - ios

Was curious about something the other day and could not find an answer.. With a native iOS app, if you load a page in a WebView that uses the gps functionality of HTML5, is the user prompted the same way they would be if viewing it in a browser?
(Yes, I know you could use native API if it's already a native app, but curious nonetheless and have no way to perform a test)

Yes you will see the same alert, it's a system alert.
However, other than triggered by a native app, the users choice will not be persistent and the alert will be shown on every visit.

Related

What are some alternatives for deferred deep-linking without using the clipboard?

Currently we utilize the clipboard for deferred deep linking, but with the upcoming changes to iOS16 we expect the success rate to drop drastically. What other alternative methods are possible? We are considering branch.io but we'd like to explore options for an in-house solution first.
You can do something like this:
web app has page, with deep link that is either opens your native app or opens app installation page.
if native app is installed just use deep link to pass some data
if native app is not installed, save your data to local storage and continue to app store
when native app is opened, redirect user to web app, read your local storage and give user some "continue" button, that is actually a deep link, same as on step 1
I wish someone has a better solution.

Show recaptcha in iOS native app from supremenewyork.com

I have an iOS app in which supremenewyork.com website is opened in web view. Sometime website shows one click recaptha (like when do payment).
My client wants to show the same recaptcha in the native app if it’s shown on website when user returns to the app. Is it possible?
If yes then how?
In theory, yes — this is entirely possible. You'll first want to get the data-sitekey by inspecting the page source that contains the CAPTCHA, after which you can use this repo this repo to get the initial implementation working in your iOS app (assuming by native you mean Swift).

How do I avoid the "Open this page in 'appName'" alert from appearing in Safari for iOS?

I am creating a flow that:
1) takes the user from my iOS app to my website through Safari
2) and then navigates back into the app via javascript
However when I try and redirect the user back to my app from my site using url schemes, i get the familiar "Open this page in 'appName'" alert.
Is there a way to avoid this alert from showing up? Is there some way to whitelist my website as a source for my app to allow me to direct the user back to my app w/out any alerts?
It seems like it might be possible with Universal Links, but I am wondering if there is a simpler way to do so.
EDIT: I should have mentioned that I have the unique requirement that I need to use Safari. I am processing donations in my app, and Apple requires you to go this through Safari and not a webview. Any ideas? –
You can achieve this using webView instead of Safari,so that
control will not go out of the App.
Now the problem is how to get the click from webView, for that you can
use this approach
How to invoke Objective C method from Javascript and send back data to Javascript in iOS?
I have integrated this approach in my App so this approach will work for sure. It feels like you are in APP & some times it will diificult to differentiate between WebPage & native page

How does the Facebook app for iPhone work?

I will soon be writing a native iPhone app for my web site. The web site is already mobile optimised so could potentially just sit in a UIWebView. How does the Facebook app work? Does it do something similar?
If I did use a UIWebView then how would I store user credentials so they don't have to log in every time and how would they upload photos? These are my two main requirements.
The facebook app is going to be a native app. It is different from the mobile website.
There are two things you can do here. If you're going to make your native app just a UIWebView then don't bother! You can have an apple icon embedded in your website which will show if a user bookmarks your website on their home screen. To use this use the <link rel="apple-itouch-icon" href="/apple-touch-icon.png" /> code to do it.
The second is make a fully native app. I know the benefits of a UIWebView app, but the negatives are plain to see. UIWebView apps are tacky, nonfunctional and terrible to use. A mobile website is not an app (unless done very well). You will have links to click, pinch and zoom, awful bounce effects on the web view, links that may possibly allow users to navigate away from your mobile website but within your app. Again, unless done cleverly, you will have to provide browser controls on your app which will make it look like a tacky web browser.
My suggestion would be either stick with your website, optimise it for touch based input, make it a really good mobile website, or create a fully functional native application. Remember not all websites need to have an app to go with it. If your app isn't necessary then its merely counter productive to make an app for it. I don't know about anyone else, but I spend more time in my web browser than I do in apps.
With regards to uploading and auth then a) auth should be done already in your website. A UIWebView is just an instance of safari working within your app, so it will be able to get and store cookies and all sorts. I believe these degrade at the end of the app session, however its easy to pass to the objective c and store in an stored preference. b) uploads not going to work even if you put your site in a web view. You will have to (at some point) hand off to an upload screen in your app which is running natively.
I would suggest that you start off with a simple native app. Let the users log in, upload stuff and do other basic stuff - whatever they can't currently do on your mobile website. Then move on to other things as people ask for them, or as you have the time to make them. You don't have to launch your app with a fully functioning version of you website (in fact this would be silly because the only thing they cannot do on your mobile website on their phone is upload stuff). I'm sure people will request features as your product evolves.
I would take a look at PhoneGap, you can get access to native device features through javascript http://phonegap.com/

Tracking HTML5 Web App installs on iOS devices

We recently launched an HTML5 Web App (using JQuery Mobile), which has a slide down box encouraging users to bookmark the Web App on their home screens. Users can do this from Safari by clicking Bookmark and then "Add to Home Screen". Any thoughts on how we might be able to track the number of "installs". I don't believe we can add any tracking to the native iOS bookmarking behavior from within the HTML5 Web app.
Thanks
I'm not sure you can get an event whenever the user installs the web app on their homescreen. However, you can know if the user is in 'full screen' / 'web app' mode by checking the window.navigator.standalone property in Javascript. So you might be able to do a call to your statistics provider and provide them the standalone property as well.
You can at least detect whether the app is launched from the homescreen or via browser via the window.navigator.standalone flag. You could use it in combination with cookies or localstorage to ensure you count unique installs in your backend.
You can also try to store the result of window.navigator.standalone into Google Analytics

Resources