Note : its and ionic (Capacitor) project and i am using Android Studio for testing.
requestNotificationsPermissions(): void {
PushNotifications.requestPermission().then(result => {
if (result.granted) {
PushNotifications.register();
}
}).catch((err: any) => {
console.log(err);
});
}
I see you are using PushNotifications
.
It used to happen to me when I forgot to include google-services.json
in my Android project folder. If that is the case, include google-services.json
inside android/app/
folder.
See the official plugin docs: https://capacitorjs.com/docs/apis/push-notifications#android