Rocket.Chat.ReactNative/ios/RocketChat Watch App/ExtensionDelegate.swift

35 lines
953 B
Swift

import WatchKit
import UserNotifications
final class ExtensionDelegate: NSObject, WKExtensionDelegate, UNUserNotificationCenterDelegate {
func applicationDidFinishLaunching() {
let center = UNUserNotificationCenter.current()
center.delegate = self
let replyAction = UNTextInputNotificationAction(
identifier: "REPLY_ACTION",
title: "Reply",
options: [],
textInputButtonTitle: "Reply",
textInputPlaceholder: "Message"
)
let category = UNNotificationCategory(
identifier: "MESSAGE",
actions: [replyAction],
intentIdentifiers: [],
options: []
)
UNUserNotificationCenter.current().setNotificationCategories([category])
}
func userNotificationCenter(
_ center: UNUserNotificationCenter,
didReceive response: UNNotificationResponse,
withCompletionHandler completionHandler: @escaping () -> Void
) {
print(response.notification)
}
}