Do I need APNs certificates if I'm using APNs Auth Key?

803

This is really stupid, but the issue was an incorrect Bundle ID in firebase. When I first hooked up firebase it gave me a default bundle id (com.firebase.io or something dumb like that). Later when I actually put my app on testflight i called it something else entirely. So even though I followed all the directions on the FlutterFire website for setting up apple here it didn't work bc the bundle ids didn't match.

So I had to delete the firebase app, replace the googleservicesinfo.plist file (thought it might have been sufficient to just change the bundle id field in that file (idk for sure tho)) and then replaced it in the firbase console. Had to reupload the auth key too with the "new" app.

Hope that makes sense. Comment if you have any other questions!

Share:
803
Miles Zoltak
Author by

Miles Zoltak

Updated on December 31, 2022

Comments

  • Miles Zoltak
    Miles Zoltak over 1 year

    I'm writing an cross-platform app with Flutter and Firebase. I've been working on sending notifications, and it works perfectly on android. I send messages via the firebase admin functions sdk with no problems. The request looks like this:

    const payload = {
      notification: {
        title: title,
        body: body,
      },
    }
    
    return admin.messaging().sendToDevice(tokens, payload, {
        mutableContent: true,
        contentAvailable: true,
        apnsPushType: "background",
    })
    

    But when I try to send messages to iOS devices, I get the following error from the shell:

    "error": {
        "errorInfo": {
            "code": "messaging/third-party-auth-error",
            "message": "A message targeted to an iOS device could not be sent
                       the required APNs SSL certificate was not uploaded or
                       has expired. Check the validity of your development and
                       production certificates."
        },
        "codePrefix": "messaging"
    }
    

    I was under the impression that since I'm using a APNs key generated in the apple developer console, that I would not need any sort of SSL certificate. My key is uploaded to the Firebase console and iOS devices are successfully reporting their device tokens, so I'm not sure why I can't get a message through.

    I've tried sending messages from the CLI and also from the FCM console online. Both have failed. I've also enabled Push Notifications and Background Modes with background fetch and remote notifications.

    Any help or suggestions would be appreciated.

    • AechoLiu
      AechoLiu over 2 years
      Did you generate APNS certifications as this thread said ?
    • Miles Zoltak
      Miles Zoltak over 2 years
      turns out this wasnt the issue. Frankly I'm not sure what a .pem file would even be used for. Firebase supports .p12 files now for the auth key, so maybe this was useful at one point but it might be obsolete now. Thanks for the help anyway! @AechoLiu