Skip to content
This repository has been archived by the owner on Apr 6, 2022. It is now read-only.

meetuparchive/MUSharedWebCredential

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MUSharedWebCredential

MUSharedWebCredential is a little class that takes all the pain out of working with passwords saved by Safari AutoFill. It lets you work with those passwords in Swift apps, and neatly hides the fact that the necessary API methods don't exist in iOS 7 and Xcode 5.


How to use this class

Before you can use this class, you must set up your app-website association. See the 2014 WWDC video “Your App, Your Website, and Safari” for instructions.

Requesting a password from Safari AutoFill requires user approval

[MUSharedWebCredential requestCredentialWithSuccess:^(NSString *username, NSString *password, NSString *domain) {
    [MULoginManager logInWithUsername:username password:password];
} failure:^(NSError *error) {
    [self showError:error];
}];

Saving a password in Safari AutoFill requires user approval if editing an existing credential

[MUSharedWebCredential saveCredentialWithUsername:username
                                         password:password
                                           domain:@"meetup.com"
                                       completion:NULL];

Deleting a password from Safari AutoFill requires user approval

[MUSharedWebCredential deleteCredentialWithUsername:username
                                             domain:@"meetup.com"
                                         completion:NULL];

Generating a strong, unique password

NSString *randomPassword = [MUSharedWebCredential randomPassword];