Core Methods
initialize()
registerDevice: true
(default), this method will prompt the user for notification permission and register the device with PNTA. Use registerDevice: false
for delayed registration if you don’t want to prompt the user immediately.
Parameters:
projectId
: Your PNTA project ID (format:prj_XXXXXXXXX
)metadata
(optional): Device metadata as key-value pairsregisterDevice
(optional): Whether to register device immediately. Default:true
autoHandleLinks
(optional): Automatically handlelink_to
URLs when notifications are tapped from background/terminated state. Default:false
showSystemUI
(optional): Show system notification banner/sound when app is in foreground. Default:false
Future<void>
Examples:
lib/main.dart
registerDevice()
initialize()
. Only needed when using delayed registration (when initialize()
was called with registerDevice: false
).
Returns: Future<void>
Example:
lib/main.dart
Must call
initialize()
first. Only use this method when you initialized with registerDevice: false
.updateMetadata()
metadata
: Updated metadata as key-value pairs
Future<void>
Example:
lib/main.dart
handleLink()
link
: The link to handle
void
Example:
lib/main.dart
Properties
deviceToken
String?
Returns: Device token string if registration was successful, null
otherwise.
Example:
lib/main.dart
navigatorKey
MaterialApp
.
Type: GlobalKey<NavigatorState>
Example:
lib/main.dart
foregroundNotifications
Stream<Map<String, dynamic>>
Payload Structure:
Both iOS and Android send identical flat payload structures:
lib/main.dart
onNotificationTap
Stream<Map<String, dynamic>>
Payload Structure:
Contains the link_to
field and any custom data fields. System fields (title
, body
) are not available on Android due to platform limitations.
lib/main.dart
Link Handling
The plugin handles notification links automatically using smart URL detection:- External URLs (with scheme) → Opens in system browser/apps
- Examples:
https://example.com
,mailto:[email protected]
,tel:+1234567890
,sms:+1234567890
- Works automatically with no additional configuration required
- Examples:
- Internal routes (without scheme) → Navigates using Flutter’s Navigator
- Examples:
/profile
,/settings
,/dashboard
- Requires
navigatorKey
setup (covered in Quick Start)
- Examples:
Implementing Notification Listeners
App-Level
Global listeners inmain.dart
. No disposal needed since the app doesn’t get disposed.