Уведомление не показывает Android 15Android

Форум для тех, кто программирует под Android
Ответить
Anonymous
 Уведомление не показывает Android 15

Сообщение Anonymous »

Я использую библиотеку notifee для реагирования на этот код

Код: Выделить всё

const createTriggerNotification = async () => {
await checkApplicationPermission();

const date = new Date(Date.now());

date.setMinutes(date.getMinutes() + 1);

console.log(date.getTime());

await createNotification(date);
};

export const checkApplicationPermission = async () => {
if (Platform.OS === 'android') {
try
{
await PermissionsAndroid.request(
PermissionsAndroid.PERMISSIONS.POST_NOTIFICATIONS,
);
} catch (error) {
console.log(error)
}
}
};

const createTrigger  = (date : Date) =>
{
const trigger: TimestampTrigger = {
type: TriggerType.TIMESTAMP,
timestamp: date.getTime(),
alarmManager: {
allowWhileIdle: true,
},
};

return trigger
}

const createChannel = async () => {
await notifee.createChannel({
id: 'goc-channel',
name: 'goc-channel',
lights: false,
vibration: true,
badge: true,
importance: AndroidImportance.HIGH,
})
};

export const createNotification = async (date : Date) => {
console.log(date.toLocaleString())
try
{
await createChannel();
await notifee.createTriggerNotification(
{
title: 'Meeting with Jane',
body: 'Today at 11:20am',
android: {
importance: AndroidImportance.HIGH,
badgeIconType : AndroidBadgeIconType.SMALL,
smallIcon: 'ic_notification',
channelId: 'goc-channel',
pressAction: {
id: "default",
},
},
},
createTrigger(date),
);
}
catch (e)
{
console.log(e)
}

}
На устройствах с Android 13 и 14 уведомление отображается правильное время, но на Android 15 оно не отображается. Создается нормально, но ничего не происходит. Я заметил, что на первых двух устройствах дата выглядит так
5.12.2024, 14:27:00
12.06.2024, 10: 23:09
но с Android 15
12.06.2024, 01:54:48
Во всех случаях отметка времени верна и проверена.
PD:
В Android 15 с этим кодом уведомление отображается< /p>

Код: Выделить всё

 async function onDisplayNotification() {
// Request permissions (required for iOS)
await notifee.requestPermission()

// Create a channel (required for Android)
const channelId = await notifee.createChannel({
id: 'default',
name: 'Default Channel',
});

// Display a notification
await notifee.displayNotification({
title: 'Notification Title',
body: 'Main body content of the notification',
android: {
channelId,
smallIcon: 'name-of-a-small-icon', // optional, defaults to 'ic_launcher'.
// pressAction is needed if you want the notification to open the app when pressed
pressAction: {
id: 'default',
},
},
});
}

Подробнее здесь: https://stackoverflow.com/questions/792 ... android-15
Ответить

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

Вернуться в «Android»