FCM Fallback Delivery
To burst through Android power saving mode, we can deliver your notifications through Pushy's MQTT channel and Firebase Cloud Messaging simultaneously, for improved reliability. Please follow our detailed instructions below to get started.
Update Pushy SDK
Please make sure your app is using the latest version of the Pushy Android SDK. Return to this page when you're done.
Add Firebase to Your Project
Follow these instructions (Option 1) to log into the Firebase Console with a Google account, create a Firebase Project, and register your Android app with Firebase.
Please follow all instructions on this page under Option 1. Note that you do not have to set up Google Analytics for your project.
- Click Add project and fill out the form
- Click the Android icon and register your app (enter your package name)
google-services.jsonand place it in your
- Include the Firebase SDK by modifying your
build.gradlefiles according to the instructions
Add FCM to Your Project
Add the following dependency to the
build.gradle in your
Note: Please check the official documentation for the latest version of this package.
Add the following
<service> declaration to your
app/src/main/AndroidManifest.xml, inside the
<!-- Pushy Firebase Service --> <service android:name="me.pushy.sdk.services.PushyFirebaseService" android:exported="false"> <intent-filter> <action android:name="com.google.firebase.MESSAGING_EVENT" /> </intent-filter> </service>
Enable FCM Fallback Delivery
Pushy.register() to enable FCM integration:
// Enable FCM fallback delivery Pushy.toggleFCM(true, getApplicationContext());
Note: You may omit the second argument if you are using a hybrid development environment such as React Native or Cordova.
Build and Test
Run your app and observe the logcat to see whether integration is working as expected:
D/Pushy: FCM device token updated successfully
Create a Firebase Service Account
For us to send notifications to your users through Firebase, you must create a service account, generate a private key file, and send the key file to us.
- In the Firebase console, open Settings > Service Accounts
- Click the relevant Firebase project
- Scroll down and click Generate New Private Key, then confirm by clicking Generate Key
- Send the JSON private key file to
firstname.lastname@example.org subject line "FCM Service Account Key"
Send Test Notification
Once we reply that your app has been configured with the private key you sent us, try sending yourself a notification and check whether it is being delivered by FCM and Pushy simultaneously, by observing the logcat.
Input a device token and select your app to send a test push notification:
Note: You can specify a topic instead of a device token (i.e.
/topics/news). Also, if your app is not automatically detected, please manually copy the Secret API Key from the Dashboard and paste it into the form.
Check if your device received the notification. Did it work? If not, contact us, we'll be glad to help.
Congratulations on integrating FCM fallback delivery in your app!
From now on, every notification you send through Pushy will simultaneously be sent through Firebase Cloud Messaging with
priority = high and
ttl = 0 to burst through Doze mode and other power saving modes such as App Standby.
Our SDK will automatically check whether the notification was already received, to ensure your push receiver will only be invoked once per notification.