Push notifications are a feature I had already set up a while ago but after building the apps and testing the APKs they weren’t working. I did some research and found out that for push notifications to work in production further configuration is required. In this article, I walk you through how I set up push notifications for the production-ready Course Assist apps. Let’s dive straight in🏃
Setting up push notifications🔔
Notifications in Course Assist happen in 5 ways:
- When a new question has been posted
- When a new question-answer request has been received
- When a question-answer request has been approved
- When a question has been answered
- When promotional messages are sent
The Course Assist apps were built using React Native Expo. Fortunately Expo comes with a push notification service called expo-notifications that provides an API to fetch push notification tokens and to present, schedule, receive and respond to notifications. Expo-notifications works fine in development but in production specifically for Android devices further configuration is required😬. This involves getting Firebase Cloud Messaging credentials to send and receive notifications for Android devices. I got these credentials by going to Firebase, setting up a new project, registering each Course Assist app and following the rest of the steps in a very long process😂 which you can read about here is you’re interested. In the end I managed to secured the credentials and was able to send notifications to and from the Course Assist apps in all the ways listed above.
I also setup up the apps to navigate to a required page once a notification is clicked on. For example if a user received a new question answer request notification and they clicked on the notification, they’d be taken to the question answer request page.
With notifications now setup and working correctly I’ll soon be soon be deploying the Course Assist apps into production which you will not want to miss. Thanks for reading and see you in the next one🙏.