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>
Это препараты и шоулокалнотификация < /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.
Подробнее здесь: https://stackoverflow.com/questions/794 ... ng-trigerr
Ионовый конденсатор, «Операторы журналов или оповещения AlertController» не запускаются в слушателях уведомлений Firebas ⇐ IOS
Программируем под IOS
1738931287
Anonymous
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>
Это препараты и шоулокалнотификация < /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.
Подробнее здесь: [url]https://stackoverflow.com/questions/79420880/ionic-capacitor-logs-statements-or-alertcontroller-alerts-not-getting-trigerr[/url]
Ответить
1 сообщение
• Страница 1 из 1
Перейти
- Кемерово-IT
- ↳ Javascript
- ↳ C#
- ↳ JAVA
- ↳ Elasticsearch aggregation
- ↳ Python
- ↳ Php
- ↳ Android
- ↳ Html
- ↳ Jquery
- ↳ C++
- ↳ IOS
- ↳ CSS
- ↳ Excel
- ↳ Linux
- ↳ Apache
- ↳ MySql
- Детский мир
- Для души
- ↳ Музыкальные инструменты даром
- ↳ Печатная продукция даром
- Внешняя красота и здоровье
- ↳ Одежда и обувь для взрослых даром
- ↳ Товары для здоровья
- ↳ Физкультура и спорт
- Техника - даром!
- ↳ Автомобилистам
- ↳ Компьютерная техника
- ↳ Плиты: газовые и электрические
- ↳ Холодильники
- ↳ Стиральные машины
- ↳ Телевизоры
- ↳ Телефоны, смартфоны, плашеты
- ↳ Швейные машинки
- ↳ Прочая электроника и техника
- ↳ Фототехника
- Ремонт и интерьер
- ↳ Стройматериалы, инструмент
- ↳ Мебель и предметы интерьера даром
- ↳ Cантехника
- Другие темы
- ↳ Разное даром
- ↳ Давай меняться!
- ↳ Отдам\возьму за копеечку
- ↳ Работа и подработка в Кемерове
- ↳ Давай с тобой поговорим...
Мобильная версия