Exigences
Assurez-vous d’avoir ce qui suit avant de commencer :- Une application mobile iOS.
- Un compte Apple Developer payant avec un accès Administrateur.
- Un compte OneSignal.
- Un Mac avec Xcode 14+.
- Le Bundle ID pour votre cible d’application tel que défini dans Xcode.
- Un projet Xcode avec la capacité de notification push activée.
Générer un certificat push
Vous devez d’abord créer un fichier de demande de signature de certificat.certSigningRequest (CSR) sur macOS.
- Ouvrez Trousseau d’accès : Applications > Utilities > Keychain Access
- Lancez l’Assistant de certificat

- Saisissez vos informations
- Adresse e-mail de l’utilisateur:
[email protected] - Nom commun: Votre nom ou le nom du certificat
- Adresse e-mail de l’AC: Laissez ce champ vide
- La demande est: Sélectionnez Enregistrée sur le disque

- Cliquez sur Continuer
- Choisissez un emplacement pour enregistrer le fichier
.certSigningRequestfile - Cliquez sur Enregistrer pour terminer
.certSigningRequest prêt à être utilisé !
Activer les capacités push pour l’application
Skip if you use Automatically manage signing within Xcode.- Go to the Identifiers section of the Apple Developer portal, locate and select your app’s App ID from the list.

- Enable the Push Notifications capability by checking the box. ⚠️ Do not click “Configure” — just enable the toggle.

Créer un certificat push
Follow these steps to generate the Apple Push Notification service (APNs) SSL certificate:- Visit the Apple Certificates page.
- Click the plus (+) button to create a new certificate.
-
Under Services, select:
- Apple Push Notification service SSL (Sandbox & Production)
- Then click Continue

- Sélectionnez your App ID from the list and click Continue.

- Upload your previously generated
.certSigningRequestfile.

- Click Continue, then click Download to save the resulting
.cerfile to your computer.

.cer file to configure push notification services.
Créer une clé privée et exporter le certificat .p12
-
Double-click the downloaded
.cerfile to import it into Keychain Access. -
In Keychain Access, navigate to:
- Keychains > Login
- Category > My Certificates
- Locate the certificate named Apple Push Services.
- Right-click the certificate and select Export.

- Choisissez un emplacement pour enregistrer le fichier file, and select the file format as
.p12. When prompted, you can set a password for the.p12file (this password is required when uploading to services like OneSignal).

Télécharger le fichier .p12 vers OneSignal
- In your OneSignal dashboard, go to your app > Settings > Push & In-App > Apple iOS.
- Upload the
.p12file (and enter the password if you set one). Click Save.
You’ve successfully set up APNs authentication using a .p12 certificate in OneSignal.Your iOS app is now ready to send and receive push notifications! 🎉
Dépannage .p12
Invalid certificate format error
”Incorrect password” when uploading to OneSignal
Missing private key in exported file
Push notifications not working after upload
Expired certificate
FAQ
Do I need a provisioning profile and how to create it?
Yes, Apple requires different types of profiles for development, testing (Ad Hoc), and distribution to the App Store. In Xcode, you should be able to select Automatically manage signing to create one automatically.