Apple have recently made new changes in APNs and now apple insist us to use "Token Based Authentication" instead of the traditional ways which we are using for push notification.
So does not need to worry about their expiration and this p8 certificates are for both development and production so again no need to generate 2 separate certificate for each mode.
To generate p8 just go to your developer account and select this option
"Apple Push Notification Authentication Key (Sandbox & Production)"
So, After taking a while I figured out that the old push certificate generating service also exists.
You get two options:
Apple Push Notification Authentication Key (Sandbox & Production)
Apple Push Notification service SSL (Sandbox & Production)
Those who want to achieve the old style .p12 certificate can get it from second option.
I have not used the first option yet as most of the third-party push notification service providers still need the .p12 format certificate.
1. Generate an APNs Auth Key Open the APNs Auth Key page in your Developer Center and click the + button to create a new APNs Auth Key.
In the next page, select Apple Push Notification Authentication Key (Sandbox & Production) and click Continue at the bottom of the page.
Apple will then generate a .p8 key file containing your APNs Auth Key.
Download the .p8 key file to your computer and save it for later. Also, be sure to write down the Key ID somewhere, as you'll need it later when connecting to APNs.
I was able to do this by selecting "All" located under the "Keys" header from the left column
Then I clicked the plus button in the top right corner to add a new key
Enter a name for your key and check "APNs"
Then scroll down and select Continue. You will then be brought to a screen presenting you with the option to download your .p8 now or later. In my case, I was presented with a warning that it could only be downloaded once so keep the file safe.
When you upload your p8 file in Firebase, in the box that reads App ID Prefix(required) , you should enter your team ID. You can get it from https://developer.apple.com/account/#/membership and copy/paste the Team ID as shown below.
Go to the keys section and click on the plus button (or click here):
⚠️ It is very important to select the keys section and NOT the certificate or identifiers. otherwise you will get the .cer file at last 🤷🏻♂️
Select the Apple push notification service:
⚠️ Note that since it is very powerful certificate, it is very limited and you can not have much of these. So if you already created one, you will face something like this image and you should use that file or just revoke the old one.