4

I'm having a problem with getting FCM APNs to work in distribution (Ad Hoc). Everything works perfectly in development, but when I tried to build an Ad Hoc for testing, it doesn't work. Here is what I did:

1- I implemented FCM into my app following this guide: https://firebase.google.com/docs/cloud-messaging/ios/client. I confirmed it's working with development in all three states (background, foreground, killed).

2- I created a p8 key for APN and uploaded it successfully to Firebase.

3- I created an Apple Distribution certificate with a provisioning profile for Ad Hoc.

4- I added "Push Notifications" capability in Xcode

5- I built the Ad Hoc distribution.

6- I'm getting the notification token every time the app launches, so I'm sending my notifications to the right tokens.

What I tried:

1- Re-created all my certificates and provisioning files and rebuilt the app.

2- I tried sending test messages from my Firebase console, and nothing was delivered

3- I tried to make the app print a label whenever it gets a notification, but nothing is happening.

Here is my JSON payload:

{"aps" : {
    "alert" : {
      "title" : "Hello",
      "body" : "World"
    },
    "content-available" : 1,
    "sound" : "default",
     "badge": 1
  },
  "person" : "John"}

As I said, everything works fine during development. Am I missing something? Is there an extra step I need to do for distribution?

Both development and distribution devices run on iOS 13, and I'm using Xcode 11.5

UPDATE:

After going through my Apple Developer account, I noticed this: enter image description here

It doesn't list Ad Hoc under distribution support, does that mean APNs don't work with Ad Hoc?

Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807
Hani
  • 105
  • 2
  • 2
  • 11
  • Make sure to use the APNS certificate for production when dealing with Ad-hoc. – Hossam Sherif Jun 23 '20 at 02:21
  • I'm using the .p8 auth key which should cover for both development and distribution certificates. In any case, I tried using the .p12 certificates instead and I made sure to use the distribution one, but no success – Hani Jun 23 '20 at 02:42
  • @Hani how you resolved this problem – nivritgupta Sep 02 '20 at 17:05
  • @nivritgupta sorry I just saw your message. Make sure the "APN environment" key is set to "production" in the production entitlements file. It worked for me after I did that. – Hani Sep 19 '20 at 03:10

0 Answers0