← Plugins / Push Notifications
Zero-config push notifications for Apache Cordova. Firebase Cloud Messaging on Android, native APNs on iOS — and you only write JavaScript. Most push plugins make you hand-edit Gradle files, AppDelegates, manifests and entitlements; this one does the boring wiring for you.
| Task | Other plugins | This plugin |
|---|---|---|
Apply the Firebase google-services Gradle plugin | manual | ✅ automatic |
Copy google-services.json into the build | manual | ✅ automatic (build hook) |
Request POST_NOTIFICATIONS (Android 13+) | manual | ✅ automatic |
| Add the iOS Push Notifications entitlement | manual (Xcode) | ✅ automatic |
Add the remote-notification background mode | manual | ✅ automatic |
| TypeScript types | rarely | ✅ included |
The only thing you provide is your Firebase / Apple credentials. Everything else is one register() call.
cordova plugin add cordova-plugin-push-notification-v2026
Requires cordova-android >= 14 (tested on 15) and cordova-ios >= 7 (tested on 8.1).
id in config.xml).google-services.json.config.xml. The plugin's build hook copies it into platforms/android/app/ on every build and auto-applies the Firebase Gradle plugin — no Gradle editing required.cordova run androidOther accepted locations: res/, www/, or a google-services/ folder. Keep google-services.json out of version control.
The plugin adds the Push Notifications capability, the aps-environment entitlement and the remote-notification background mode automatically. You only need a signing identity:
cordova platform add ios then open platforms/ios/*.xcworkspace.cordova run ios --device.document.addEventListener("deviceready", async () => {
const push = cordova.plugins.pushNotification;
// Fires for every incoming notification (foreground, background-tap, etc.)
push.on("notification", (n) => {
console.log("Notification:", n.title, n.body, n.data);
if (n.tap) {
// The user tapped the notification — navigate accordingly.
}
});
push.on("error", (e) => console.error("Push error:", e.message));
// Requests permission, registers with FCM/APNs and returns the token.
const { token, platform, registrationType } = await push.register();
console.log(`Registered on ${platform} (${registrationType}):`, token);
// Send `token` to your backend to target this device.
});
All methods return a Promise. The module is clobbered onto cordova.plugins.pushNotification.
register(options?) → Promise<RegistrationResult>Requests permission, registers with FCM/APNs, starts event delivery and resolves with the device token.
| Result field | Type | Description |
|---|---|---|
token | String | The device push token. |
platform | 'android' | 'ios' | The platform that registered. |
registrationType | 'FCM' | 'APNS' | Which service issued the token. |
on() / once() / off()| Event | Payload | When |
|---|---|---|
registration | { token, platform, registrationType } | Token obtained / changed. |
notification | see below | A push arrives or is tapped. |
tokenRefresh | { token } | The FCM token rotated. |
error | { message, code? } | Something failed. |
The notification payload includes title, body, data (your custom key/values),
foreground, tap, and on iOS badge, sound and messageId.
| Method | Platform | Description |
|---|---|---|
getToken() | both | Resolve the current device token. |
subscribe(topic) | Android | Join an FCM topic (no-op on iOS). |
unsubscribe(topic) | Android | Leave an FCM topic. |
unregister() | both | Stop notifications and delete the token. |
setBadge(n) / getBadge() | iOS | Manage the app icon badge. |
clearNotifications() | both | Remove delivered notifications. |
hasPermission() | both | true if notifications are authorised. |
requestPermission() | both | Explicitly prompt for permission. |
Android / cross-platform via FCM HTTP v1:
curl -X POST \
https://fcm.googleapis.com/v1/projects/YOUR_PROJECT_ID/messages:send \
-H "Authorization: Bearer $ACCESS_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"message": {
"token": "DEVICE_FCM_TOKEN",
"notification": { "title": "Hello 👋", "body": "Sent via FCM v1" },
"data": { "screen": "inbox", "id": "42" }
}
}'
Use a data payload to receive custom key/values in the notification event's data field.
On iOS, keys outside the aps object are delivered the same way.
| Component | Version |
|---|---|
| Cordova CLI | >= 12 |
| cordova-android | >= 14 (tested 15) |
| cordova-ios | >= 7 (tested 8.1) |
| Android min SDK | 24 |
| iOS deployment target | 13.0 |
| Firebase Messaging | 24.x |