For hacktoberfest 2019, my third PR was for an app called Shoot I Smoke App. It is a pretty famous and a useful application. It lets the user know how many cigarettes is the user smoking based upon the quality of air around the user. It is built in React-native, typescript. It uses user’s location and uses the open Algolia places API to get the current air quality and then calculates the number of cigarettes that accounts to.
The owner of the app wanted to add a new feature of notifications, in which user could set their preference and get notifications daily, weekly or monthly basis. Notification would tell the user how many cigarettes are they currently smoking.
I started this issue by looking into expo notification API and then looking into react-native picker. I added a picker with storing the selected value into async storage of users device. Then I dug deep into notification API. Apparently we could schedule notifications, so I added a utils class which receives user’s preference and scheduled the notification accordingly. I got curious and as expected it is kind of a cron job behind the expo curtains.
Work in Progress
Expo notification API accepts a JSON of the data for notification which is displayed at the scheduled time. But we need to fetch the latest data at the time of notification and display that. I and the owner of the repo went back and forth a number of times discussing possible solutions, and currently I am looking into expo background fetch or having a backend for it. I got the initial base set up , and now lets see how we would implement this amazing feature to this amazing application.
- Learnt a big deal about Expo API’s
- Learnt how to handle async storage for a react native app
- Learning about Expo background fetch