This is a simple Android application that demonstrates how to implement push notifications using the Courier Android SDK. The app allows you to send push notifications to devices using Firebase Cloud Messaging (FCM) as the push notification provider.
- Android Studio
- Firebase Cloud Messaging (FCM) setup (instructions provided below)
To get started with the Android Push Notification App, follow these steps:
- Clone this repository to your local machine.
- Open the project in Android Studio.
- Install the required packages by running the following command in the terminal:
./gradlew build
- Go into MyApplication.kt, replace
YOUR_AUTH_KEY
with your auth key andYOUR_COURIER_ID
with the appropriate id.
This will download and install all the necessary dependencies for the project (including the Courier Android SDK 2.0.2).
Before you can send push notifications using this app, you need to set up Firebase Cloud Messaging (FCM) and link it with your Courier dashboard. Here's how you can do it:
- Go to the Firebase Console.
- Create a new project and follow the instructions to set up FCM for Android. Make sure to follow the steps to implement the SDK into the project.
- Download the google-services.json file and add it to the root of this Android project.
- In your Firebase project settings, go to the "Service accounts" tab and generate a new private key. Download this JSON for later.
- Once you've set up FCM, go to the Courier Dashboard.
- In "Channels", Add Firebase Cloud Messaging (FCM) as a new provider. This will require your Firebase "Service Account JSON" - paste in the JSON you saved in step 4.
To send push notifications using this app, follow these steps:
- Run the app on an Android device (a physical device is recommended as Courier does not support the emulator). You will need to turn on developer options and USB debugging.
- Once you've installed the app on your device, go to the settings for this app and allow push notifications.
- To check that your app can receive a basic push notification, send the following cURL request:
"message": {
"to": {
"user_id": "<YOUR_COURIER_USER_ID>"
},
"content": {
"title": "Hey there 👋",
"body": "Have a great day 😁"
},
"routing": {
"method": "all",
"channels": [
"firebase-fcm"
]
}
}
}'```