Not Receiving Push Notifications on iOS

Following the guide on Capacitor’s site for push notifications, I am unable to receive any push notification inside my iOS device.

I’ve triple checked that the Apple Push key and sandbox/production certificates are uploaded

image

I have successfully registered to the APNs and get a token value, but when I use Firebase to send a message to the token, I receive no notification.

I’ve also tried to send a message directly using this solution Apple Push Notification Using ASP.Net and I can send the message successfully, but I receive no response at all.

My app capabilities:

If you are using Firebase, then you need to make sure you are using the Firebase token and not the iOS APN token (reference).

Your AppDelegate.swift needs to look like this:

func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
  Messaging.messaging().apnsToken = deviceToken
  Messaging.messaging().token(completion: { (token, error) in
    if let error = error {
        NotificationCenter.default.post(name: .capacitorDidFailToRegisterForRemoteNotifications, object: error)
    } else if let token = token {
        NotificationCenter.default.post(name: .capacitorDidRegisterForRemoteNotifications, object: token)
    }
  })
}

func application(_ application: UIApplication, didFailToRegisterForRemoteNotificationsWithError error: Error) {
  NotificationCenter.default.post(name: .capacitorDidFailToRegisterForRemoteNotifications, object: error)
}

I’ve tried that following this guide: Capacitor - build cross platform apps with the web

Hmmm…that is the guide that I followed as well. I am using the “APNs Authentication Key” in Firebase and didn’t upload any APNs Certificates.

I am assuming you are using a physical iOS device? Push notifications don’t work/aren’t supported with the emulator.

Have you tried sending a push notification directly from the Firebase admin panel?

Correct, I have my iPhone connected to my mac.

@rvikander1 did you ever get this to work? Having the exact same issue as you

I’m following the next guide:

My problem is at the point to receive the Apple Token:

{“value”:“cbFFSBbn8URNoIwohiAqQd:APA91bELR-e3ULh1DmlHl6Kuqfzb3000uDt9OLpancGNYX…AKDWT1hecj28fNCBJjm8SHioGztEgFiZWf9U6_QAwXp6Fi-HP-SEfOpqgmQ9yJ9zSOvbm6JKJMq-rSxuTtG6ZljTgz6P”}

The problem is that this token should be hexadecimal, or it was before…

That looks right. There are two different tokens. There is the Apple APN token (which a quick Google search says is hexadecimal) and then the Firebase token. That looks like the Firebase token which is required if you are using Firebase.

1 Like

Correct! Thx for the quick answer. Thought that it was Apple again changeing the format. I was searching for the APNs ones :slightly_smiling_face:

1 Like
  1. Open your phone settings.
  2. Tap on notifications and toggle on the switch next to allow notifications if it isn’t already.
  3. Under “most recent” tap all apps.
  4. Turn the app’s notifications on or off.

APNS its work or not in IONIC-5 capacitor?

and in import { PushNotifications, Token } from ‘@capacitor/push-notifications’;
already i am getting device token then why firebase plugin all this required ?

i am using PHP for server side i am sending through APNS but i am not receiving notification in my device how this is possible please help