Skip to content

Commit

Permalink
fixed naming, adding preconditionfailure
Browse files Browse the repository at this point in the history
  • Loading branch information
edjiang committed May 12, 2016
1 parent d4c5316 commit cb0330e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
8 changes: 4 additions & 4 deletions Simplicity/LoginProviders/Facebook.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import Foundation

public class FacebookLoginProvider: OAuth2LoginProvider {
public class Facebook: OAuth2LoginProvider {
public var scopes = Set<String>()
public var urlScheme: String

Expand Down Expand Up @@ -51,14 +51,14 @@ public class FacebookLoginProvider: OAuth2LoginProvider {
callback?(authToken: accessToken, error: nil)
}

public init?() {
public init() {
// Search for URL Scheme, error if not there

guard let urlScheme = Helpers.registeredURLSchemes(matching: {$0.hasPrefix("fb")}).first,
range = urlScheme.rangeOfString("\\d+", options: .RegularExpressionSearch) else {
return nil
preconditionFailure("You must configure your Facebook URL Scheme to use Facebook login.")
}
self.urlScheme = urlScheme
self.clientId = urlScheme.substringWithRange(range)
}
}
}
3 changes: 2 additions & 1 deletion Simplicity/Simplicity.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import SafariServices

public typealias ExternalLoginCallback = (authToken: String?, error: NSError?) -> Void

public class LoginManager: NSObject {
public class Simplicity: NSObject {
static var currentLoginProvider: LoginProvider?
static var callback: ExternalLoginCallback?
static var safari: UIViewController?
Expand All @@ -25,6 +25,7 @@ public class LoginManager: NSObject {

/// Deep link handler (iOS9)
public static func application(app: UIApplication, openURL url: NSURL, options: [String : AnyObject]) -> Bool {
safari?.dismissViewControllerAnimated(true, completion: nil)
if url.scheme != currentLoginProvider?.urlScheme {
return false
}
Expand Down

0 comments on commit cb0330e

Please sign in to comment.