firebase-ios-sdk: Push Notifications Not Working for Catalyst

I am unable to get push notifications working for Catalyst. My current setup works correctly for iOS but shows an authentication error for Catalyst.

Code Excerpts

AppDelegate
      FirebaseApp.configure(options: options)
        Messaging.messaging().delegate = self
        UNUserNotificationCenter.current().delegate = self

      func registerForPushNotifications(completionHandler : @escaping () -> Void) {
        UNUserNotificationCenter.current().getNotificationSettings() { settings in
            guard settings.authorizationStatus == .authorized else { return }
            
            DispatchQueue.main.async {
                UIApplication.shared.registerForRemoteNotifications()
                iOSNotificationService.shared.getPendingNotifications()
                completionHandler()
            }
        }
    }


func requestPushNotificationAuthorization(completionHandler: @escaping ()-> Void ) {
        let authOptions : UNAuthorizationOptions = [.alert, .badge, .sound]
        UNUserNotificationCenter.current().requestAuthorization(options: authOptions) { (granted, error) in
            guard granted else {
                if let errorString = error?.localizedDescription {
                    os_log("Push notification authorization denied : %{public}s", errorString )
                }
                
                return
            }
            self.registerForPushNotifications() {
               // 
               //
            }
            
            completionHandler()
        }
    }

**Error ** { Error: Auth error from APNS or Web Push Service Raw server response: “{“error”:{“code”:401,“message”:“Auth error from APNS or Web Push Service”,“status”:“UNAUTHENTICATED”,“details”:[{”@type":“type.googleapis.com/google.firebase.fcm.v1.FcmError”,“errorCode”:“THIRD_PARTY_AUTH_ERROR”}]}}" at FirebaseMessagingError.FirebaseError [as constructor] (/srv/node_modules/firebase-admin/lib/utils/error.js:42:28) at FirebaseMessagingError.PrefixedFirebaseError [as constructor] (/srv/node_modules/firebase-admin/lib/utils/error.js:88:28) at new FirebaseMessagingError (/srv/node_modules/firebase-admin/lib/utils/error.js:253:16) at Function.FirebaseMessagingError.fromServerError (/srv/node_modules/firebase-admin/lib/utils/error.js:283:16) at Object.createFirebaseError (/srv/node_modules/firebase-admin/lib/messaging/messaging-errors.js:34:47) at /srv/node_modules/firebase-admin/lib/messaging/messaging-api-request.js:76:42 at <anonymous> at process._tickDomainCallback (internal/process/next_tick.js:229:7) errorInfo: { code: ‘messaging/unknown-error’, message: ‘Auth error from APNS or Web Push Service Raw server response: “{“error”:{“code”:401,“message”:“Auth error from APNS or Web Push Service”,“status”:“UNAUTHENTICATED”,“details”:[{”@type":“type.googleapis.com/google.firebase.fcm.v1.FcmError”,“errorCode”:“THIRD_PARTY_AUTH_ERROR”}]}}"’ }, codePrefix: ‘messaging’ }

Configuration

  • Using APNS Key
  • Happens with both Xcode 11.3.1. & 11.4 Beta
  • Mac OS Catalina 10.15.3
  • podfile.lock excerpts
    • Firebase/Functions (6.18.0):
      • Firebase/CoreOnly
      • FirebaseFunctions (~> 2.5.1)
    • Firebase/Messaging (6.18.0):
      • Firebase/CoreOnly
      • FirebaseMessaging (~> 4.3.0)
    • FirebaseCore (6.6.3): - FirebaseCoreDiagnostics (~> 1.2) - FirebaseCoreDiagnosticsInterop (~> 1.2) - GoogleUtilities/Environment (~> 6.5) - GoogleUtilities/Logger (~> 6.5)

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 35 (21 by maintainers)

Most upvoted comments

Looking at the bundleID issue now, also related to #5126

I see so number 3 is not an issue, we are working on issues 1 and 2.

I see the following errors, not sure if they are related:

[User Defaults] Couldn’t write values for keys ( ApplicationAccessibilityEnabled ) in CFPrefsPlistSource<0x600002c21780> (Domain: com.apple.Accessibility, User: kCFPreferencesCurrentUser, ByHost: No, Container: (null), Contents Need Refresh: Yes): setting preferences outside an application’s container requires user-preference-write or file-write-data sandbox access

[User Defaults] Couldn’t write values for keys ( FullKeyboardAccessFocusRingEnabled ) in CFPrefsPlistSource<0x600002c21780> (Domain: com.apple.Accessibility, User: kCFPreferencesCurrentUser, ByHost: No, Container: (null), Contents Need Refresh: No): setting preferences outside an application’s container requires user-preference-write or file-write-data sandbox access

[User Defaults] Couldn’t write values for keys ( ApplicationAccessibilityEnabled ) in CFPrefsPlistSource<0x600002c21780> (Domain: com.apple.Accessibility, User: kCFPreferencesCurrentUser, ByHost: No, Container: (null), Contents Need Refresh: No): setting preferences outside an application’s container requires user-preference-write or file-write-data sandbox access

[Firebase/Core][I-COR000008] The project’s Bundle ID is inconsistent with either the Bundle ID in ‘GoogleService-Info.plist’, or the Bundle ID in the options if you are using a customized options. To ensure that everything can be configured correctly, you may need to make the Bundle IDs consistent. To continue with this plist file, you may change your app’s bundle identifier to ‘com.myApp.bundleIF’. Or you can download a new configuration file that matches your bundle identifier from https://console.firebase.google.com/ and replace the current one.

Couldn’t read values in CFPrefsPlistSource<0x600002c51780> (Domain: group.myApp.bundleID, User: kCFPreferencesAnyUser, ByHost: Yes, Container: (null), Contents Need Refresh: Yes): Using kCFPreferencesAnyUser with a container is only allowed for System Containers, detaching from cfprefsd

[Firebase/InstanceID][I-IID003014] Error while reading embedded mobileprovision Error Domain=NSCocoaErrorDomain Code=260 “The file “embedded.mobileprovision” couldn’t be opened because there is no such file.” UserInfo={NSFilePath=/…/Developer/Xcode/DerivedData/MyApp-bfnufiqtzeksrgetsiycpfkfzngu/Build/Products/Beta-maccatalyst/MyApp.app/embedded.mobileprovision, NSUnderlyingError=0x600000db5fb0 {Error Domain=NSPOSIXErrorDomain Code=2 “No such file or directory”}}