WKWebView Password autofill like Safari - ios

In my app I have a WKWebView to browse Internet in general, it's not tied to a specific website. I'd like to let the users to have login forms auto filled directly from the KeyChain.
When I tap the fields, in the QuickType bar I can see a "Passwords" button to open the passwords list, then I can search the website and finally the WKWebView fills the information.
I'd like to have a much more direct experience like on Safari, please see the screenshots.
My app when I tap on the textfield:
The list appearing when you tap the "Passwords" button:
This is Safari when tapping on the text field:
I don't want to fill the information via Javascript.
Is there a way to do this or is it just a Safari thing?

Related

Switch between WebView and NativeView with Swift

Problem Statement:
I have an a native app which has a G+ single sign-on.
When I click that button, it displays an alert - "application wants to use google.com to sign-in" along with 2 buttons "Continue" and "Cancel"
When I press "Continue" on the alert, it opens a browser inside the app where the account selection page opens. It shows accounts.google.com as the page URL.
Assuming that I've already signed in to Google once before, I want to select / click a particular account from the list of google accounts being displayed there.
After I click the account, the user is navigated to a native screen called "Dashboard".
To automate this, in Appium + Java, I click on the G+ button and then switch the context to webview and then select the account using xpath and then switch back to native view as login is done now and application is back to the native screen.
driver.findElement(By.xpath("XPATH of Native Screen - Google SignIn Button")).click;
driver.switchTo().alert().accept();//Clicks "Continue" Button.
driver.context("WEBVIEW"); //Switch to WebView
driver.findElement(By.xpath("XPATH of intended Account Name HTML control")).click();
driver.context("NATIVEVIEW");
...Then, I perform the other operations that I want to perform on the native app screen.
I want to do the same in XCode + Swift but I'm not finding any way to do it.
Here's what I do
//some code to click on the button
app.buttons["Google Sign In"].tap()
app.alerts["“AppName” Wants to Use “google.com” to Sign In"].buttons["Continue"].tap()
...Now I don't know how to switch to WebView of the App and click on the HTML control that contains the account name and then switch back to native view.
Please help.
Try using this when you click on sign in with google:
GIDSignIn.sharedInstance().signOut()

What is the difference between tapping keyboard "Go" button and web page button

TL;DR
I'm trying to understand what is the difference between user tapping "Go" button on software keyboard and tapping "Sign In" button rendered on authentication web page when using SFSafariViewController to authenticate user via Azure or any other OAuth provider.
Description
We're using various OAuth providers (Azure, Keycloack to name a few) to authenticate users to our native iOS application.
We present to a user, browser instance (SFSafariViewController) with login page
This page contains username, password fields and a button to sign in
When user is entering the password - he/she can either use Log In button on the page or Go button on the iOS software keyboard
In both cases login procedure will be triggered and user will be redirected back to proper URL
However, if user taps Go button on the software keyboard, application is not being notified about redirect (universal link logic doesn't work) and redirect URL page is being rendered inside SafariViewController
It happens in various OAuth providers and can be reproduced only on iOS (when using Android software keyboard button, universal link behaves fine)
We're handling this situation right now by creating special redirect page, which contains special link to a user to tap. Something like "Tap here if you're not automatically redirected back to the application". But I was wondering if there is better solution to this and what is the difference from the OS/Browser perspective between user tapping software keyboard button and HTML page element.
Your workaround seems reasonable.
About activating Universal Links when user navigates from keyboard: this case seems to be similar to situation when user types some URL to browser's address bar and tap GO. If user doing this, than the user intent is to stay in browser, not go to the App. So it is logical to not engage Universal Links.
One more way to make better experience for this case:
if user navigated to "special redirect page" on iPhone, try to navigate to customURLScheme URL of your App. At this point you already know that the App is installed on this device.
Trying to navigate to customURLScheme URL will bring up iOS system dialog, like "Do you want to open XYZ App?". Still this seems a bit better than "Tap here if you're not automatically redirected back to the application".
Probably you already found out that "special redirect page" should be located on different domain than "Universal Links enabled domain". Navigating inside the same domain will not engage Universal Links. For reference, App Preview page that we have, serves essentially the same purpose as yours "special redirect page".
This is because Universal Links on iOS cannot be programmatically opened. When you click the "Go" button you're essentially programmatically submitting the input form (You can recreate this yourself by typing in the Universal link into the Safari bar and clicking go, the app will not open). A Universal Link can only be opened when a user intentionally taps on the link itself or a link that redirects to the Universal Link.
Assuming you have control over the OAuth form, I found the following technique to provide a fairly good experience:
<button type="submit"
style="visibility:hidden; height: 0; margin: 0; padding: 0;"
onclick="document.activeElement.blur(); return false;">
</button>
Add this hidden button ABOVE all other submit buttons on your form. When the Go button is pressed, I've observed that it "clicks" the first submit button on the form. This button catches that click, blurs the current input causing the keyboard to be dismissed, and then cancels the form submission. The user then can tap the visible button(s) on the form to complete the process correctly. No need for two flows.
This also allows for users on desktop using the same OAuth form to press Enter to submit the form or to click the buttons.

How to disable lock the Home button in iOS 7

How can I lock the home button in iOS 7 ?
I have 10 text fields and a submit button in a view. While I'm filling the text fields, the home button should be disabled.
Only after filling all the text fields, should the home button be again enabled.
Please let me know anybody, how to achieve this.
Thanks in advance.
Disabling the Home button using your app is not possible but you can use Guided Access to block the Home button, but this is something the users will have to do. I don't think there's an API to do it within an app.
From Apple:
Guided Access helps students with disabilities such as autism remain
on task and focused on content. It allows a parent, teacher, or
administrator to limit an iOS device to one app by disabling the Home
button, as well as restrict touch input on certain areas of the
screen.

Add Share Button to Naviagtion Bar

I'd like to add a share button to the navigation bar in a webview that when pressed gives the options to open the link in Safari, Email the link, share on facebook, tweet it. Can anyone point me in the right direction on how to go about this?
Try BCDShareSheet. It includes sharing with Email, Twitter, and Facebook, but it lacks opening in Safari, but it should be trivial to add it.

iPad Safari Home Screen website gets stuck on Facebook Login

I have a website that uses the JavaScript SDK, and I have a facebook login button that calls FB.login() that opens a new tab for the user to log in.
This website is optimized for the iPad, and I made a home screen entry for this website so it could be viewed in full screen, like how this article mentions it:
http://www.viaboxxsystems.de/html-fullscreen-apps-for-the-ipad
My problem is that only in the home-screen-launched, fullscreen version, when I click on the login button, either I see a white screen, or I get the login details screen (but in that case, clicking "Log In" also results in a white screen), and thus I get to a dead end.
How do I make it so the Facebook login goes through and I get redirected back to my website successfully?
Apple’s documentation for this says,
When you use this standalone mode, Safari is not used to display the web content—specifically, there is no browser URL text field at the top of the screen or button bar at the bottom of the screen.
Sounds to me like this might also affect the ability to open popups. If that’s the case, you could maybe use the server-side authentication flow instead.

Resources