Using cloud messaging for push notifications has minimal impact on app frame rate and UI smoothness because notifications are handled by the system outside your app's main thread. However, frequent or heavy payloads can increase battery use and network data consumption. Keep notification payloads small and avoid waking the app unnecessarily to preserve battery life.
Cloud Messaging (push notifications) in Android Kotlin - Build, Publish & Deploy
To keep your app running smoothly at 60fps, avoid processing heavy tasks directly in the notification handler. Use WorkManager or background threads for any data syncing triggered by notifications. Limit the frequency of notifications and batch updates when possible. Also, use data-only messages sparingly to reduce wake-ups and conserve battery.
Integrating Firebase Cloud Messaging (FCM) adds a small increase to your app size, typically a few megabytes due to Firebase libraries. This is considered medium impact. The startup time impact is minimal since FCM runs as a background service managed by Google Play Services, not your app process. Keep dependencies minimal to avoid unnecessary size growth.
On Android, Firebase Cloud Messaging uses Google Play Services to receive and display notifications. On iOS, Apple Push Notification service (APNs) is used, and Firebase acts as a wrapper. iOS requires explicit user permission to show notifications, while Android grants permission by default (starting from Android 13, explicit permission is required). Also, iOS limits background processing time after receiving notifications more strictly than Android.
- Ensure your app requests notification permissions clearly and respectfully, explaining why notifications are needed.
- Do not send spammy or irrelevant notifications; follow Apple App Store and Google Play policies on user experience.
- Handle user opt-out gracefully and do not bypass system notification settings.
- Comply with privacy policies regarding user data used in notifications.
Your app takes 5 seconds to load this screen after receiving a push notification. What's likely wrong?
Answer: The notification handler is doing heavy work on the main thread, blocking UI rendering. Move processing to background threads or schedule work asynchronously to fix this.