-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathOpenChatThreadIntent.swift
More file actions
44 lines (35 loc) · 1.24 KB
/
Copy pathOpenChatThreadIntent.swift
File metadata and controls
44 lines (35 loc) · 1.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
//
// OpenChatThreadIntent.swift
// Slices Chat
//
// Visual Intelligence integration: Intent to open a chat thread
// Created by Williamson Quintero on 1/9/26.
//
import AppIntents
import Foundation
import SwiftUI
/// Intent to open a specific chat thread from Visual Intelligence search results
struct OpenChatThreadIntent: AppIntent, OpenIntent {
static var title: LocalizedStringResource = "Open Chat Thread"
static var description = IntentDescription("Opens a chat conversation in the app.")
// OpenIntent requires a 'target' parameter
@Parameter(title: "Thread")
var target: ChatThreadEntity
// OpenIntent conformance
static var openAppWhenRun: Bool = true
@MainActor
func perform() async throws -> some IntentResult {
// Post a notification to navigate to this thread
// Your app will listen for this notification and navigate accordingly
NotificationCenter.default.post(
name: .openChatThread,
object: nil,
userInfo: ["threadId": target.id.uuidString]
)
return .result()
}
}
// MARK: - Notification Extension
extension Notification.Name {
static let openChatThread = Notification.Name("openChatThread")
}