前提
swiftで通話アプリを作っています。
awsでユーザーごとのデバイストークンを管理しています。
実現したいこと
発生している問題
apnsの仕組みとしては、デバイストークンを指定すればその対応したデバイスに通知が送信されるものと思っているのですが、その指定方法がわからず困っています。
調べても出てこないので自分の勘違いなのかとも思っているのですが、であればトークンは何に使うのかと疑問に思っています。
ソースコード
以下のように作成しているのですが、この中にトークンを指定できるようなものがあると考えておりましたが、そう言った記事は見つからなかったのでやり方を見直す必要があるのかと思っています。
swift
func sendNotification(identifier: String, title: String, body: String, sound: String?, dateComponents: DateComponents, repeats: Bool = false) { let content = UNMutableNotificationContent() content.title = title content.body = body if let sound = sound { content.sound = UNNotificationSound.init(named: UNNotificationSoundName(rawValue: sound)) } let trigger = UNCalendarNotificationTrigger.init( dateMatching: dateComponents, repeats: repeats) let request = UNNotificationRequest( identifier: identifier, content: content, trigger: trigger) UNUserNotificationCenter.current().add(request) { error in if let error = error { print(error) } }}

0 コメント