didReceiveRegistrationToken
ของ Firebase ดังที่แสดงด้านล่างกำลังถูกเรียกแม้ว่าผู้ใช้จะไม่ได้รับสิทธิ์ในการแจ้งเตือนแบบพุชก็ตาม ฉันต้องตรวจสอบให้แน่ใจว่าพุชโทเค็น APNS ได้รับการลงทะเบียนสำหรับการวิเคราะห์ เช่นเดียวกับการบันทึกบนเซิร์ฟเวอร์ของฉัน แต่ฟังก์ชันนี้ถูกเรียกแม้ว่าผู้ใช้จะไม่อนุญาตการพุชก็ตาม ????♂️
/**
* Requirement for Firebase push notifications.
* See documentation here: https://firebase.google.com/docs/cloud-messaging/ios/client
*/
extension AppDelegate: MessagingDelegate {
// Note: This callback is fired at each app startup and whenever a new token is generated.
func messaging(_ messaging: Messaging, didReceiveRegistrationToken fcmToken: String) {
print("Firebase registration token: \(fcmToken)")
let dataDict: [String: String] = ["token": fcmToken]
NotificationCenter.default.post(name: Notification.Name("FCMToken"), object: nil, userInfo: dataDict)
print("Getting called even if the user hasn't opted in for push notifications!")
}
}