Delete one notification from a subscriber's indie inbox with deleteIndieNotificationInbox.
Delete a notification
Every row in the indie inbox has a notification_id. Pass it to deleteIndieNotificationInbox, then reload the list:
import React, { useState, useEffect } from 'react';
import { getIndieNotificationInbox, deleteIndieNotificationInbox } from 'native-notify';
export default function NotificationInbox() {
const [takeNumber, setTakeNumber] = useState(10);
const [skipNumber, setSkipNumber] = useState(0);
const [data, setData] = useState([]);
const fetchNotifications = async () => {
try {
const notifications = await getIndieNotificationInbox(
"unique-user-id",
yourAppId,
'yourAppToken',
takeNumber,
skipNumber
);
console.log("notifications: ", notifications);
setData(notifications);
} catch (error) {
console.error("Error fetching notifications: ", error);
}
};
useEffect(() => {
fetchNotifications();
}, []);
const handleDeleteNotification = async (notificationId) => {
try {
await deleteIndieNotificationInbox(
"unique-user-id",
notificationId,
yourAppId,
'yourAppToken'
);
fetchNotifications(); // reload the list in the same shape as getIndieNotificationInbox
} catch (error) {
console.error("Error deleting notification: ", error);
}
}
return (
...
// attach your handleDeleteNotification to mapped notifications
// inside of your Indie Notification Inbox
// so you have access to the notification.notification_id
// example function use:
// handleDeleteNotification(notification.notification_id)
)
}
| Argument | Required | Notes |
|---|---|---|
subId | yes | The subscriber's registered id. |
notificationId | yes | A row's notification_id. |
appId, appToken | no | Your app's id and token from your Native Notify dashboard. Default to NativeNotify.init(). |
Response
It resolves with the subscriber's 10 most recent remaining rows in the same shape the list returns (notification_id, date, title, message, pushData, read), newest first.
Call the endpoint directly
DELETE https://app.nativenotify.com/api/indie/notification/inbox/notification/{appId}/{appToken}/{notificationId}/{subId}
| Status | Meaning |
|---|---|
201 with text | Nothing is deleted: the free trial has ended, sending is paused for an unpaid invoice, or the account is on Premium. |
401 | The appId and appToken pair doesn't match an app. |
A failed request (a 401, a network error) rejects, so keep the try / catch.