To setup push notification, you need to follow the below steps:
1. Configuring schema in admin panel
Open classified listing > settings > app . Now put a same value for the app under App schema. (only lowercase alphabets)
2. Configuring schema in app.json
You need to open your app.json file and add a custom url schema under schema key. See the image.
3. Configuring firebase app
- (If you already configured google login, and added google-services.json file, go to step 4)
If you have not already created a Firebase project for your app, do so now by clicking on Add project in the Firebase Console. - In your new project console, click Add Firebase to your Android app and follow the setup steps. Make sure that the Android package name you enter is the same as the value of
android.package
in your app.json. And similarly add iOS project.
(Android only) Go to your Firebase project’s settings, scroll down to “Your apps” and select your Android app. UnderSHA certificate fingerprints
, clickAdd fingerprint
, and addGoogle Certificate Fingerprint
.
You’ll getGoogle Certificate Fingerprint
by following steps:
(You need to build your app once before these steps to generate credentials)
– runeas credentials
– Select Android
– Select profile (production)
– You’ll get all the credentials in the console. From here copy the “SHA1 Fingerprint“. This SHA1 Fingerprint isGoogle Certificate Fingerprint
.
*** If you haven’t already runeas build -p android
for this project, you’ll need to do that first before getting the Google Certificate Fingerprint. - Download the
google-services.json
for android and Googleservice-info.plist file for iOS and place it in your app’s root directory. - In your app.json, add an
android.googleServicesFile
field with the relative path to thegoogle-services.json
file you just downloaded. If you placed it in the root directory, this will probably look like . Similarly do for iOS. see below code.
{
...
"ios" : {
"googleServicesFile": "./GoogleService-Info.plist"
...
}
...
"android": {
"googleServicesFile": "./google-services.json",
...
}
}
4. Uploading Server Credentials
In order for Expo to send notifications from our servers using your credentials, you’ll need to upload your secret server key. You can find this key in the Firebase Console for your project:
- Click the gear icon to the right of Project Overview to go to your project settings.
- Click on the Cloud Messaging tab in the Settings pane.
- Copy the token listed next to Server key.
Note : If you see Cloud Messaging API (Legacy) is disabled, just click the three dot right next to it and select “Manage API in Google Cloud Console” and After going to cloud console, Click “Enable”. Come back to this page again and refresh it. You’ll see the server key. - Now Log in to expo.dev . Select your app from left sidebar. Click on “Credentials” from Left sidebar
=>
– Select Android and then Select “Applocation Identifier name”
– Now screooll down to “FCM Server Key” section and click on “Add a FCM Server Key” Button
– Now Select “Google Cloud Messaging Token” and paste the copied Server key under Cloud Messaging Token” and click “Save” button
5. Finally go to app > services > miscConfig.js and put “true” for “enablePushNotification”
That’s it — users who run this new version of the app will now receive notifications through FCM using your project’s credentials.
– After configuring Push notification , please create a new build and test with that. Older build might produce errors.
6. After you upload the app in play store and get approved, you need to log in to your play console account and select your published app. On the next page select “App Signing” under “Setup” option from the left sidebar. Scroll down to “App signing key certificate” You’ll see something like the image below. Copy the “SHA-1 certificate fingerprint” under “App signing key certificate”.
Go to your firebase project, open the android app you created in step 2. Now add the “SHA-1 certificate fingerprint” to your project.
Similarly Copy the “SHA-256 certificate fingerprint” And add it to firebase project.
If you miss this step, google signin will not work in the app downloaded from play store.