Passer au contenu principal
Pour envoyer des notifications push aux applications iOS, une connexion authentifiée aux services de notification push Apple (APNs) est requise. Vous pouvez vous authentifier en utilisant une méthode basée sur un jeton (clé .p8) ou basée sur un certificat (fichier .p12) — mais une seule est nécessaire.
Les certificats .p12 expirent après un an. Si vous ne voulez pas gérer le renouvellement de ce certificat, vous pouvez créer une clé .p8 à la place, qui n’expire pas.
Ce guide vous guidera à travers la configuration d’un certificat (.p12). Ceci n’est pas recommandé car vous devez le renouveler annuellement. Cela inclut la connexion à votre compte Apple Developer pour générer le nouveau certificat et le télécharger sur votre tableau de bord OneSignal chaque année.

Exigences

Assurez-vous d’avoir ce qui suit avant de commencer :

Générer un certificat push

Vous devez d’abord créer un fichier de demande de signature de certificat .certSigningRequest (CSR) sur macOS.
  1. Ouvrez Trousseau d’accès : Applications > Utilities > Keychain Access
  2. Lancez l’Assistant de certificat
Dans la barre de menu, cliquez sur : Trousseau d’accès > Assistant de certificat > Demander un certificat à une autorité de certification…

Trousseau d'accès Mac

  1. Saisissez vos informations
Remplissez les champs requis :
  • 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

Fenêtre Assistant de certificat

  1. Cliquez sur Continuer
  • Choisissez un emplacement pour enregistrer le fichier .certSigningRequest file
  • Cliquez sur Enregistrer pour terminer
Vous avez maintenant votre fichier .certSigningRequest prêt à être utilisé !

Activer les capacités push pour l’application

Skip if you use Automatically manage signing within Xcode.
  1. Go to the Identifiers section of the Apple Developer portal, locate and select your app’s App ID from the list.
  1. 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:
  1. Visit the Apple Certificates page.
  2. Click the plus (+) button to create a new certificate.
  3. Under Services, select:
    • Apple Push Notification service SSL (Sandbox & Production)
    • Then click Continue
  4. Sélectionnez your App ID from the list and click Continue.
  1. Upload your previously generated .certSigningRequest file.
  1. Click Continue, then click Download to save the resulting .cer file to your computer.
You’ll use this .cer file to configure push notification services.

Créer une clé privée et exporter le certificat .p12

  1. Double-click the downloaded .cer file to import it into Keychain Access.
  2. In Keychain Access, navigate to:
    • Keychains > Login
    • Category > My Certificates
  3. Locate the certificate named Apple Push Services.
  4. Right-click the certificate and select Export.

Export will generate a .p12 file at your desired file location

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

Télécharger le fichier .p12 vers OneSignal

  1. In your OneSignal dashboard, go to your app > Settings > Push & In-App > Apple iOS.
  2. Upload the .p12 file (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

Cause

The uploaded file is not in .p12 format.

Fix

Ensure you export the certificate from Keychain Access as .p12 (not .cer or .pem).

”Incorrect password” when uploading to OneSignal

Cause

Password was entered incorrectly or not set.

Fix

  • Try exporting again and set a new password.
  • Ensure no extra spaces are added when pasting.
  • If using Provisionator, the password is shown in the UI.

Missing private key in exported file

Cause

Certificate was imported but not paired with a private key.

Fix

  • Make sure you generate the CSR from Keychain Access on the same machine.
  • After downloading the .cer file, double-click to install and check if the key appears under My Certificates.

Push notifications not working after upload

Cause

Incorrect App ID, or Provisioning Profile missing capabilities.

Fix

  • Confirm the .p12 matches the App ID used in the app.
  • In Apple Developer Portal, ensure the App ID has Push Notifications enabled.
  • Make sure the Provisioning Profile includes Push.

Expired certificate

Cause

.p12 certificate is no longer valid.

Fix

  • Go to Apple Developer > Certificates and check expiry.
  • Revoke the old certificate and create a new one.

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.
Otherwise, see Apple’s docs on provisioning profiles for details.