31 lines
941 B
Swift
31 lines
941 B
Swift
//
|
|
// 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)))
|
|
}
|
|
|
|
}
|