import IntentLauncher, { IntentConstant } from 'react-native-intent-launcher';
export const SetAlarm = (Hour, Minute) => {
const now = new Date()
let currentHour = now.getHours()
let currentMinute = now.getMinutes()
// Dakikaya ekleme yap
let newMinute = currentMinute + Minute;
let additionalHours = Math.floor(newMinute / 60); // Eğer dakika 60'ı geçerse saati artır
if(additionalHours > 0){
newMinute = newMinute % 60; // Dakikayı 60'ın altında tut
}
// Saate ekleme yap
let newHour = (currentHour + Hour + additionalHours) % 24; // 24 saat sisteminde kal
console.log("Hour: " + newHour + " Minute: " + newMinute);
const intentParams = {
action: 'android.intent.action.SET_ALARM',
extra: {
'android.intent.extra.alarm.HOUR': parseInt(newHour), // Saat
'android.intent.extra.alarm.MINUTES': parseInt(newMinute), // Dakika
'android.intent.extra.alarm.SKIP_UI': true, // UI'yi atla
}
};
try{
IntentLauncher.startActivity(intentParams);
}
catch(err){
console.log(err)
}
};
But instead of the hour and minute I gave it, it automatically sets it to 11 o'clock.
How can I have it set at the hour and minute I choose? I couldn't find an exact example usage on the internet.
For Android security, it cannot be set automatically on some phones, it only redirects to the application screen.