Expo Push (Classic)

Get unread indie notifications count

Get how many notifications a subscriber hasn't read, for your own unread badge.

Premium has no inbox

On Premium, every inbox call answers 201 with an explanation, so the SDK shows an empty inbox and an unread count of 0. See what each plan includes.

Get the unread count

getUnreadIndieNotificationInboxCount resolves with how many of a subscriber's notifications are unread. Show a bubble over your inbox icon while it's above 0.

import React, { useState, useEffect } from 'react';
import { getUnreadIndieNotificationInboxCount } from 'native-notify';

export default function Header() {
    const [unreadNotificationCount, setUnreadNotificationCount] = useState(0);

    const fetchUnreadCount = async () => {
        try {
            const unreadCount = await getUnreadIndieNotificationInboxCount(
              "unique-user-id",
              yourAppId,
              'yourAppToken'
            );
            console.log("unreadCount: ", unreadCount);
            setUnreadNotificationCount(unreadCount);
        } catch (error) {
            console.error("Error fetching unread notification count: ", error);
        }
    };

    useEffect(() => {
      fetchUnreadCount();
    }, []);

    return (
      ...
    )
}
ArgumentRequiredNotes
subIdyesThe subscriber's registered id.
appId, appTokennoYour app's id and token from your Native Notify dashboard. Default to NativeNotify.init().

Fetching the inbox marks every notification read and drops the count to 0, unless you use per-notification read state.

Call the endpoint directly

GET https://app.nativenotify.com/api/indie/notification/inbox/read/{subId}/{appId}/{appToken}
StatusMeaning
201{ "unreadCount": 3 }.
201 with textPremium: nothing is counted, so the SDK returns 0.
401The appId and appToken pair doesn't match an app.

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