-
Notifications
You must be signed in to change notification settings - Fork 237
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Notification not showing Android 15 #1154
Comments
If you could post a full App.tsx that had a button to post a working notification and a button that failed on Android 15 that would really help - I could drop in a fresh reproducer app that would help. Something I can just drop in with no changes |
It is a complex app to just share that file. The try-catch does not throw any errors. The notification is created well because when I show them, it appears. It must be something with the permissions because on two other phones it does appear programmed. |
I did not ask for a complex app. I asked you for a minimal viable reproducer App.tsx. nothing but what is required to produce the problem you describe https://stackoverflow.com/help/minimal-reproducible-example I recommend using react-native-permissions for all permission stuff, regardless - you might try centralizing all your permission handling to that |
When I enter the app information, the notification permission is enabled and even the channel (essential for new versions). For notifications that I create on demand, it appears normally. Not the scheduled ones. |
import React from 'react';
// UTILS
import {checkApplicationPermission, createNotification, } from '../../utils';
// REACT NATIVE
import {
View,
Button,
} from 'react-native';
import notifee from '@notifee/react-native';
export default function CheckListScreen() {
async function onDisplayNotification() {
// Request permissions (required for iOS)
await checkApplicationPermission()
// 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,
// pressAction is needed if you want the notification to open the app when pressed
pressAction: {
id: 'default',
},
},
});
}
async function onDisplayDelayNotification()
{
await checkApplicationPermission()
createNotification();
}
return (
<>
<View>
<Button title="Display Notification" onPress={() => onDisplayNotification()} />
<Button title="Display Notification in two minutues" onPress={() => onDisplayDelayNotification()} />
</View>
</>
);
} utils export const checkApplicationPermission = async () => {
if (Platform.OS === 'android') {
try
{
await PermissionsAndroid.request(
PermissionsAndroid.PERMISSIONS.POST_NOTIFICATIONS,
);
} catch (error) {
console.log(error)
}
}
};
const createTrigger = () =>
{
const trigger: TimestampTrigger = {
type: TriggerType.TIMESTAMP,
timestamp: Date.now() + 1000 * 60 * 2, // fire in 2 minutes
alarmManager: {
type: AlarmType.SET_ALARM_CLOCK
},
};
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 () => {
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(),
);
}
catch (e)
{
console.log(e)
}
} |
I am using the notifee library for react native with this code
On devices with Android 13 and 14 the notification is It displays the correct time but with Android 15 it doesn't appear. It creates itself fine but nothing happens. Something I noticed is that on the first two devices the date appears like this
12/5/2024, 2:27:00 PM 6/12/2024, 10:23:09 AM
but with Android 15
6/12/2024, 01: 54:48
In all cases the timestamp is correct and verified
PD:
In Android 15 with this code, the notification is showing
The text was updated successfully, but these errors were encountered: