This repository was archived by the owner on Jan 14, 2025. It is now read-only.
This repository was archived by the owner on Jan 14, 2025. It is now read-only.
on press localNotificaton don't work on android #2188
Closed
Description
When calling localNotificationSchedule in context provider it works, when calling localNotificationSchedule onPress inside component it doesn't work on android. Ios work well.
MacBook air m1
react-native: 0.64
react-native-push-notification: 8.1.1
react-native-community/push-notification-ios: 1.10.1
index.js
PushNotification.configure({
onRegister: function (token) {
console.log('TOKEN:', token);
},
onNotification: function (notification) {
console.log('onnn', notification);
notification.finish(PushNotificationIOS.FetchResult.NoData);
},
permissions: {
alert: true,
badge: true,
sound: true,
},
popInitialNotification: true,
requestPermissions: Platform.OS === 'ios',
});
PushNotification.createChannel(
{
channelId: 'local-notifications', // (required)
channelName: 'Local-notifications channel', // (required)
channelDescription: 'A channel to categorise your notifications', // (optional) default: undefined.
soundName: 'default', // (optional) See `soundName` parameter of `localNotification` function
importance: Importance.HIGH,
vibrate: true, // (optional) default: true. Creates the default vibration pattern if true.
},
created => console.log(`createChannel returned '${created}'`),
);`
Contex provider:
useEffect(() => {
PushNotification.localNotificationSchedule({
id: '12333',
channelId: 'local-notifications',
title: 'Hat er sein Ziel erreicht 1',
message: 'poruka',
repeatType: 'minute',
date: new Date(),
});
}, []);
component
const setupNotification = (id, mess, name) => {
PushNotification.localNotificationSchedule({
id: id,
channelId: `local-notifications`,
title: name,
message: mess,
repeatType: 'minute',
date: new Date(),
});
};
<TouchableOpacity
style={FormStyles.button}
onPress={() => savePlane()}>
<Text style={FormStyles.buttonText}>Einen Plan machen</Text>
</TouchableOpacity>