on press localNotificaton don't work on android
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>
Hi @IsmetGlumcevic
Your exemple is not complete, there is no call of setupNotification.
Since it's working in useEffect, I suggest you to check again your code, probably undefined parameters
Regards
I have id: '45id-45rr-33hf-34wd', which format can I put in id? I try with dot, comma.... There is function:
let newId;
id.split('').map((item, index) => {
if (id.length - 1 > index) {
newId += item.charCodeAt() + ',';
} else {
newId += item.charCodeAt();
}
});
The fornat/type is described in the readme.
here dont working too
onPress call:
async function handleComplete() {
console.log('test')
PushNotification.localNotification({
channelId: 'default-channel',
title: 'testnotify',
message: 'test'
})
}
my config:
PushNotification.configure({
permissions: {
alert: true,
badge: true,
sound: true,
},
requestPermissions: false,
});
@IsmetGlumcevic did you found a solution?
This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 30 days if no further activity occurs. Thank you for your contributions.