Skip to main content

Prerequisites

Make sure you’ve completed the Platform Setup for iOS and Android before proceeding.

How to Use

Add one line to your app’s main() function:
lib/main.dart
Get your project ID from your PNTA Dashboard settings.
That’s it! Your app now receives push notifications.

Advanced Usage

Configuration Options

You can configure optional parameters for more control:
lib/main.dart

Delayed Registration

If you need to register the device later (e.g., after user login), use delayed registration:
lib/main.dart
Best Practice: Consider delayed registration for better opt-in rates. Prompt users for notifications during onboarding or after signup when they understand the value.

Custom Notification Handling

Foreground Notifications

When your app is open and active, notifications arrive silently by default (no system banner). Use this to show custom UI like snackbars or dialogs:
lib/main.dart
iOS: Set showSystemUI: true to display the standard notification banner when your app is in the foreground.
Android: Set showSystemUI: true to make notifications appear in the notification panel. By default, Android foreground notifications are silent and don’t appear in the panel. You’ll need to handle in-app UI using the listener above.

Background/Terminated Notifications

When users tap notifications while your app is in background or closed:
lib/main.dart
Set autoHandleLinks: true to automatically handle notification links. External URLs open in the browser, internal routes navigate within your app (requires navigator key setup).

Deep Linking Setup

For notifications that navigate to specific pages in your app:
lib/main.dart
Only needed if your notifications contain internal routes like /profile. External URLs with schemes (https://, mailto:, tel:, sms:) work automatically with no configuration.

Complete Example

This example shows multiple optional features. Remember: most apps only need the one-liner from “How to Use” above.
lib/main.dart