// Bildirimleri yapılandır
Notifications.setNotificationHandler({
handleNotification: async () => ({
shouldShowAlert: true,
shouldPlaySound: true,
shouldSetBadge: true,
}),
});
const schedulePrayerTime = async (vakit, time) => {
const [hours, minutes] = time.split(':');
return await Notifications.scheduleNotificationAsync({
content: {
title: "Namaz Vakti",
body: `${vakit.toUpperCase()} vakti girdi`,
sound: true,
},
trigger: {
hour: parseInt(hours),
minute: parseInt(minutes),
repeats: true,
},
});
}; React Native Yardım
2
●74
- 07-01-2025, 00:46:22Bir program geliştiriyorum, bildirimler kısmında bildirmi açınca direkt bildirim geliyor aslında tam saatinde gelmesi gerekiyor bunu nasıl ayarlayabilirim?
- 07-01-2025, 00:52:04
const schedulePrayerTime = async (vakit, time) => { const [hours, minutes] = time.split(':'); // Bugünün tarihini al const now = new Date(); // Hedef zamanı oluştur const scheduledTime = new Date(); scheduledTime.setHours(parseInt(hours)); scheduledTime.setMinutes(parseInt(minutes)); scheduledTime.setSeconds(0); // Eğer hedef zaman bugün için geçmişse, yarına planla if (scheduledTime <= now) { scheduledTime.setDate(scheduledTime.getDate() + 1); } return await Notifications.scheduleNotificationAsync({ content: { title: "Namaz Vakti", body: `${vakit.toUpperCase()} vakti girdi`, sound: true, }, trigger: { date: scheduledTime, repeats: true, }, }); };