ios
ios copied to clipboard
Way to Show Local Notification Popup Only Once
"@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);

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

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