Expo notifications configuration guide
Expo notifications are already preconfigured in this template. However, you still have to provide some secrets and keys in order to use them across your applications that uses this template.
Expo Go doesn't require any additional configuration so you can check notifications by copying push token (from Settings
screen) and test notifications (on RL device) on expo.dev/notifications tool.
Usage in expo dev client (expo run:[android:ios])
- Make sure you have created your account in expo.dev.
- Follow bootstrap docs
- Follow platform specific configuration.
Android
- Configure firebase to get
google-services.json
file - follow this guide. - Make sure that you have changed your
owner
name inapp.json
. - Download
google-services.json
file - Encode this file to base64
- Place base64 string in environment variable in this value:
ANDROID_FIREBASE_CONFIG
- Provide your
experienceId
inextra
section inapp.json
typically it follows this scheme -@owner/slug
ex.:yarn baca bootstrap --simple
- you should have this values already filled up - look at create new app docs
- Get credentials
For Android, you need to configure Firebase Cloud Messaging (FCM) V1 to get credentials and set up your Expo project.
Follow the steps in Add Android FCM V1 credentials to set up your credentials.
iOS
iOS
notification credentials are automatically generated (paid apple developer account is required to make them working).
Test using the push notifications tool
Extending expo-notifications
config
If u need additional expo-notifications
config follow this guide.
Push notifications logic
When working with expo push notifications, probably you will not need to do any additional logic, but here are described key files that you can follow when some changes will be needed:
NotificationsProvider
- assign push token when opening the app (thanks to that push token will be send every time user will change their push permissions outside the app)
- setup push listeners
- navigate to screens when push is pressed
NotificationService
- Register push - ask for permissions
- Assign push token - send push token to backend
Sending push token to backend
This starter comes with support to send expo push token to backend, you will just need to add your api calls in this two files (replace console.logs with api calls):
NotificationService
console.log('SEND ME TO BACKEND', pushExpoToken)
authActions
console.log('REMOVE ME from BACKEND', pushTokenStorage)