Expo Push (Classic)

Delete indie notifications

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)
    )
}
ArgumentRequiredNotes
subIdyesThe subscriber's registered id.
notificationIdyesA row's notification_id.
appId, appTokennoYour 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}
StatusMeaning
201 with textNothing is deleted: the free trial has ended, sending is paused for an unpaid invoice, or the account is on Premium.
401The appId and appToken pair doesn't match an app.

A failed request (a 401, a network error) rejects, so keep the try / catch.