diff --git a/Example/BiometricAuthExample/BiometricAuthExample.xcodeproj/project.pbxproj b/Example/BiometricAuthExample/BiometricAuthExample.xcodeproj/project.pbxproj new file mode 100644 index 0000000..9d5ecd0 --- /dev/null +++ b/Example/BiometricAuthExample/BiometricAuthExample.xcodeproj/project.pbxproj @@ -0,0 +1,387 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 46; + objects = { + +/* Begin PBXBuildFile section */ + 040536241DF01AD400F189BA /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 040536231DF01AD400F189BA /* AppDelegate.swift */; }; + 040536261DF01AD400F189BA /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 040536251DF01AD400F189BA /* ViewController.swift */; }; + 040536291DF01AD400F189BA /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 040536271DF01AD400F189BA /* Main.storyboard */; }; + 0405362B1DF01AD400F189BA /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 0405362A1DF01AD400F189BA /* Assets.xcassets */; }; + 0405362E1DF01AD400F189BA /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 0405362C1DF01AD400F189BA /* LaunchScreen.storyboard */; }; + 040536531DF01B6000F189BA /* BiometricAuth.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 0405363D1DF01B0600F189BA /* BiometricAuth.framework */; }; +/* End PBXBuildFile section */ + +/* Begin PBXContainerItemProxy section */ + 0405363C1DF01B0600F189BA /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 040536351DF01B0500F189BA /* BiometricAuth.xcodeproj */; + proxyType = 2; + remoteGlobalIDString = 52D6D97C1BEFF229002C0205; + remoteInfo = "BiometricAuth-iOS"; + }; + 0405363E1DF01B0600F189BA /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 040536351DF01B0500F189BA /* BiometricAuth.xcodeproj */; + proxyType = 2; + remoteGlobalIDString = 52D6DA0F1BF000BD002C0205; + remoteInfo = "BiometricAuth-macOS"; + }; + 040536401DF01B0600F189BA /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 040536351DF01B0500F189BA /* BiometricAuth.xcodeproj */; + proxyType = 2; + remoteGlobalIDString = 52D6D9861BEFF229002C0205; + remoteInfo = "BiometricAuth-iOS Tests"; + }; + 040536421DF01B0600F189BA /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 040536351DF01B0500F189BA /* BiometricAuth.xcodeproj */; + proxyType = 2; + remoteGlobalIDString = DD75027A1C68FCFC006590AF; + remoteInfo = "BiometricAuth-macOS Tests"; + }; +/* End PBXContainerItemProxy section */ + +/* Begin PBXFileReference section */ + 040536201DF01AD300F189BA /* BiometricAuthExample.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = BiometricAuthExample.app; sourceTree = BUILT_PRODUCTS_DIR; }; + 040536231DF01AD400F189BA /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; + 040536251DF01AD400F189BA /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; }; + 040536281DF01AD400F189BA /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; + 0405362A1DF01AD400F189BA /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; + 0405362D1DF01AD400F189BA /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; + 0405362F1DF01AD400F189BA /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + 040536351DF01B0500F189BA /* BiometricAuth.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = BiometricAuth.xcodeproj; path = ../../BiometricAuth.xcodeproj; sourceTree = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + 0405361D1DF01AD300F189BA /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 040536531DF01B6000F189BA /* BiometricAuth.framework in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 040536171DF01AD300F189BA = { + isa = PBXGroup; + children = ( + 040536351DF01B0500F189BA /* BiometricAuth.xcodeproj */, + 040536221DF01AD300F189BA /* BiometricAuthExample */, + 040536211DF01AD300F189BA /* Products */, + ); + sourceTree = ""; + }; + 040536211DF01AD300F189BA /* Products */ = { + isa = PBXGroup; + children = ( + 040536201DF01AD300F189BA /* BiometricAuthExample.app */, + ); + name = Products; + sourceTree = ""; + }; + 040536221DF01AD300F189BA /* BiometricAuthExample */ = { + isa = PBXGroup; + children = ( + 040536231DF01AD400F189BA /* AppDelegate.swift */, + 040536251DF01AD400F189BA /* ViewController.swift */, + 040536271DF01AD400F189BA /* Main.storyboard */, + 0405362A1DF01AD400F189BA /* Assets.xcassets */, + 0405362C1DF01AD400F189BA /* LaunchScreen.storyboard */, + 0405362F1DF01AD400F189BA /* Info.plist */, + ); + path = BiometricAuthExample; + sourceTree = ""; + }; + 040536361DF01B0500F189BA /* Products */ = { + isa = PBXGroup; + children = ( + 0405363D1DF01B0600F189BA /* BiometricAuth.framework */, + 0405363F1DF01B0600F189BA /* BiometricAuth.framework */, + 040536411DF01B0600F189BA /* BiometricAuth-iOS Tests.xctest */, + 040536431DF01B0600F189BA /* BiometricAuth-macOS Tests.xctest */, + ); + name = Products; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + 0405361F1DF01AD300F189BA /* BiometricAuthExample */ = { + isa = PBXNativeTarget; + buildConfigurationList = 040536321DF01AD400F189BA /* Build configuration list for PBXNativeTarget "BiometricAuthExample" */; + buildPhases = ( + 0405361C1DF01AD300F189BA /* Sources */, + 0405361D1DF01AD300F189BA /* Frameworks */, + 0405361E1DF01AD300F189BA /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = BiometricAuthExample; + productName = BiometricAuthExample; + productReference = 040536201DF01AD300F189BA /* BiometricAuthExample.app */; + productType = "com.apple.product-type.application"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + 040536181DF01AD300F189BA /* Project object */ = { + isa = PBXProject; + attributes = { + LastSwiftUpdateCheck = 0810; + LastUpgradeCheck = 0810; + ORGANIZATIONNAME = "Igor Vasilenko"; + TargetAttributes = { + 0405361F1DF01AD300F189BA = { + CreatedOnToolsVersion = 8.1; + ProvisioningStyle = Automatic; + }; + }; + }; + buildConfigurationList = 0405361B1DF01AD300F189BA /* Build configuration list for PBXProject "BiometricAuthExample" */; + compatibilityVersion = "Xcode 3.2"; + developmentRegion = English; + hasScannedForEncodings = 0; + knownRegions = ( + en, + Base, + ); + mainGroup = 040536171DF01AD300F189BA; + productRefGroup = 040536211DF01AD300F189BA /* Products */; + projectDirPath = ""; + projectReferences = ( + { + ProductGroup = 040536361DF01B0500F189BA /* Products */; + ProjectRef = 040536351DF01B0500F189BA /* BiometricAuth.xcodeproj */; + }, + ); + projectRoot = ""; + targets = ( + 0405361F1DF01AD300F189BA /* BiometricAuthExample */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXReferenceProxy section */ + 0405363D1DF01B0600F189BA /* BiometricAuth.framework */ = { + isa = PBXReferenceProxy; + fileType = wrapper.framework; + path = BiometricAuth.framework; + remoteRef = 0405363C1DF01B0600F189BA /* PBXContainerItemProxy */; + sourceTree = BUILT_PRODUCTS_DIR; + }; + 0405363F1DF01B0600F189BA /* BiometricAuth.framework */ = { + isa = PBXReferenceProxy; + fileType = wrapper.framework; + path = BiometricAuth.framework; + remoteRef = 0405363E1DF01B0600F189BA /* PBXContainerItemProxy */; + sourceTree = BUILT_PRODUCTS_DIR; + }; + 040536411DF01B0600F189BA /* BiometricAuth-iOS Tests.xctest */ = { + isa = PBXReferenceProxy; + fileType = wrapper.cfbundle; + path = "BiometricAuth-iOS Tests.xctest"; + remoteRef = 040536401DF01B0600F189BA /* PBXContainerItemProxy */; + sourceTree = BUILT_PRODUCTS_DIR; + }; + 040536431DF01B0600F189BA /* BiometricAuth-macOS Tests.xctest */ = { + isa = PBXReferenceProxy; + fileType = wrapper.cfbundle; + path = "BiometricAuth-macOS Tests.xctest"; + remoteRef = 040536421DF01B0600F189BA /* PBXContainerItemProxy */; + sourceTree = BUILT_PRODUCTS_DIR; + }; +/* End PBXReferenceProxy section */ + +/* Begin PBXResourcesBuildPhase section */ + 0405361E1DF01AD300F189BA /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 0405362E1DF01AD400F189BA /* LaunchScreen.storyboard in Resources */, + 0405362B1DF01AD400F189BA /* Assets.xcassets in Resources */, + 040536291DF01AD400F189BA /* Main.storyboard in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + 0405361C1DF01AD300F189BA /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 040536261DF01AD400F189BA /* ViewController.swift in Sources */, + 040536241DF01AD400F189BA /* AppDelegate.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin PBXVariantGroup section */ + 040536271DF01AD400F189BA /* Main.storyboard */ = { + isa = PBXVariantGroup; + children = ( + 040536281DF01AD400F189BA /* Base */, + ); + name = Main.storyboard; + sourceTree = ""; + }; + 0405362C1DF01AD400F189BA /* LaunchScreen.storyboard */ = { + isa = PBXVariantGroup; + children = ( + 0405362D1DF01AD400F189BA /* Base */, + ); + name = LaunchScreen.storyboard; + sourceTree = ""; + }; +/* End PBXVariantGroup section */ + +/* Begin XCBuildConfiguration section */ + 040536301DF01AD400F189BA /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_SUSPICIOUS_MOVES = YES; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = dwarf; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_DYNAMIC_NO_PIC = NO; + GCC_NO_COMMON_BLOCKS = YES; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 10.1; + MTL_ENABLE_DEBUG_INFO = YES; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = iphoneos; + SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; + SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + }; + name = Debug; + }; + 040536311DF01AD400F189BA /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_SUSPICIOUS_MOVES = YES; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 10.1; + MTL_ENABLE_DEBUG_INFO = NO; + SDKROOT = iphoneos; + SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; + VALIDATE_PRODUCT = YES; + }; + name = Release; + }; + 040536331DF01AD400F189BA /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + INFOPLIST_FILE = BiometricAuthExample/Info.plist; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; + PRODUCT_BUNDLE_IDENTIFIER = com.IgorVasilenko.BiometricAuthExample; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 3.0; + }; + name = Debug; + }; + 040536341DF01AD400F189BA /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + INFOPLIST_FILE = BiometricAuthExample/Info.plist; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; + PRODUCT_BUNDLE_IDENTIFIER = com.IgorVasilenko.BiometricAuthExample; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 3.0; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 0405361B1DF01AD300F189BA /* Build configuration list for PBXProject "BiometricAuthExample" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 040536301DF01AD400F189BA /* Debug */, + 040536311DF01AD400F189BA /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 040536321DF01AD400F189BA /* Build configuration list for PBXNativeTarget "BiometricAuthExample" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 040536331DF01AD400F189BA /* Debug */, + 040536341DF01AD400F189BA /* Release */, + ); + defaultConfigurationIsVisible = 0; + }; +/* End XCConfigurationList section */ + }; + rootObject = 040536181DF01AD300F189BA /* Project object */; +} diff --git a/Example/BiometricAuthExample/BiometricAuthExample.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/Example/BiometricAuthExample/BiometricAuthExample.xcodeproj/project.xcworkspace/contents.xcworkspacedata new file mode 100644 index 0000000..3cd5f18 --- /dev/null +++ b/Example/BiometricAuthExample/BiometricAuthExample.xcodeproj/project.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/Example/BiometricAuthExample/BiometricAuthExample.xcodeproj/project.xcworkspace/xcuserdata/mac.xcuserdatad/UserInterfaceState.xcuserstate b/Example/BiometricAuthExample/BiometricAuthExample.xcodeproj/project.xcworkspace/xcuserdata/mac.xcuserdatad/UserInterfaceState.xcuserstate new file mode 100644 index 0000000..80b7f0b Binary files /dev/null and b/Example/BiometricAuthExample/BiometricAuthExample.xcodeproj/project.xcworkspace/xcuserdata/mac.xcuserdatad/UserInterfaceState.xcuserstate differ diff --git a/Example/BiometricAuthExample/BiometricAuthExample.xcodeproj/xcuserdata/mac.xcuserdatad/xcschemes/BiometricAuthExample.xcscheme b/Example/BiometricAuthExample/BiometricAuthExample.xcodeproj/xcuserdata/mac.xcuserdatad/xcschemes/BiometricAuthExample.xcscheme new file mode 100644 index 0000000..3ae19aa --- /dev/null +++ b/Example/BiometricAuthExample/BiometricAuthExample.xcodeproj/xcuserdata/mac.xcuserdatad/xcschemes/BiometricAuthExample.xcscheme @@ -0,0 +1,91 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Example/BiometricAuthExample/BiometricAuthExample.xcodeproj/xcuserdata/mac.xcuserdatad/xcschemes/xcschememanagement.plist b/Example/BiometricAuthExample/BiometricAuthExample.xcodeproj/xcuserdata/mac.xcuserdatad/xcschemes/xcschememanagement.plist new file mode 100644 index 0000000..d56a0fe --- /dev/null +++ b/Example/BiometricAuthExample/BiometricAuthExample.xcodeproj/xcuserdata/mac.xcuserdatad/xcschemes/xcschememanagement.plist @@ -0,0 +1,22 @@ + + + + + SchemeUserState + + BiometricAuthExample.xcscheme + + orderHint + 0 + + + SuppressBuildableAutocreation + + 0405361F1DF01AD300F189BA + + primary + + + + + diff --git a/Example/BiometricAuthExample/BiometricAuthExample/AppDelegate.swift b/Example/BiometricAuthExample/BiometricAuthExample/AppDelegate.swift new file mode 100644 index 0000000..e518001 --- /dev/null +++ b/Example/BiometricAuthExample/BiometricAuthExample/AppDelegate.swift @@ -0,0 +1,46 @@ +// +// AppDelegate.swift +// BiometricAuthExample +// +// Created by Developer on 01/12/2016. +// Copyright © 2016 Igor Vasilenko. All rights reserved. +// + +import UIKit + +@UIApplicationMain +class AppDelegate: UIResponder, UIApplicationDelegate { + + var window: UIWindow? + + + func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { + // Override point for customization after application launch. + return true + } + + func applicationWillResignActive(_ application: UIApplication) { + // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. + // Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game. + } + + func applicationDidEnterBackground(_ application: UIApplication) { + // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. + // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. + } + + func applicationWillEnterForeground(_ application: UIApplication) { + // Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background. + } + + func applicationDidBecomeActive(_ application: UIApplication) { + // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. + } + + func applicationWillTerminate(_ application: UIApplication) { + // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. + } + + +} + diff --git a/Example/BiometricAuthExample/BiometricAuthExample/Assets.xcassets/AppIcon.appiconset/Contents.json b/Example/BiometricAuthExample/BiometricAuthExample/Assets.xcassets/AppIcon.appiconset/Contents.json new file mode 100644 index 0000000..118c98f --- /dev/null +++ b/Example/BiometricAuthExample/BiometricAuthExample/Assets.xcassets/AppIcon.appiconset/Contents.json @@ -0,0 +1,38 @@ +{ + "images" : [ + { + "idiom" : "iphone", + "size" : "29x29", + "scale" : "2x" + }, + { + "idiom" : "iphone", + "size" : "29x29", + "scale" : "3x" + }, + { + "idiom" : "iphone", + "size" : "40x40", + "scale" : "2x" + }, + { + "idiom" : "iphone", + "size" : "40x40", + "scale" : "3x" + }, + { + "idiom" : "iphone", + "size" : "60x60", + "scale" : "2x" + }, + { + "idiom" : "iphone", + "size" : "60x60", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/Example/BiometricAuthExample/BiometricAuthExample/Base.lproj/LaunchScreen.storyboard b/Example/BiometricAuthExample/BiometricAuthExample/Base.lproj/LaunchScreen.storyboard new file mode 100644 index 0000000..fdf3f97 --- /dev/null +++ b/Example/BiometricAuthExample/BiometricAuthExample/Base.lproj/LaunchScreen.storyboard @@ -0,0 +1,27 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Example/BiometricAuthExample/BiometricAuthExample/Base.lproj/Main.storyboard b/Example/BiometricAuthExample/BiometricAuthExample/Base.lproj/Main.storyboard new file mode 100644 index 0000000..273375f --- /dev/null +++ b/Example/BiometricAuthExample/BiometricAuthExample/Base.lproj/Main.storyboard @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Example/BiometricAuthExample/BiometricAuthExample/Info.plist b/Example/BiometricAuthExample/BiometricAuthExample/Info.plist new file mode 100644 index 0000000..38e98af --- /dev/null +++ b/Example/BiometricAuthExample/BiometricAuthExample/Info.plist @@ -0,0 +1,38 @@ + + + + + CFBundleDevelopmentRegion + en + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + $(PRODUCT_NAME) + CFBundlePackageType + APPL + CFBundleShortVersionString + 1.0 + CFBundleVersion + 1 + LSRequiresIPhoneOS + + UILaunchStoryboardName + LaunchScreen + UIMainStoryboardFile + Main + UIRequiredDeviceCapabilities + + armv7 + + UISupportedInterfaceOrientations + + UIInterfaceOrientationPortrait + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + + diff --git a/Example/BiometricAuthExample/BiometricAuthExample/ViewController.swift b/Example/BiometricAuthExample/BiometricAuthExample/ViewController.swift new file mode 100644 index 0000000..2c01889 --- /dev/null +++ b/Example/BiometricAuthExample/BiometricAuthExample/ViewController.swift @@ -0,0 +1,42 @@ +// +// ViewController.swift +// BiometricAuthExample +// +// Created by Developer on 01/12/2016. +// Copyright © 2016 Igor Vasilenko. All rights reserved. +// + +import UIKit +import BiometricAuth + +class ViewController: UIViewController { + + let biometricAuth = BiometricAuth(forceThrowsOnChangedDomainState: true) + + override func viewDidLoad() { + super.viewDidLoad() + + let feature = "Passcode Screen Auth" + do { + try self.biometricAuth.enableAuthentication(forFeature: feature) + } catch let error as BiometricAuthError { + print(error.localizedDescription) + } catch { + print("Something went wrong") + } + + var success = false + do { + success = try self.biometricAuth.requestAuthentication(forFeature: feature, reason: "For authentication") + } catch let error as BiometricAuthError { + print(error.localizedDescription) + } catch { + print("Something went wrong") + } + + if success { + print("Success biometric authentication") + } + } +} + diff --git a/Sources/BiometricAuth.swift b/Sources/BiometricAuth.swift index 3acdaed..bf6076d 100644 --- a/Sources/BiometricAuth.swift +++ b/Sources/BiometricAuth.swift @@ -43,10 +43,32 @@ public enum BiometricAuthError : Error { public class BiometricAuth { public let authenticationContext = LAContext() - public var forceThrowsOnChangedDomainState : Bool = true fileprivate let serviceFeaturesKey = "BiometricAuthFeatures" fileprivate let oldDomainStateDefaultsKey = "BiometricAuthOldDomainStateDefaultsKey" + fileprivate var forceThrowsOnChangedDomainState : Bool = true + + public init(forceThrowsOnChangedDomainState: Bool) { + self.forceThrowsOnChangedDomainState = forceThrowsOnChangedDomainState + } + + public func isAvailable() throws -> Bool { + + let result = self.authenticationContext.canEvaluatePolicy(LAPolicy.deviceOwnerAuthenticationWithBiometrics, error: nil) + + if let oldDomainState : Data = UserDefaults.standard.value(forKey: self.oldDomainStateDefaultsKey) as! Data? { + if let domainState = self.authenticationContext.evaluatedPolicyDomainState, domainState != oldDomainState { + UserDefaults.standard.set(nil, forKey: self.oldDomainStateDefaultsKey) + if self.forceThrowsOnChangedDomainState { + throw BiometricAuthError.domainStateChanged + } + } + } else { + UserDefaults.standard.set(self.authenticationContext.evaluatedPolicyDomainState, forKey: self.oldDomainStateDefaultsKey) + } + + return result + } public func isAuthenticationAvailable(forFeature feature: String) -> Bool { @@ -59,7 +81,7 @@ public class BiometricAuth { public func enableAuthentication(forFeature feature: String) throws -> Bool { - guard try self.isAuthenticationByBiometricAvailable() else { + guard try self.isAvailable() else { return false } @@ -67,9 +89,9 @@ public class BiometricAuth { return true } - func disableAuthentication(forFeature feature: String, reason: String) throws -> Bool { + public func disableAuthentication(forFeature feature: String, reason: String) throws -> Bool { - guard try self.isAuthenticationByBiometricAvailable() else { + guard try self.isAvailable() else { return false } @@ -81,9 +103,9 @@ public class BiometricAuth { } } - func requestAuthentication(forFeature feature: String, reason: String) throws -> Bool { + public func requestAuthentication(forFeature feature: String, reason: String) throws -> Bool { - guard try self.isAuthenticationByBiometricAvailable() else { + guard try self.isAvailable() else { return false } @@ -94,25 +116,6 @@ public class BiometricAuth { } } - // MARK: Biometrics - fileprivate func isAuthenticationByBiometricAvailable() throws -> Bool { - - let result = self.authenticationContext.canEvaluatePolicy(LAPolicy.deviceOwnerAuthenticationWithBiometrics, error: nil) - - if let oldDomainState : Data = UserDefaults.standard.value(forKey: self.oldDomainStateDefaultsKey) as! Data? { - if let domainState = self.authenticationContext.evaluatedPolicyDomainState, domainState != oldDomainState { - UserDefaults.standard.set(nil, forKey: self.oldDomainStateDefaultsKey) - if self.forceThrowsOnChangedDomainState { - throw BiometricAuthError.domainStateChanged - } - } - } else { - UserDefaults.standard.set(self.authenticationContext.evaluatedPolicyDomainState, forKey: self.oldDomainStateDefaultsKey) - } - - return result - } - fileprivate func evaluateAuthentication(withReason reason: String) throws -> Bool { var success : Bool = false