Remove hardcoded bundle identifier

This commit is contained in:
Yishi Lin 2017-06-07 17:09:37 +08:00
parent 6daa84df30
commit d86ee90eb7
2 changed files with 10 additions and 6 deletions

View file

@ -29,7 +29,9 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
SVProgressHUD.setMinimumSize(CGSize(width: 150, height: 100)) SVProgressHUD.setMinimumSize(CGSize(width: 150, height: 100))
passcodeLockPresenter.present() passcodeLockPresenter.present()
if let shortcutItem = launchOptions?[UIApplicationLaunchOptionsKey.shortcutItem] as? UIApplicationShortcutItem { if let shortcutItem = launchOptions?[UIApplicationLaunchOptionsKey.shortcutItem] as? UIApplicationShortcutItem {
if shortcutItem.type == "me.mssun.passforios.search" { var searchType = Bundle.main.bundleIdentifier!
searchType.append("search")
if shortcutItem.type == searchType {
self.perform(#selector(postSearchNotification), with: nil, afterDelay: 0.4) self.perform(#selector(postSearchNotification), with: nil, afterDelay: 0.4)
} }
} }
@ -42,7 +44,9 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
} }
func application(_ application: UIApplication, performActionFor shortcutItem: UIApplicationShortcutItem, completionHandler: @escaping (Bool) -> Void) { func application(_ application: UIApplication, performActionFor shortcutItem: UIApplicationShortcutItem, completionHandler: @escaping (Bool) -> Void) {
if shortcutItem.type == "me.mssun.passforios.search" { var searchType = Bundle.main.bundleIdentifier!
searchType.append("search")
if shortcutItem.type == searchType {
let tabBarController = self.window!.rootViewController as! UITabBarController let tabBarController = self.window!.rootViewController as! UITabBarController
tabBarController.selectedIndex = 0 tabBarController.selectedIndex = 0
let navigationController = tabBarController.selectedViewController as! UINavigationController let navigationController = tabBarController.selectedViewController as! UINavigationController

View file

@ -72,7 +72,7 @@ class Utils {
} }
static func getPasswordFromKeychain(name: String) -> String? { static func getPasswordFromKeychain(name: String) -> String? {
let keychain = Keychain(service: "me.mssun.passforios") let keychain = Keychain(service: Bundle.main.bundleIdentifier!)
do { do {
return try keychain.getString(name) return try keychain.getString(name)
} catch { } catch {
@ -82,11 +82,11 @@ class Utils {
} }
static func addPasswordToKeychain(name: String, password: String?) { static func addPasswordToKeychain(name: String, password: String?) {
let keychain = Keychain(service: "me.mssun.passforios") let keychain = Keychain(service: Bundle.main.bundleIdentifier!)
keychain[name] = password keychain[name] = password
} }
static func removeKeychain(name: String) { static func removeKeychain(name: String) {
let keychain = Keychain(service: "me.mssun.passforios") let keychain = Keychain(service: Bundle.main.bundleIdentifier!)
do { do {
try keychain.remove(name) try keychain.remove(name)
} catch { } catch {
@ -94,7 +94,7 @@ class Utils {
} }
} }
static func removeAllKeychain() { static func removeAllKeychain() {
let keychain = Keychain(service: "me.mssun.passforios") let keychain = Keychain(service: Bundle.main.bundleIdentifier!)
do { do {
try keychain.removeAll() try keychain.removeAll()
} catch { } catch {