Push Notifications
How to use Expo Push Notifications in Ship Mobile Fast
Overview
We are using Expo Push Notifications to send push notifications to your users.
Setup
Actually I handled this in codebase. If you interested, you can go to the @/hooks/usePushNotifications.ts
file.
With this hook, your user can get notifications in background, on lock screen, and in notification center automatically.
You don’t need to do anything else but I want to give you some hints:
Go to your @/hooks/usePushNotifications
file. You’ll see bunch of codes. But Important part is:
expoPushToken
is your user’s push token. You can use this token to send push notifications to your user.
sendPushNotification
is a function to send push notifications to your user.
notification
is a hook to get the notification data.
Types
Advanced
If you want to send advanced notifications, you should create Supabase Edge Functions. Let me tell you step by step. But I am not going to code this in this documentation. Because it is project specific.
I assumed you already set up Supabase and created your tables. Such as profiles
, likes
, comments
, etc.
Go to Supabase Edge Function documentation. Which is: Supabase Edge Functions.
Click Get Started
button and open your terminal.
You should have Supabase CLI installed. If you don’t have, follow the documentation.
Then you need to create a new Edge Function. Like:
Open your supabase/functions/send-push-notification
folder. And you will see the index.ts
file.
Now we need to integrate with Expo Push Notifications. You can follow this link: Sending Notifications
If you got stuck, you can watch this video:
Now you can use Edge Functions and send push notifications to your users.
Don’t forget to use webhooks.
Was this page helpful?