NativeScript / push-plugin

Contains the source code for the Push Plugin.
Apache License 2.0
123 stars 48 forks source link

Update, group or remove notifications #223

Open GuntarsLuta opened 6 years ago

GuntarsLuta commented 6 years ago

Hi, when app is working in background mode each received notification is displayed separately. Is there any way to group them, update or remove old notifications from status bar?

tbozhikov commented 6 years ago

Hi @GuntarsLuta, with the current setup, this plugin does not offer this functionality. I am not sure if grouping client-side is possible at all. If you want to achieve that, maybe you should think of accumulating notifications server-side and only push a single "grouped" notification to the devices? As for the old notifications - they disappear automatically when the app is opened. Additionally, if you want to remove them before opening the app, the following APIs may help (iOS):

A possible usage in {N}:

import * as utils from "tns-core-modules/utils/utils";

const center = utils.ios.getter(UNUserNotificationCenter, UNUserNotificationCenter.currentNotificationCenter);
center.removeAllDeliveredNotifications();
center.removeAllPendingNotificationRequests();