invertase / react-native-notifee

Moved to https://github.com/invertase/notifee
https://invertase.io/blog/open-sourcing-notifee
Other
465 stars 31 forks source link

`cancelDisplayedNotifications` also cancels scheduled notifications on Android #349

Closed mars-lan closed 3 years ago

mars-lan commented 3 years ago

Based on the name & documentation, I assume the function only cancles displayed/delivered notifications. But it seems that on Android it also cancels all scheduled (but not yet triggered) notifications. Here is an example that demostrates the bug. By commenting out the cancelDisplayedNotifications line the notification will fire as expected after 3s.

import React from 'react';
import { AppRegistry } from 'react-native';
import notifee, { TriggerType } from '@notifee/react-native';

async function init() {
  await notifee.createChannel({
    id: 'channel',
    name: 'channel',
  });

  await notifee.createTriggerNotification({
    title: 'Title',
    body: 'Body',
    android: {
      channelId: 'channel',
    },
  }, {
    type: TriggerType.TIMESTAMP,
    timestamp: (new Date()).getTime() + 3000,
  });

  // Comment out the following line to make the above trigger notification work
  await notifee.cancelDisplayedNotifications();
}

init();

function Test() {
  return null;
}

AppRegistry.registerComponent('Test', () => Test);
helenaford commented 3 years ago

@mars-lan oh, is that since the latest update? I'll take a look into this ASAP, thanks for bringing it to our attention.

mars-lan commented 3 years ago

@helenaford Reproduciable on both 1.9.2 & 1.10.0.

helenaford commented 3 years ago

@mars-lan thanks for confirming. I can see the issue and will publish a release shortly.

helenaford commented 3 years ago

@mars-lan should be fixed now (release 1.10.1) 🙏 Release notes will be live soon (https://notifee.app/react-native/docs/release-notes)

mars-lan commented 3 years ago

Thanks for the quick fix!