Push Notification Tutorial for IOS + Firebase Cloud Messaging

Hi all,

At the beginning, thank you all for great support I had experience from this forum.
Recently I had an issue with push notifications not working on IPhone and I was searching here and on external services for the solution. Finally I had a working solution and want to share with you the steps how I achieved that. Hope it will be useful for others. The example enables the push notification on existing app I developed.

First key aspect for push notification
While you are going to test: push notification is only working on the standalone application - it means that you will not see any notification using appgyver preview app.

Ok let’s start:

  1. In Appgyver add as on the picture - in my case I added that as a button action. To see the device token I use Alert, however I recommend to use different outputs to easy copy&paste the device token for test purposes.

  1. Now as stated in official Appgyver guideline Push notifications - Google Firebase go tu Sign In - Apple → Certificates:

a. Enable push notification on your App ID.


Mark the checkbox “Push Notification” and add the required certificate by clicking “Edit”


image

Once you finish, the certificate will be visible in the mian view

Download your push notification certificate file. This certificate will be later used in Firebase Cloud messaging as APNs Certificates and can be converted to *.pem once you would like to use curl.

Important: check identifier name, it needs to be equal/explicit to the Bundle ID on Firebase Project settings->General and in Project settings->Project settings->Cloud Messaging. The identifier will be later used in appgyver build service configuration.


b. Now you need to create your new Distribution Certificates

Download your distribution certificate file.

c. Then create new Provisioning Profiles

Download your distribution provisioning file.

d. In the last step we need to generate “Key” *.p8 file, if I understood correctly for Firebase <-> Push Service communication. Later we will add this key to Firebase as APNs Authentication Key.

Now short check. You should see in your profile view the “Push Notification” enabled.
Again please check Bundle ID title.

  1. Now we open Appgyver Build service and configure the build with a recently generated distribution certificate and provisioning file. Remember to add the same Bundle identifier.

  2. Last step before we can start testing - move to the Firebase Project settings->Cloud Messaging and add key file (*.p8) and push notification certificate.

Once the app is delivered and you install it on your mobile you can start the test.

Hope it’s useful. If I missed something or was not clear - please let me know.

1 Like

Hello friend, so, in the part of importing the APN certificate to Firebase, it only allows p12 extension, however, I can only generate the certificate in .pfx or .cer format

It would be good to understand better about this part of certificate extensions, because for me, thanks to your fantastic tutorials, I’m almost able to configure Push Notifications

Hi,

.cer file will do the job. See this tutorial starting from point 6 till 9

In this case, I am generating all the certificates via Windows, following this tutorial:

https://mzansibytes.com/2021/08/28/create-apple-developer-certificates-on-windows/

However, Apple’s developer account did not refuse the .pfx Format of the certificates, however, Firebase is refusing the same, it says only accept .p12

ok understood and yes Firebase requires .p12. I never generated the .p12 from windows, but I think there are some ways to do so. Maybe using openssl like example under link (but I haven’t checked that)

In this case, I just need to know where I can find the private key file, since, when I download the Apple certificate, I only receive one file, and when I convert it with Open SSL I only transform it from .cer to .cer before. pem

Could this private key file that it asks to convert .cer to .p12 be the .pfx that I generate when exporting the apple certificate?

I managed to solve this .p12 extensions incompatibility issue thanks to this tutorial:

However, when uploading the APN file to Firebase, unfortunately I am getting the following error:
image

From what I’ve been reading, the Bundle ID can only be changed if you create a new APP (Project) is that it?

Identificador de pacote de alteração de um Exi… | Fóruns de Desenvolvedores da Apple

Hi, yes both Bundle ID’s need to identical.
App Store Connect → App information → General Information - > Bundle ID
should be the same to
Firebase → Project settings → General → Your Apps → Apple apps → Bundle ID

You can’t changed the existing app Bundle ID in App Store, however you can add Apple app in Firebase with the same Bundle ID as in App Store. Looks like it is working for me, but still need to test fully the final build.

Yes, I solved this problem by creating a new App in Firebase.

I managed to do 100% of your tutorial, however, the HTTP Request part for sending notifications remains…

I’m racking my brain to figure out how to do it

As far as I know, it’s not possible to send and receive notifications with the app open, right?

However, what I want is to send a certain notification after the click of a button in my app, you know?

How to do this ?

does anybody know where I can find a well-written, step by step guide on how exactly to make push notifications work for an iOS app?