more logging
This commit is contained in:
parent
e46d983111
commit
94512211d8
2 changed files with 8 additions and 5 deletions
|
|
@ -88,7 +88,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate, ObservableObject {
|
|||
func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
|
||||
let token = deviceToken.map { data in String(format: "%02.2hhx", data) }.joined()
|
||||
Messaging.messaging().apnsToken = deviceToken
|
||||
Log.d(tag, "Registered for remote notifications. Passing APNs token to Firebase: \(token)")
|
||||
Log.d(tag, "Registered for remote notifications. Passing APNs token \(token.prefix(12))... to Firebase")
|
||||
}
|
||||
|
||||
func application(_ application: UIApplication, didFailToRegisterForRemoteNotificationsWithError error: Error) {
|
||||
|
|
@ -166,7 +166,11 @@ extension AppDelegate: UNUserNotificationCenterDelegate {
|
|||
|
||||
extension AppDelegate: MessagingDelegate {
|
||||
func messaging(_ messaging: Messaging, didReceiveRegistrationToken fcmToken: String?) {
|
||||
Log.d(tag, "Firebase token received: \(String(describing: fcmToken))")
|
||||
if let fcmToken = fcmToken, !fcmToken.isEmpty {
|
||||
Log.d(tag, "Firebase token received: \(fcmToken.prefix(12))...")
|
||||
} else {
|
||||
Log.w(tag, "Firebase token missing")
|
||||
}
|
||||
|
||||
// Subscribe to ~poll topic
|
||||
Messaging.messaging().subscribe(toTopic: pollTopic) { error in
|
||||
|
|
|
|||
|
|
@ -68,7 +68,6 @@ class NotificationService: UNNotificationServiceExtension {
|
|||
private func handlePollRequest(_ request: UNNotificationRequest, _ content: UNMutableNotificationContent, _ pollRequest: Message, _ contentHandler: @escaping (UNNotificationContent) -> Void) {
|
||||
let subscription = store?.getSubscriptions()?.first { subscription in
|
||||
// Poll requests usually target the hashed topic URL, but tolerate raw topic payloads too
|
||||
// Previously polls may have been ignored?
|
||||
subscription.urlHash() == pollRequest.topic || subscription.topic == pollRequest.topic
|
||||
}
|
||||
let baseUrl = subscription?.baseUrl
|
||||
|
|
@ -77,7 +76,7 @@ class NotificationService: UNNotificationServiceExtension {
|
|||
let subscription = subscription,
|
||||
let baseUrl = baseUrl
|
||||
else {
|
||||
Log.w(tag, "Cannot find subscription", pollRequest)
|
||||
Log.w(tag, "Cannot find subscription for poll request topic=\(pollRequest.topic), pollId=\(pollRequest.pollId ?? "<nil>")")
|
||||
contentHandler(request.content)
|
||||
return
|
||||
}
|
||||
|
|
@ -87,7 +86,7 @@ class NotificationService: UNNotificationServiceExtension {
|
|||
// The extension only needs contentHandler to be called from the async callback
|
||||
ApiService.shared.poll(subscription: subscription, messageId: pollId, user: user) { message, error in
|
||||
guard let message = message else {
|
||||
Log.w(self.tag, "Error fetching message", error)
|
||||
Log.w(self.tag, "Error fetching poll request message topic=\(pollRequest.topic), pollId=\(pollId), subscription=\(subscription.urlString())", error)
|
||||
contentHandler(request.content)
|
||||
return
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue