59262

Automatic credentials input in UIWebview - iOS

Question:

I want to create an iOS app with a feature that - user can store username and password for particular website, and when the go to that website credentials will automatically typed in the webview and it will submitted automatically.

The concept is implemeted in the app - <a href="https://www.google.com/url?sa=t&rct=j&q=&esrc=s&source=web&cd=4&cad=rja&uact=8&ved=0CDYQFjAD&url=https%3A%2F%2Fitunes.apple.com%2Fus%2Fapp%2Fdashlane-password-manager%2Fid517914548%3Fmt%3D8&ei=TpLWU4fQBIim8AXKkoD4Cg&usg=AFQjCNHxhqFoHy5hKh34pg__rcLCKOvaBw&sig2=O5Ztt46aR71H5nlozWHiPA&bvm=bv.71778758,d.dGc" rel="nofollow">Dashlane</a>

I know this can be done with HTML and Javascript. But I am not strong in Javascript. Can anyone please describe this ? It would be so kind of if you put some example.

Say there is a website with url - <a href="http://www.quickeeme.com" rel="nofollow">http://www.quickeeme.com</a> and my username is "hamdaman" and password is "123456". How can I load this url in a Webview with autofill this credentials on the fields ?

Answer1:

Here is some code I used in the past that allowed me to enter user credentials and click a login button. You'll need to change sid, pin, and btnLogin to the appropriate variables on the webpage you're using (you can find them using "View Source" in Chrome, for example):

//Write Javascript code in a string NSString* javaScriptString = @"document.getElementById('sid').value='%@';" "document.getElementById('pin').value='%@';" "document.getElementById('btnLogin').click()"; //Insert string values into the Javascript string javaScriptString = [NSString stringWithFormat:javaScriptString, yourUsername, yourPassword]; //Run Javascript in web view [webView stringByEvaluatingJavaScriptFromString:javaScriptString];

Recommend

  • UICollectionview scroll horizontal and vertical
  • Is there a greater chance to collide when comparing GUIDs based on a hash vs \"Guid.NewGuid()?
  • Phonegap Android App, open links within app?
  • wordpress query - next two events by metadata date
  • input type=“file” accept=“image/*” doesn't work in phone gap?
  • Why is OpenID Connect considered mobile friendly compared to SAML
  • setContentView() is not enough to switch between layouts?
  • JavaScript IE rotation transform maths
  • NHibernate manually control fetching
  • How do I mock an exported typescript function in a jasmine test?
  • Git describe fails to return most recent annotated tag
  • C# program and C++ DLL compiled for 32-bit system crash on 64-bit system
  • Loading .coffee files via a view in Rails
  • Zurb Foundation _global.scss meta styles for js?
  • jQuery ready not fired after rails link_to is clicked
  • Create DicomImage from scratch using Dcmtk
  • Yii2: Config params vs. const/define
  • Java: can you cast Class into a specific interface?
  • Ajax Loaded meta Tags
  • HTML download movie download link
  • AES padding and writing the ciphertext to a disk file
  • angularjs unit test when to use $rootScope.$new()
  • Updating server-side rendering client-side
  • How to extract text from Word files using C#?
  • How to model a transition system with SPIN
  • Weird JavaScript statement, what does it mean?
  • jquery mobile loadPage not working
  • Circular dependency while pushing http interceptor
  • bootstrap to use multiple ng-app
  • How to get icons for entities from eclipse?
  • KeystoneJS: Relationships in Admin UI not updating
  • AngularJs get employee from factory
  • Proper way to use connect-multiparty with express.js?
  • Load html files in TinyMce
  • How to set the response of a form post action to a iframe source?
  • Setting background image for body element in xhtml (for different monitors and resolutions)
  • Change div Background jquery
  • Turn off referential integrity in Derby? is it possible?
  • JaxB to read class hierarchy
  • How to load view controller without button in storyboard?