Push Notifications are an important feature, no matter what kind of app you’re building. Not only is it nice to let users know about something that may interest them, be it a new album being released, a sale or other limited-time-only deal, or that one of their friends sent them a message, but push notifications are proven to help boost user interaction and create a better overall user experience.
Whether you just want to be able to let users know when a relevant event happens, or you’re trying to optimize customer engagement and retention, Expo makes implementing push notifications almost too easy. All the hassle with native device information and communicating with APNs (Apple Push Notification service) or FCM (Firebase Cloud Messaging) is taken care of behind the scenes, so that you can treat iOS and Android notifications the same, saving you time on the front-end, and back-end!
Steps to achieve push notification :-
There are three main steps to setting up topic push notifications, and we provide a guide for each part of the process:
- Setup: getting a user’s Expo Push Token
- Sending: calling Expo’s Push API with the token when you want to send a notification
- Receiving: responding to the notification in your app (maybe upon opening, you want to jump to a particular screen that the notification refers to)
First you have to visit: https://app.nativenotify.com/dashboard
you will seen this type of interface
Create a account for free
Then you will see : )
after that create an app by pressing the button CREATE AN APP
click the button START HERE showing in the navigation bar and follow these steps:
npm install native-notifynpx expo install expo-device expo-notifications
import registerNNPushToken from ‘native-notify’;
export default function App() {…}
registerNNPushToken(“your-app-id”, ‘your-app-token’);
*Do NOT change the ‘appId’ or the ‘appToken’ value in this code. We put your appId and appToken in the code for you*
npx expo start
npm install axios
import { registerIndieID } from ‘native-notify’;import axios from ‘axios’;
export default function LoginScreen() {.…}
const yourLoginFunction = () => {…// Native Notify Indie Push Registration CoderegisterIndieID(‘put your unique user ID here as a string’, your-app-id, ‘your-app-token’);// End of Native Notify Code}
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‘});
axios.post(`https://app.nativenotify.com/api/indie/notification`, {…,pushData: ‘{ “yourProperty”: “yourPropertyValue” }’});
https://app.nativenotify.com/api/all/app/topic/group/names/your-app-id/your-app-token
https://app.nativenotify.com/api/post/follower
{“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”}
https://app.nativenotify.com/api/unfollow/master
{“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”}
https://app.nativenotify.com/api/topic/group/your-topic-group-name/5701/yxOjNO5AkmD8XiPHL2D0pP
https://app.nativenotify.com/api/follow/master/5701/yxOjNO5AkmD8XiPHL2D0pP/topic-group-name