I`m lost on implementing push notifications without firebase, using laravel web app and expo react native app.

Please provide the following:

  1. SDK Version: 38.00
  2. Platforms(Android/iOS/web/all): Android / IOS

Hi Everyone,

Im developing a react native project in Expo, and the app is pretty much done for all the functionality. However, im stuck on the last part which is push notifications.

We have the following assets:

Laravel web app with API ( Passport ) https://teetimesaver.com/
React Native expo app

In the admin of the web app we can change order status from pending to confirmed. Once we trigger the order to be confirmed, we want to sent out a push notification to their mobile phone, so that they can pay for the order.

The thing is, the web app and the phone app use the same database, the phone app is just consuming data from the api. And the laravel database is a conventional relational database, we got no realtime database like firebase.

With a system like firebase we can listen to the state, and if it change we can execute something. But as i understand this is not possible with a normal database right?

And even if it is possible, if there is no listener how can this be detected by the phone app?

If i send a notification based on just the order status, it would keep sending notifications as the status is always confirmed. So this parameter alone would not work.

I was thinking on putting an extra field in the orders table called “sendPushNotification” with a initial value of 0, then when the order is confirmed change this to 1, and when the notification is send out put it back to 0. Where the notification will only be send if the value is 1.

However, then we come back to the other issue of not having a constant listener for that change.

Can anyone help me with a push in the right direction? I`m a bit lost on this.

I would recommend using expo push notifications. Your experience will be best if you upgrade to the newest SDK of Expo, because push notifications has received a lot of attention in the recent Expo SDK releases. Such as making the push notifications work when the app is killed.

Push notifications is one of the more complex parts of mobile development. But made a lot easier with expo.

  1. Setup your app for push notifications and for android create a firebase project in order to create a google-service-json file.

  2. Your app should register for push tokens: await Notifications.getExpoPushTokenAsync()).data. You can send that push token to your web api

  3. You web api saves that push token, maybe with the userId.

  4. When you set a status to confirmed in your admin part of the web you should create a push notification. Your wep api will send that push notification to expo’s push notification servers, using the push token recieved from the app. That way expo and Google/Apple will know who the recipient of your notification are.

  5. Handle receiving the notification in your app

You can see more here

Thank you very much rcknti!

That helped me a lot, it was a bit of a pain to upgrade to SDK 42 but got that done.

I was able to generate push notifications, and by going through the process i now understand that push notification tokens stay the same for that user. At first i thought this changes with every push notifications send.

This enabled me to indeed save that token in the user table of the web app. And since the system works through an API, i should be able to send a push notification through the web app to the EXPO Push notification API. And the push notification should trigger on the phone.

Thank you so much man!

Glad I could help!

when you get to handle notifications on the app remember to update the token your app has once in a while. I’m not sure when it cycles. We send the token to our API whenever the app become active / foreground. That is likely too often :slight_smile:

I got an answer from another post:

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.