A push notification comes from your server, through Firebase Cloud Messaging 1 (FCM) on Android and Apple's push service on iOS. The plugin registers: it asks permission (POST_NOTIFICATIONS on Android 13 and later) and obtains the device token your server needs:
export async function push() {
let perm = await PushNotifications.checkPermissions();
if (perm.receive === 'prompt') perm = await PushNotifications.requestPermissions();
if (perm.receive !== 'granted') return show('push', perm);
await PushNotifications.register(); // the token arrives in the 'registration' event
return show('push', perm);
}watchPlugins() listens for registration (the token, which you send to your server) and registrationError. Two more events carry payloads: pushNotificationReceived fires when a message arrives while the app is in the foreground, and pushNotificationActionPerformed when the user taps a notification, with the message's data fields in notification.data. The Android side is a FirebaseMessagingService built on firebase-messaging 25.0.1, so FCM must be configured before register(). Capacitor 243,123 's app/build.gradle applies the Google Services plugin only if google-services.json exists, and logs the miss at info level, invisible in a normal build. BookNest had no such file yet, and tapping Push took the whole app down:
adb -s emulator-5558 logcat -d -v tag | grep -E "FirebaseApp is not|FATAL"E/Capacitor: Caused by: java.lang.IllegalStateException: Default FirebaseApp is not
initialized in this process com.example.booknest. Make sure to call
FirebaseApp.initializeApp(Context) first.
E/AndroidRuntime: FATAL EXCEPTION: CapacitorPlugins
E/AndroidRuntime: Caused by: java.lang.IllegalStateException: Default FirebaseApp is not
initialized in this process com.example.booknest. Make sure to call
FirebaseApp.initializeApp(Context) first.The exception escaped on the plugin thread of Plugin Registry, so no registrationError arrived: the process died. FCM Setup adds google-services.json from a real Firebase 1 project and sends a test message. On iOS (not run here) you enable the Push Notifications capability in Xcode 10 and upload an APNs key to Firebase or your push provider.