Push notifications are an important feature for modern mobile applications. They help businesses
keep users informed about relevant events such as new releases, special offers, messages, updates,
and other time-sensitive information.
When implemented correctly, push notifications can improve user engagement, encourage users to
return to an application, and provide a better overall experience. Topic-based notifications take
this one step further by allowing users to receive notifications based on the topics they choose
to follow.
This guide explains how to set up push notifications using Expo and Native Notify, register users,
create topic groups, subscribe users to topics, and send notifications to specific topic groups.
Steps to Set Up Topic-Based Push Notifications
The overall process can be divided into three main stages:
- Register the application and obtain the required push token
- Register individual users with a unique identifier
- Subscribe users to topics and send topic-based notifications
The notification flow generally involves setup, sending, and receiving. The application first
obtains the required notification information, the backend or API sends the notification when
required, and the application responds when the user receives or opens it.
Set Up Native Notify
To begin, visit the Native Notify dashboard and create a free account. After creating an account,
create your application and follow the setup instructions provided by the platform.
Step 1: Install the Required Packages
Open your terminal and install the required packages:
npm install native-notify
npx expo install expo-device expo-notifications
Step 2: Import Native Notify
In your App.js file, import the push-token registration function:
import registerNNPushToken from 'native-notify';
Step 3: Use a Hook-Based App Component
Make sure your application component is a function component. For example:
export default function App() {
// App code
}
Step 4: Register the Push Token
Inside your App function, register the application using the app ID and app token provided by
Native Notify:
registerNNPushToken("your-app-id", "your-app-token");
Use the app ID and app token supplied by your Native Notify application.
Step 5: Start the Expo Application
npx expo start
After completing the basic push notification setup, you can proceed with the Indie Push
configuration.
Register Individual Users
Before sending an individual or topic-based notification, each application user should have a
unique identifier. This identifier can be an email address, phone number, or unique user ID
stored in your database.
A common approach is to register the user after a successful login. This allows the application
to associate the Native Notify subscription with the correct user.
Install Axios
npm install axios
Import the Required Functions
import { registerIndieID } from 'native-notify';
import axios from 'axios';
Register the User
Your login component should use a function component:
export default function LoginScreen() {
// Login code
}
After a successful login, register the user’s unique ID:
const yourLoginFunction = () => {
// Login code
registerIndieID(
'put your unique user ID here as a string',
your-app-id,
'your-app-token'
);
};
It is important that every user has a unique ID. Two different users should not share the same
identifier.
How to Send an Individual Push Notification
Once a user has been registered, an individual push notification can be sent using the user’s
unique ID, application ID, application token, notification title, and message.
The API request can be structured as follows:
axios.post(`https://app.nativenotify.com/api/indie/notification`, {
subID: 'put your unique app user ID here as a string',
appId: 'your-app-id',
appToken: 'your-app-token',
title: 'put your push notification title here as a string',
message: 'put your push notification message here as a string'
});
You can also include additional data with a notification using the pushData
object:
axios.post(`https://app.nativenotify.com/api/indie/notification`, {
subID: 'put your unique app user ID here as a string',
appId: 'your-app-id',
appToken: 'your-app-token',
title: 'Notification title',
message: 'Notification message',
pushData: '{ "yourProperty": "yourPropertyValue" }'
});
Individual notifications are delivered to the application user associated with the supplied
subscription ID.
Set Up Topic Groups
Topic groups allow you to organize users according to the subjects or categories they are
interested in. For example, an application could have topics such as technology, sports,
entertainment, offers, or product updates.
Users can subscribe to the topics they want to follow. Notifications can then be sent to the
users subscribed to a particular topic rather than sending the same notification to everyone.
Get All Topic Group Names
Use the following API to retrieve the available topic groups:
GET https://app.nativenotify.com/api/all/app/topic/group/names/your-app-id/your-app-token
Subscribe a User to a Topic Group
To subscribe a user to a topic group, send a POST request using the topic group name and the
user’s unique subscription ID.
POST https://app.nativenotify.com/api/post/follower
Example request body:
{
"masterSubID": "your Topic Group name",
"followerSubID": "the Indie Sub ID you want to subscribe to this Topic Group",
"appId": "your-app-id",
"appToken": "your-app-token"
}
Unsubscribe a User from a Topic Group
Users can also be removed from a topic group when they no longer want to receive notifications
related to that topic.
PUT https://app.nativenotify.com/api/unfollow/master
Example request body:
{
"masterSubID": "your Topic Group name",
"followerSubID": "the Indie Sub ID you want to unsubscribe from this Topic Group",
"appId": "your-app-id",
"appToken": "your-app-token"
}
View Users Subscribed to a Topic Group
You can retrieve the subscription IDs associated with a particular topic group using the
following API:
GET https://app.nativenotify.com/api/topic/group/your-topic-group-name/your-app-id/your-app-token
Delete a Topic Group
If a topic group is no longer required, it can be deleted using the following API:
DELETE https://app.nativenotify.com/api/follow/master/your-app-id/your-app-token/topic-group-name
Fetching Available Topics
Topic groups can be retrieved through the API and used to determine which topics are available
for users to follow.
The topic group count represents the number of users currently subscribed to that topic. This
information can help you understand how many users are interested in each category.
Sending a Topic-Based Push Notification
After users have subscribed to topic groups, you can send notifications to a specific topic.
Only users who are subscribed to that topic will receive the notification.
This approach is useful when you want to send targeted updates without sending irrelevant
notifications to every user of the application.
- Create relevant topic groups
- Allow users to subscribe to their preferred topics
- Store a unique subscription ID for each user
- Check the user’s topic subscription status
- Send notifications to the selected topic
What Happens When a User Is Not Subscribed?
If a user has not subscribed to a particular topic, they will not receive notifications sent to
that topic. This is one of the main advantages of topic-based push notifications because users
receive information that is relevant to their selected interests.
Benefits of Topic-Based Push Notifications
Topic-based notifications can make push messaging more useful and targeted. Instead of sending
every notification to the entire user base, businesses can deliver updates according to user
interests.
- Improves notification relevance
- Helps increase user engagement
- Reduces unnecessary notifications
- Allows users to control the topics they follow
- Makes targeted communication easier
- Supports better user retention and experience
Conclusion
Topic-based push notifications provide a practical way to deliver relevant information to
specific groups of application users. With Expo, Native Notify, and topic groups, developers can
register users, manage subscriptions, and send targeted notifications without sending every
message to the entire user base.
The key is to maintain unique user identifiers, organize users into meaningful topic groups,
and send notifications only when the information is relevant. This creates a more personalized
notification experience while giving users greater control over the updates they receive.
If you need help implementing push notifications, topic subscriptions, or other mobile
application features, the development team at IPH Technologies can help you build and integrate
the required functionality into your application.






















































