Ionenkondensator, "Protokolle Anweisungen oder AlertController -Warnungen", die nicht in Firebase -BenachrichtigungshöreIOS

Programmierung für iOS
Guest
 Ionenkondensator, "Protokolle Anweisungen oder AlertController -Warnungen", die nicht in Firebase -Benachrichtigungshöre

Post by Guest »

FirebaseMessaging.addListener('notificationReceived', async (event: NotificationReceivedEvent) => {
console.log('Received foreground notification:', event);
await this.presentAlert(event.notification.body || '', event.notification.title || 'Notification');
await this.showLocalNotification({
title: event.notification.title || '',
body: event.notification.body || '',
data: event.notification.data
});
});
< /code>
Dies sind Präsentationen und ShowlocalNotification < /p>
private async showLocalNotification(notification: {
title: string;
body: string;
data?: any;
}) {
try {
await LocalNotifications.schedule({
notifications: [{
title: notification.title,
body: notification.body,
id: Math.floor(Math.random() \* 100),
extra: notification.data,
sound: 'default',
smallIcon: 'icon',
largeIcon: 'icon',
iconColor: '#58B941'
}]
});
} catch (error) {
console.error('Error showing notification:', error);
}
}
< /code>
async presentAlert(message: string, header?: string) {
const alert = await this.alertController.create({
header,
message,
buttons: [{
text: 'OK',
cssClass: 'alert-button-green', handler: () => console.log('OK clicked')
}],
cssClass: 'custom-alert'
});

await alert.present();
return alert;
}
< /code>
I am trying to get alerts of same content as of notification, notifications getting trigerred but alerts or log statement are not getting executed in Ios or android.

Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post