33 lines
987 B
Swift
33 lines
987 B
Swift
|
//
|
||
|
// OpenURLIntentHandler.swift
|
||
|
// Gemini-iOS
|
||
|
//
|
||
|
// Created by Shadowfacts on 9/29/21.
|
||
|
//
|
||
|
|
||
|
import Intents
|
||
|
import UIKit
|
||
|
|
||
|
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) {
|
||
|
print("handling intent")
|
||
|
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)))
|
||
|
}
|
||
|
|
||
|
}
|