• 07-01-2025, 00:46:22
    #1
    Bir program geliştiriyorum, bildirimler kısmında bildirmi açınca direkt bildirim geliyor aslında tam saatinde gelmesi gerekiyor bunu nasıl ayarlayabilirim?


    // 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,
        },
      });
    };
  • 07-01-2025, 00:52:04
    #2
    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,
        },
      });
    };
  • 07-01-2025, 01:22:37
    #3
    teşekkür ederim hocam