The type of WKUser
to display upon receipt of the specified notification category.
init(controller:category:)
Availability 有効性
- watchOS 7.0+
Technology
- Swift
UI
Declaration 宣言
init(controller: Controller.Type = Controller.self, category: String
)
Parameters パラメータ
controller
Notification Hosting Controller category
The category of notifications to listen for.
Discussion 議論
Use a watch notification instance to add support for one or more Apple Watch notification scenes that appear on receipt of the local or remote notification categories you specify. The example below, adds two notification scenes to the app declaration:
@main
struct PopQuizApp : App {
var body: some Scene {
MainScene {
RootView()
}
WKNotificationScene(
controller: QuizTimeController.self,
category: "com.example.quiztime"
)
WKNotificationScene(
controller: QuizResultsController.self,
category: "com.example.results"
)
}
}
Each WKNotification
declaration references a WKUser
and a category string that you provide. The hosting controller displays your notification’s content view upon receipt of a local or a PushKit notification. The category string you specify corresponds to the category name in the notification’s dictionary and describes a specific notification that contains the content displayed by the notification view.