Plugin Methods
Complete API documentation for PNTA Flutter plugin
Core Methods
initialize()
Initializes the plugin with configuration options.
Parameters:
projectId
: Your PNTA project ID (format:prj_XXXXXXXXX
)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
Returns: Future<void>
Examples:
requestNotificationPermission()
Requests notification permission from the user.
Returns: Future<bool>
- true
if permission granted, false
otherwise
Example:
identify()
Registers the device with your PNTA project. Should be called on every app startup after permission is granted.
Parameters:
metadata
(optional): Device metadata as key-value pairs
Returns: Future<String?>
- Device token if you need it for your backend
Examples:
Requires notification permission to obtain the device token. Always call after requestNotificationPermission()
returns true.
updateMetadata()
Updates device metadata without re-registering.
Parameters:
metadata
(optional): Updated metadata
Returns: Future<void>
Example:
handleLink()
Manually handles a link using the plugin’s routing logic.
Parameters:
link
: The link to handle
Returns: void
Example:
Properties
navigatorKey
Global navigator key for internal route navigation. Must be assigned to your MaterialApp
.
Type: GlobalKey<NavigatorState>
Example:
foregroundNotifications
Stream of notification payloads received when app is in foreground.
Type: Stream<Map<String, dynamic>>
Example:
onNotificationTap
Stream of notification payloads when user taps a notification from background/terminated state.
Type: Stream<Map<String, dynamic>>
Example:
Link Handling
The plugin handles notification links automatically based on URL format:
- External URLs (with
://
) → Opens in system browser/apps- Examples:
https://example.com
,mailto:[email protected]
,tel:+1234567890
- Requires Android
<queries>
permissions (covered in Platform Setup)
- Examples:
- Internal routes (without
://
) → Navigates using Flutter’s Navigator- Examples:
/profile
,/settings
,/dashboard
- Requires
navigatorKey
setup (covered in Quick Start)
- Examples:
Best Practices
Memory Management
Always cancel stream subscriptions to avoid memory leaks:
Error Handling
Wrap API calls in try-catch blocks: