Help with Apple Push Notifications

I am working on a direct / instant messaging component which needs to send Push Notifications directly from the Sender to the Receiver. I have this working great for Android using HTTP Request, but Im not sure how to configure this for APNS (Apple Push Notification Service).

In the documentation it describes this cURL format:

curl --location --request POST ‘https://api.push.apple.com/3/device/
–header 'apns-topic: ’
–http2
–cert ‘<route to my .pem file>’
–data-raw ’ { “aps” : { “alert” : “Here’s Johnny!” } }

If I build this out in an HTTP POST Request, where do I put the ‘cert’ part described above? Is this set in the Header? I have the .pem file i need(and the path to get to it), I just dont know enough where in the HTTP Request this would be defined at.

Can @Harri_Sarsa or anyone who is currently doing APNs help me? Thanks.

Just keeping this bumped

Hi!

The documentation is a bit sparse, but the sample code here refers to a server side setup one could impement with say NodeJS.
The APNS architecture looks broadly like this:

The “server” part should be implemented in a backend. This is because even if you could include the certificate file in your app, this would mean the certificate is included in the app bundle and distributed to everyone who downloads your app.

For example for NodeJS there is a rather popular npm library for handling Apple push notifications this https://github.com/node-apn/node-apn

I wouldnt be including the cert inside the app - just the path to it. I have the actual .pem file stored on Firebase storage, so all I would be doing is defining “cert”: < .pem file path > in the HTTP request somewhere. Im just not sure where exactly. I was assuming that maybe this would be done in the header.

This would actually all be so much easier if you provided Firebase support for APNS, so we could just include the GoogleService-info.plist file they provide, similar to how you handle it with Android.

Just consider that if your cert file is accessible on the web, then it is possible for someone to download it and then they can theoretically use it to send push notifications with your app’s identity.

I agree the push notifications should be more straightforward, but there is some complexity in the underlying architecture which is not dependent on us alone :slight_smile:

@JOHN_WORSHAM , Good day, How do you route to your .pem file. I have the .pem file, but I’m not sure how I route to it

This is an old thread that was before Appgyver opened up a way us to use Firebase for IOS APNS support, so I chose not to use a .pem file (certificate) for IOS. I use an APNs Auth Key instead. In Firebase you set that up in the Project Settings under Cloud Messaging tab:

Thank you so much for the reply, but I’m using this method, not the firebase method:

Do you remember how to route to .pem file. I use Xano as a backend if that’s important.

No i never figured it out.

1 Like

Thank you very much.

Sorry for so many questions, but I am trying to use firebase now, but I don’t see an advanced tab in iOS to add Googleservice-info.plist. Is it not necessary for iOS? I have notification functions installed on AppGyver

You need to use the Get Device Token flow function to trigger the advanced tab

1 Like

Thanks alot, I had the “get device token (beta)” function, but not the “get firebase token.” It worked now that I installed that one. Should I use the firebase token instead of the device token or is anyone fine?

You need to use the Firebase token if youre using Firebase. But verify its returning a token and not null. It was broken for a while. I found a workaround i posted in another thread if its still broke.