One Signal
Follow this tutorial to set up push notifications with One Signal
You can find the OneSignal integration at /providers/OneSignalProvider.tsx
and it is initialized at /app/auth.tsx
like this:
If you want to disable the Push Notifications just comment out this part of the code.
Setting up OneSignal
Create an account
Go to the OneSignal website and create an account.
Setting up Messaging Channels
In your Quick Start Guide click on:
- Set up Messaging Channels for Your App
- Then on Push Notifications
Set up your first channel
- Click on Google Android (FCM)
Firebase console
- Now you need to go to the Firebase console and create a new project.
Firebase project settings
- Now once you have created a new Firebase project go to Project Settings
Service account
- Now go to Service Accounts section under Project Settings.
- Click on Generate new private key and download the JSON file.
Google Android Configuration
- Now go back to OneSignal.
- Upload
.json
key. - Click on Save & Continue
Target SDK
- Click on React Native / Expo.
- Click on Save & Continue
App Id
- Copy the App Id.
- Save the App Id in your
.env
file atONESIGNAL_APP_ID=
.
Apple set up
Now you have to that same steps for iOS but instead of Firebase service key you will need a .p8 key from Apple Developer Portal, to do this:
- Go to this page.
- Write a key name.
- Check Apple Push Notifications service (APNs).
- Click Register.
- Download the key.
Remember that the key can be downloaded only once so store it somewhere safe and don’t lose it. And to register .p8 key at Apple Developer portal you have to be enrolled in Apple Developer program.
Run the app
- Now you need to run
npx expo prebuild
in your terminal. - Then run
npx expo run ios
to launch on iOS ornpx expo run android
to launch on Android.
Congratulations! You have successfully set up push notifications with One Signal.
Other tutorials
Set up development environment
Set up your development environment