Local Notifications not working


#1

Hi, thus far I have a a Preact build with Capacitor working on a physical and virtual IOS device and cannot get LocalNotifications to work. I have no Ionic experience and am not using typescript. Just trying to get a simple native local notification to work. Calling the scheduleNow function bellow freezes my app.

Plugins.LocalNotifications.addListener('localNotificationReceived', (notification) => 
 console.log('Notification: ', notification);

});

const scheduleNow = async () => {
        const notif = await Plugins.LocalNotifications.schedule({
            notifications: [{
                at: new Date(),
                title: 'Heyyoo',
                actionTypeId: 'asdf',
                body: 'hit me up',
                // Get random id to test cancel
                id: Math.floor(Math.random()*10),
                sound: 'beep.aiff',
            }]
        });

};


#2

The docs may be wrong but i was referencing this
https://github.com/ionic-team/capacitor/blob/5759d8ab7e8ac4e964f2d7a5574c8e44f7e4bbc6/example/src/pages/local-notifications/local-notifications.ts#L65

my solution was use the following while ensuring the date is a future date:

   const scheduleNow = async () => {

    var now = new Date();

    const notif = await Plugins.LocalNotifications.schedule({
        notifications: [{
            schedule: {
                at: new Date(now.getTime() + (10 * 1000))
            },
            title: 'Heyyoo',
            body: 'hit me up',
            id: Math.floor(Math.random()*10),
            sound: 'beep.aiff',
        }]
    });

};