Developers · Flutter SDK
Flutter push notifications SDK
One plugin, oricato_push, for Android and iOS. It is built on firebase_messaging, uses flutter_local_notifications to render Android data messages, even from the background isolate, and reports deliveries, opens and conversions through a stored retry queue.
oricato_push 1.0.1Flutter 3.27+Dart 3.6+firebase_core 3.12–4.xfirebase_messaging 15.2–16.xflutter_local_notifications 18–19.xAndroid minSdk 21iOS 13+
Last updated · Ask the docs, or a person
Lingora jetzt
Deine Lektion für heute ist bereit
Fünf Minuten, und deine 12-Tage-Serie hält.
receiptsFlutter
- pushfx_id 0192f0c4… · fx_v 113:00:00
- shownchannel lessons · big picture13:00:01
- deliveredsampled device · once13:00:03
- openedtap · launch_url lingora://lesson13:00:41
A photo of a phone in someone's hands; on its screen, a sample notification from Lingora in the language de. Beside it, the receipts the SDK reports for that push: shown, delivered from a sampled device, and opened on tap.
01
What the plugin does for you
- Creates and keeps the subscription ID in native storage that is never backed up, with a guard against restored or copied state.
- Registers and updates the subscription on start, resume, token refresh, time zone or locale change, permission change and every setter, when something changed or the last success is over an hour old.
- Sends the IANA time zone, the language your app shows, country hints, device model, OS, app and SDK versions, and the permission state.
- Creates Android notification channels from your dashboard settings.
- Renders Android data messages with channel, icon, accent color, big picture, group and collapse key, and handles taps, including the tap that started the app.
- Reports
deliveredfrom sampled devices,openedand conversions, with de-duplication, backoff,Retry-Afterand an Android WorkManager job to flush the queue.
02
Add the package
Your app must already be set up for Firebase Cloud Messaging (flutterfire configure, google-services.json, GoogleService-Info.plist). During early access the plugin comes in the SDK kit with your account. Copy it into your repository and use a path dependency.
dependencies:
firebase_core: ^4.11.0
firebase_messaging: ^16.4.1
oricato_push:
path: packages/oricato_push 03
Android setup
- Core library desugaring, which
flutter_local_notificationsneeds, inandroid/app/build.gradle.kts:android { compileOptions { isCoreLibraryDesugaringEnabled = true } } dependencies { coreLibraryDesugaring("com.android.tools:desugar_jdk_libs:2.1.4") } - A small icon, white on transparent, for example
res/drawable/ic_stat_notification.pngin every density, passed asdefaultSmallIcon. Unknown icon names fall back to it, then to the app icon. - Keep resources referenced by name with
android/app/src/main/res/raw/oricato_keep.xml:<?xml version="1.0" encoding="utf-8"?> <resources xmlns:tools="http://schemas.android.com/tools" tools:keep="@drawable/ic_stat_*,@raw/*" /> - Channel sounds go in
res/raw/, for examplechime.mp3, namedchimein the dashboard. A channel whose sound is missing is not created, because Android fixes a channel's sound when it is created. - Permission. The plugin declares
POST_NOTIFICATIONS. On Android 13 and later, callOricato.requestPermission()at a good moment in onboarding. - Deep links open with
ACTION_VIEW. KeeplaunchMode="singleTop"onMainActivity, the Flutter default, and handle links in your router.
04
iOS setup
- In Xcode, under Signing & Capabilities, add Push Notifications and Background Modes › Remote notifications. Upload your APNs key (
.p8) in the Firebase console. - Foreground presentation follows
firebase_messaging:await FirebaseMessaging.instance.setForegroundNotificationPresentationOptions( alert: true, badge: true, sound: true, ); - Optional: the Notification Service Extension, for images and for deliveries while the app isn't running. Open
ios/Runner.xcworkspace, add a Notification Service Extension target, linkOricatoPushNotificationServicefrom the iOS package in the kit, subclassOricatoNotificationService, and setOricatoApiBaseURLin the extension'sInfo.plist. Then callOricato.setDeliveryReportedByExtension(true)in Dart.
Build fails with "Cycle inside Runner"? Move Runner's Embed Foundation Extensions build phase above Run Script and Thin Binary. Without an extension, iOS reports delivered only for pushes that arrive while the app is in the foreground; opens are always reported.
05
Initialize and wire the background handler
The background handler must be a top-level function marked @pragma('vm:entry-point'). If you already have one, call Oricato.handleBackgroundMessage from it; it returns true for Oricato pushes.
import 'package:firebase_core/firebase_core.dart';
import 'package:firebase_messaging/firebase_messaging.dart';
import 'package:flutter/material.dart';
import 'package:oricato_push/oricato_push.dart';
import 'firebase_options.dart';
@pragma('vm:entry-point')
Future<void> firebaseMessagingBackgroundHandler(RemoteMessage message) async {
// Renders Android data messages and records "delivered".
// Works without Oricato.initialize in this isolate.
if (await Oricato.handleBackgroundMessage(message)) return;
// your own background handling for other pushes
}
Future<void> main() async {
WidgetsFlutterBinding.ensureInitialized();
await Firebase.initializeApp(options: DefaultFirebaseOptions.currentPlatform);
FirebaseMessaging.onBackgroundMessage(firebaseMessagingBackgroundHandler);
await Oricato.initialize(
'<ORICATO_PROJECT_ID>',
'<ORICATO_API_ADDRESS>',
options: const OricatoInitOptions(defaultSmallIcon: 'ic_stat_notification'),
);
Oricato.onNotificationOpened((n) {
// n.messageId, n.title, n.body, n.launchUrl, n.additionalData
});
runApp(const MyApp());
} initialize returns after local setup and registers in the background. Call it on every start. No handler of your own? Pass oricatoFirebaseMessagingBackgroundHandler instead.
06
Report the language your app shows
Oricato picks each message's translation from the subscriber's language. Report the locale your UI uses, for example from your root widget. Without it, the device locale is used.
@override
void didChangeDependencies() {
super.didChangeDependencies();
Oricato.setLanguage(Localizations.localeOf(context).toLanguageTag());
} 07
API
| Call | Notes |
|---|---|
Oricato.initialize(projectId, apiBaseUrl, {options}) | Idempotent; stores the settings; first registration in the background. |
Oricato.setLanguage(code) | Normalized (zh-TW becomes zh-hant); null follows the app locale. |
Oricato.setExternalUserId(id, {hash}) | An opaque, pseudonymous ID only, never an email or phone number. |
Oricato.setTags(map) | Merges; a null or empty value removes the key. Up to 50 keys. |
Oricato.optIn() / optOut() | App-level switch. |
Oricato.trackEvent(name) | A conversion; linked by the server to the latest open within 24 hours. |
Oricato.onNotificationOpened(handler) / notificationOpened stream | The latest unhandled tap, up to five minutes old, arrives when you register. |
Oricato.onForegroundNotification(handler) / foregroundNotifications stream | Return false to hide the Android notification. |
Oricato.getSubscriptionId() | The stored ID. Show it in a debug screen to set up a test device. |
Oricato.requestPermission({provisional}) / getPermissionStatus() | Android 13 and later, and iOS authorization. |
Oricato.setLaunchUrlsAutoOpen(bool) | On by default. |
Oricato.setAppCheckTokenProvider(...) | Adds the App Check header, cached until five minutes before expiry. |
Oricato.setLogLevel(level) / setLogSink(sink) | Never logs secrets. |
Oricato.setDeliveryReportedByExtension(bool) | iOS with the extension. |
Oricato.handleBackgroundMessage(message) | From your own background handler. |
08
Apps that already own firebase_messaging or flutter_local_notifications
By default Oricato listens to onMessage and onMessageOpenedApp, calls getInitialMessage() and initializes flutter_local_notifications on Android. getInitialMessage() returns a message only once, and flutter_local_notifications has a single tap callback. If your app uses them itself, for example for locally scheduled reminders, turn those parts off and forward.
await Oricato.initialize(projectId, apiBaseUrl,
options: const OricatoInitOptions(
handleFirebaseMessaging: false,
manageLocalNotifications: false,
defaultSmallIcon: 'ic_stat_notification',
),
);
FirebaseMessaging.onMessage.listen((m) async {
if (await Oricato.handleForegroundMessage(m)) return;
// your foreground handling
});
FirebaseMessaging.onMessageOpenedApp.listen((m) async {
if (await Oricato.handleMessageOpenedApp(m)) return;
});
final initial = await FirebaseMessaging.instance.getInitialMessage();
if (!await Oricato.handleInitialMessage(initial)) {
// your cold-start handling
} Forward taps from flutter_local_notifications with Oricato.handleNotificationResponse and launch details with Oricato.handleLaunchDetails; each returns true when the notification was Oricato's.
09
Running next to onesignal_flutter
- Keep
onesignal_flutterand addoricato_push. Each SDK gets its own Firebase registration and handles only its own pushes; notification channels don't collide. - Ask for notification permission once, with either SDK.
- Optional: from this release, set a OneSignal tag such as
oricato = 1and exclude it from OneSignal sends, so only phones that haven't updated still get OneSignal pushes. - On a real iPhone, check that tapping an Oricato notification reaches
onNotificationOpenedand OneSignal notifications still open as before.
Oricato Intelligence · Early access
One more release, later
Designed and in development. No results yet.
Oricato Intelligence (early access) will need a later plugin version that counts app opens a notification did not start, inside the registration you already send, plus a consent switch your app sets. In the EEA and the UK it stays off until your app asks.