react-native-alarm-manager icon indicating copy to clipboard operation
react-native-alarm-manager copied to clipboard

Alarm.searchAll returns an empty array even though I have an alarm on my device

Open TechPro424 opened this issue 2 years ago • 0 comments

import { StatusBar } from 'expo-status-bar';
import { Button, StyleSheet, Text, View} from 'react-native';
import Alarm, {AlarmScheduleType} from 'react-native-alarm-manager';
import * as FileSystem from 'expo-file-system';
import { useEffect } from 'react';

//npx expo start - to start the app


export default function App() {
  //const video = ytdl("https://music.youtube.com/watch?v=sT2sD8PdC_E&si=HM04kwTqdawlIIr2")
  //console.log(video)

  useEffect(() => {
    console.log("Hi")

    Alarm.searchAll(
      success => console.log(success),  // alarm list
      fail => console.log(fail)         // fail message
    );
  }, undefined)

  

  

  const alarm: AlarmScheduleType = {
    alarm_time: '12:30:00 2024-01-25',   // HH:mm:00 yyyy-MM-dd
    alarm_title: 'title',
    alarm_text: 'text',
    alarm_sound: 'sound',   // sound.mp3
    alarm_icon: 'icon',     // icon.png
    alarm_sound_loop: true,
    alarm_vibration: true,
    alarm_noti_removable: true,
    alarm_activate: true
  };


  return (
    <View style={styles.container}>
      <Text>Open up App.js to start working on your app!</Text>
      <Button
        onPress={alarmSearch}
        title="Learn More"
        color="#1e90ff"
        accessibilityLabel="Learn more about this purple button"
      />
      <StatusBar style="auto" />
    </View>
  );
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    backgroundColor: '#fff',
    alignItems: 'center',
    justifyContent: 'center',
  },
});


function alarmSearch() {
  Alarm.searchAll(
    success => console.log(success),  // alarm list
    fail => console.log(fail)         // fail message
  );
}

My App.tsx file

Whenever I press the button, it runs the alarmsearch function, and logs only an empty array [] each time the function is run But I have already set an alarm through the device's clock app

TechPro424 avatar Jan 28 '24 06:01 TechPro424