Back to results for “Flutter App Security Best Practices”
Flutter › Push Notifications in Flutter (FCM)

How do you properly request notification permission from a user, and what genuinely differs between how Android and iOS each respectively handle this specific particular permission request?

Beginner

Answer

Both platforms genuinely require explicit user permission before an app can actually display push notifications, though they genuinely differ somewhat in exactly how this works, with iOS requiring an explicit runtime permission request through the requestPermission method before any notification can ever actually be displayed at all, while more genuinely recent Android versions similarly now also require this exact same kind of explicit runtime permission request, whereas genuinely older Android versions had previously granted this particular permission completely automatically without ever needing to ask.
NotificationSettings settings = await FirebaseMessaging.instance.requestPermission(
  alert: true,
  badge: true,
  sound: true,
);
Real-world example A fitness app properly requests notification permission immediately after a user genuinely completes their initial onboarding flow, clearly explaining beforehand exactly why receiving workout reminder notifications would genuinely actually benefit them.

Common follow-ups: What genuinely happens if a user actually denies the requested notification permission?;At what specific point within the overall onboarding flow is it generally genuinely best to actually request this particular permission?