emekalites / react-native-alarm-notification

schedule alarm and local notification in react-native
https://www.npmjs.com/package/react-native-alarm-notification
MIT License
225 stars 95 forks source link

Immediate notification works but Scheduling doesn't work #200

Open prakhar-thecoder opened 1 year ago

prakhar-thecoder commented 1 year ago

Hello,

when i use the send notification now method(), it works perfectly, but when using the scheduleAlarm method the alarm doesn't ring. The app is in foreground completely

My code

`

import React, {useEffect, useState} from 'react';
import {FlatList, Text, TouchableOpacity, View} from 'react-native';

import ReactNativeAN from 'react-native-alarm-notification';

function App() {
  useEffect(() => {
    (async () => {
      const alarmNotifData = {
        title: 'My Notification Title',
        message: 'My Notification Message',
        channel: 'my_channel_id',
        small_icon: 'ic_launcher',

        // You can add any additional data that is important for the notification
        // It will be added to the PendingIntent along with the rest of the bundle.
        // e.g.
        data: {foo: 'bar'},
      };

      try {
        const alarm = await ReactNativeAN.scheduleAlarm({
          ...alarmNotifData,
          fire_date: '18-10-2023 20:03:50',
        });
        console.log(alarm); // { id: 1 }
      } catch (e) {
        console.log(e);
      }
    })();
  }, []);
  return <Text>Hello!</Text>;
}

export default App;

`

emekalites commented 1 year ago

Hi, i believe the library needs a make-over. I have not had the time to work on this but I'm hoping to update/upgrade this library in the upcoming month. Hopefully this issue should be resolved by then. Thanks.