Gemini/Gemini-iOS/Intents/OpenURLIntentHandler.swift

31 lines
941 B
Swift
Raw Normal View History

2021-09-30 15:06:03 +00:00
//
// OpenURLIntentHandler.swift
// Gemini-iOS
//
// Created by Shadowfacts on 9/29/21.
//
import Intents
class OpenURLIntentHandler: NSObject, OpenURLIntentHandling {
func resolveUrl(for intent: OpenURLIntent, with completion: @escaping (INURLResolutionResult) -> Void) {
guard let url = intent.url,
url.scheme?.lowercased() == "gemini" else {
completion(.unsupported())
return
}
completion(.success(with: url))
}
func handle(intent: OpenURLIntent, completion: @escaping (OpenURLIntentResponse) -> Void) {
guard let url = intent.url,
url.scheme?.lowercased() == "gemini" else {
completion(OpenURLIntentResponse(code: .failure, userActivity: nil))
return
}
completion(OpenURLIntentResponse(code: .continueInApp, userActivity: NSUserActivity(geminiURL: url)))
}
}