ios icon indicating copy to clipboard operation
ios copied to clipboard

Way to Show Local Notification Popup Only Once

Open yfng96 opened this issue 4 years ago • 1 comments

"@react-native-community/push-notification-ios": "^1.8.0",

Hi, I am trying to create a timer feature using local notifications. The code below works well with no duplicate notification in Notification Center.

BackgroundTimer.runBackgroundTimer(() => {
      setSecs((prevVal) => {
        Platform.OS === 'ios'
          ? PushNotificationIOS.addNotificationRequest({
              id: '21474',
              title,
              body: moment()
                .startOf('day')
                .seconds(prevVal + 1)
                .format('H:mm:ss'),
              badge: 0,
            })
          : PushNotification.localNotification({
              id: 21474,
              tag: title,
              ticker: 'My Notification Ticker', // (optional)
              channelId: '123', // (required)
              channelName: 'Default Notification', // (required)
              largeIcon: '',
              smallIcon: '',
              color: Colors.digital,
              title,
              message: moment()
                .startOf('day')
                .seconds(prevVal + 1)
                .format('H:mm:ss'),
              showWhen: true,
              when: Date.now(),
              allowWhileIdle: true,
              ongoing: true,
              onlyAlertOnce: true,
            });
        return prevVal + 1;
      });
    }, 1000);

output-onlinegiftools

However, the popups keep appearing. Is there any way to show the popup only once? output-onlinegiftools-2

yfng96 avatar Aug 18 '21 16:08 yfng96

I have the same problem, using background-timer. Already managed to solve?

jose-guilherme-ti avatar Oct 13 '21 20:10 jose-guilherme-ti