I have create a usePushNotification hook in my Ionic/React app following the official documentation. When I generate a token, and paste that token in to Firebase Cloud Messaging to send a test notification, the notification arrives on my test phone no problem. When I create a campaign and send a notification scheduled for now, it never arrives. What am I doing wrong?
I have the google-services.json file in the Android app
import { useEffect } from 'react';
import { PushNotifications } from '@capacitor/push-notifications';
const usePushNotifications = () => {
useEffect(() => {
(async () => {
let permStatus = await PushNotifications.checkPermissions();
if (permStatus.receive === 'prompt') {
permStatus = await PushNotifications.requestPermissions();
}
if (permStatus.receive !== 'granted') {
throw new Error('User denied permissions!');
}
await PushNotifications.register();
if (permStatus.receive === 'granted') {
await PushNotifications.addListener('registration', (token) => {
console.info('Registration token: ', token.value);
});
await PushNotifications.addListener('registrationError', (err) => {
console.error('Registration error: ', err.error);
});
await PushNotifications.addListener(
'pushNotificationReceived',
(notification) => {
console.log('Push notification received: ', notification);
}
);
await PushNotifications.addListener(
'pushNotificationActionPerformed',
(notification) => {
console.log(
'Push notification action performed',
notification.actionId,
notification.inputValue
);
}
);
}
})();
}, []);
};
export default usePushNotifications;