Flutter Push Notifications: FCM, APNs and Permission — Cloud & DevOps article by Rui Codex

Push notifications in a Flutter app need three parts working together: Firebase Cloud Messaging (FCM) sends the message, Apple Push Notification service (APNs) delivers it to iPhones and iPads, and the user must grant permission before any alert can appear. Configure the device token and the APNs key first, then request permission at a moment when the user understands why it matters.

Key takeaways

  • Firebase Cloud Messaging routes each message to a device token, and iOS messages also pass through APNs.
  • Tokens change over time, so your backend must store them per user and remove the ones that stop working.
  • Ask for notification permission after the user sees a concrete reason to allow alerts, not on first launch.
  • Test iOS pushes on a physical device with a correctly configured APNs key and Push Notifications capability.

How does push delivery work in a Flutter app?

A server sends a message to Firebase Cloud Messaging, which routes it to a registration token that identifies one app installation on one device. For iOS devices, FCM hands the message to APNs, which holds the connection to Apple devices. Your Flutter code receives the message only after the operating system has accepted it.

Tokens belong to installations, not users

Each app installation receives its own registration token. The token can change after a reinstall, a device restore or a token refresh, so the app should report every new token to your backend. A backend that keeps tokens against user accounts can send to the right devices after a user signs in on a second phone.

Stale tokens must be cleaned up. When FCM reports that a token is no longer valid, the backend should delete it instead of retrying it on every send.

Notification messages and data messages

A notification message carries a display payload that the operating system can show while the app is in the background or closed. A data message is handled entirely by your code. The Firebase Cloud Messaging documentation describes how each message type behaves in each app state, and the two types do not behave the same way.

Tip: Test every notification in four states: foreground, background, terminated, and launched by a tap from the system tray. Most delivery bugs appear in only one of these states.

When should a business app ask for notification permission?

Ask once, at the point where the user can see a concrete reason to say yes, and never on first launch before they have used a feature. On iOS, the system permission dialog is shown once, and a user who declines must change the setting manually in the device settings. The Apple UserNotifications framework documentation describes the authorisation request and its options.

Before the system dialog appears, show a short in-app explanation that names the notification types the user will receive. The explanation does not replace the system prompt, but it gives the user context to answer it.

  • Name the notification types, such as order status changes or approval requests.
  • Show an in-app explanation before calling the system permission request.
  • Offer an in-app inbox so users who decline still see the same events.
  • Store the permission state so the app does not repeat a prompt the system will not show again.

Hypothetical examples of permission timing

Here are two hypothetical scenarios: these are illustrative only and contain no measured results.

In the first scenario, a field-service app requests permission on first launch, before the technician has seen any job. The prompt may be declined, and then job reminders never reach that technician. In the second scenario, the same app waits until the technician accepts a first job, then explains that dispatch alerts will arrive while the app is closed. The second flow gives the user a reason to allow alerts, and the in-app inbox covers anyone who still declines.

What does the iOS side need before a push can arrive?

An iOS app needs an APNs authentication key linked to the Firebase project, the Push Notifications capability enabled in Xcode, and a provisioning profile that includes that capability. Without these, pushes will not reach the device. Apple describes the notification request model in the UserNotifications documentation, which is the reference to read before changing signing settings.

  • Create an APNs authentication key in the Apple Developer account and upload it to the Firebase project settings.
  • Enable the Push Notifications capability in the Xcode target.
  • Regenerate the provisioning profile after changing capabilities.
  • Test on a physical device, because a simulator is not a reliable target for remote pushes.
Tip: Keep the APNs key in your team password manager, not on one developer laptop. A missing key is one of the most common causes of an iOS release that receives no pushes.

Where do push notifications fail in production?

Most failures come from tokens, permissions and payload assumptions rather than from the messaging service itself. Check these three areas before changing the app code. The FCM documentation explains the delivery rules that operating systems can override.

Stale and duplicate tokens

A user who signs out but keeps a token registered can receive another person's alerts on a shared device. Tie each token to the signed-in account and remove it on sign-out.

Background restrictions

Operating systems can delay or drop background work to protect battery life, so a push should never be the only path for a timing-critical action. Design the app so it fetches the current state when it opens.

Payload content

Notification text may appear on a lock screen, and the payload passes through Google and Apple delivery services. Keep it short and free of customer details that should stay inside the authenticated app.

How should a business app route notifications to the right screen?

Send a stable identifier, such as a record type and record ID, and let the app load the record after the user signs in. This keeps sensitive details out of the payload and lets the app handle expired sessions cleanly.

Rui Codex builds Flutter app development for business workflows. Where notifications depend on data from an ERP or CRM, the event source is usually a system integration that publishes changes to the app backend, and the notification logic should be designed alongside it.

Tip: Log the notification identifier, the token state and the delivery result on the backend. Without these logs, a support request about a missing alert cannot be investigated.

Frequently Asked Questions

Do I need APNs if I use Firebase Cloud Messaging?

Yes, for iOS devices. FCM delivers messages to iPhones through APNs, so the APNs authentication key must be linked to the Firebase project. Android devices receive messages through Firebase directly. Plan the APNs setup alongside the Firebase project so the iOS build can be tested on a physical device before release.

Should the app request notification permission on first launch?

Usually not. Asking before the user understands the value often produces a denial that is hard to reverse on iOS. Explain the notification types first, request permission at a relevant moment, and provide an in-app inbox as a fallback for users who decline.

Why do some push notifications not arrive?

The most common causes are stale tokens, missing permission, a missing APNs configuration and operating system limits on background activity. Check the token stored in your backend, the permission status on the device and the APNs key in Firebase before changing application code.

Can a push notification carry customer data?

It is better not to. Notification text can be visible on a lock screen and passes through Google and Apple delivery services. Send an identifier instead, and load the details inside the authenticated app after the user signs in.

Next steps

Start by mapping which events matter to users, then configure FCM and APNs before writing the permission flow. Test the token lifecycle, the iOS capability and each app state on real devices. Rui Codex is led by a founder with 200+ projects delivered and 12+ years of hands-on experience, and the team can review your notification design as part of a wider app project. Request a project consultation at https://ruicodex.com/Contact or email info@ruicodex.com to discuss your project.

Sources

Tags: Flutter Firebase Cloud Messaging APNs Push Notifications iOS Development Mobile Apps Business Apps Notification Permission

Need Help Implementing This?

Our team can help you put these insights into practice. From AI automation to custom software development, we build solutions that deliver real results.

Send a project request