dartway_push_firebase 0.1.1 copy "dartway_push_firebase: ^0.1.1" to clipboard
dartway_push_firebase: ^0.1.1 copied to clipboard

Firebase Cloud Messaging transport for DartWay push: tokens, permissions and notification taps on Android, iOS and web, behind the dw.plugins.push contract.

dartway_push_firebase #

Firebase Cloud Messaging as a transport for dartway_push_flutter — Android, iOS and web.

DwPush(
  config: DwPushConfig(
    providers: [DwFirebasePush(webVapidKey: kWebVapidKey)],
    // ...
  ),
)

Everything else — when to ask for permission, when the token goes to the server, what happens between a tap and a screen — belongs to the core plugin. This package answers five questions about FCM and nothing more.

What the app still owns #

  • Firebase.initializeApp in main(), with your own firebase_options.dart. This transport refuses to guess your project: with no Firebase app initialized it stands aside and says so.
  • DwFirebasePush.registerBackgroundHandler() right after that, before runApp. FCM wants the handler registered before the app starts.
  • android/app/google-services.json and ios/Runner/GoogleService-Info.plist, plus the Google Services Gradle plugin. Standard FlutterFire setup.
  • Web: copy web/firebase-messaging-sw.template.js from this package to your app's web/firebase-messaging-sw.js and fill in the config. Without it a closed tab shows nothing. Copy it as it stands — the handler is registered before firebase.messaging() and calls stopImmediatePropagation() on purpose: the SDK installs its own notificationclick listener in that call and stops propagation itself, so a handler placed after it never runs. Without the template a tap still reaches the right screen, through webpush.fcm_options.link, but in a new tab instead of the one already open. Pass webVapidKey — the browser issues no token without one.

Notes that cost an afternoon each #

  • On iOS an FCM token exists only after APNs has registered the install. Before that requestToken() answers null, which is a "not yet": the core plugin picks the token up when the platform refreshes it.
  • In the foreground, iOS shows nothing unless asked; this transport asks. Android draws its own.
  • On Android 13+ the notification permission is a runtime prompt, and requestPermission() raises it.

Part of DartWay #

DartWay is a fullstack Dart framework (Flutter + Serverpod). The framework lives in one repository.

0
likes
140
points
65
downloads

Documentation

API reference

Publisher

unverified uploader

Weekly Downloads

Firebase Cloud Messaging transport for DartWay push: tokens, permissions and notification taps on Android, iOS and web, behind the dw.plugins.push contract.

Homepage
Repository (GitHub)
View/report issues

Topics

#dartway #push #notifications #firebase #fcm

License

Apache-2.0 (license)

Dependencies

dartway_push_flutter, firebase_core, firebase_messaging, flutter, web

More

Packages that depend on dartway_push_firebase