r/ScriptingApp • u/Haunting-Ad-655 • Jun 02 '25
Help Removing Notifications
Could anyone help checking my script? This doesn't remove notifications as desired.
Steps to reproduce:
- Run the script
- Tap button 'Push Notification'
- Tap button 'Clear All Notifications'
- Check console logs
import { Button, Notification, Navigation, NavigationStack, Script, VStack } from "scripting";
// Function to schedule a notification immediately
async function clearNotifications() {
await Notification.removeAllPendings();
await Notification.removeAllDelivereds();
console.log("All notifications cleared");
const notis = await Notification.getAllDelivereds()
console.log(notis.length);
console.log(notis);
}
async function pushNotification() {
console.log("Scheduling immediate notification");
await Notification.schedule({
title: "new noti"
});
const notis = await Notification.getAllDelivereds()
console.log(notis.length);
console.log(notis);
}
// Main view component
function NotificationDemoView() {
return (
<NavigationStack>
<VStack navigationTitle="Notifications Demo" spacing={20}>
<Button
title="Push Notification"
action={async () => {
pushNotification()
}}
/>
<Button
title="Clear All Notifications"
action={async () => {
clearNotifications()
}}
/>
</VStack>
</NavigationStack>
);
}
async function run() {
await Navigation.present({
element: <NotificationDemoView />
});
Script.exit();
}
run();
1
Upvotes
View all comments
Show parent comment
1
u/Haunting-Ad-655 Jun 27 '25
I don't think that's relevant. Time-sensitive notifications are those that stays on Lock Screen, without ever going to Notification Center, until manually dismissed. They are not on by default, and need to be implemented by developers.
https://apnspush.com/how-to-enable-time-sensitive-notifications