This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fileprivate var isDeeplinkStored:Bool { | |
get { | |
return (deepLink(forUserDefaults: storage) != nil) | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fileprivate var isLoggedIn:Bool { | |
get { | |
return (accessToken(forUserDefaults: storage) != nil) | |
} | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public var deeplinkCallbackCompleted: Bool = false { | |
didSet { | |
handleStartup() | |
} | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func handleStartup() { | |
if isCurrentUserActivity { // if the app is opened by URL it must wait the deeplink compltetion and deeplink data stored. | |
if isDeeplinkStored { | |
deeplinkAction() | |
} | |
} else if isDeeplinkStored { | |
deeplinkAction() | |
} else if isLoggedIn { | |
loggedInAction() | |
} else { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private func removeDeeplinkInfo() { | |
removeCurrentAppUserActivity() | |
removeLegacyDeepLink(fromUserDefaults: storage) | |
} | |
private func removeLegacyDeepLink(fromUserDefaults userDefaults: KeyValueStoreType) { | |
userDefaults.removeObject(forKey:"com.appStartup.deeplink") | |
} | |
private func removeCurrentAppUserActivity() { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import UIKit | |
let userActivity = NSUserActivity(activityType: "com.sirishorutsapp.wamf") | |
userActivity.isEligibleForSearch = true | |
userActivity.isElegibleForPrediction = true | |
userActivity.title = "Activity" | |
userActivity.userInfo = ["key": "Value"] | |
userActivity.suggestedInvocationPhrase = "Play Star Wars Movie" | |
let attributes = CSSearchableItemsAttributeSet(intemContentType: kUTTypeItem as String) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Once resolution is completed, perform validation on the intent and provide confirmation (optional). | |
func confirm(intent: INSendMessageIntent, completion: @escaping (INSendMessageIntentResponse) -> Void) { | |
// Verify user is authenticated and your app is ready to send a message. | |
let userActivity = NSUserActivity(activityType: NSStringFromClass(INSendMessageIntent.self)) | |
let response = INSendMessageIntentResponse(code: .ready, userActivity: userActivity) | |
completion(response) | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func application(_ application: UIApplication, continue userActivity: NSUserActivity, restorationHandler: @escaping ([Any]?) -> Void) -> Bool { | |
let type = userActivity.activityType | |
if let name = userActivity.userInfo?["name"] as? String where type == NSStringFromClass(INSendMessageIntent.self) { | |
let alert = UIAlertController(title: "User Activity", message: "Continue Activity: \(name)", preferredStyle: .alert) | |
window?.rootViewController?.present(alert, animated: true, completion: nil) | |
} | |
return true | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let handler = VNImageRequestHandler(ciImage: ciImage, orientation: orientation) | |
do { | |
try handler.perform([self.classificationRequest]) | |
} catch { | |
print("Failed to perform classification.\n\(error.localizedDescription)") | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
lazy var classificationRequest: VNCoreMLRequest = { | |
// Load the ML model through its generated class and create a Vision request for it. | |
do { | |
let model = try VNCoreMLModel(for: MobileNet().model) | |
return VNCoreMLRequest(model: model, completionHandler: self.handleClassification) | |
} catch { | |
fatalError("can't load Vision ML model: \(error)") | |
} | |
}() |