This directory contains comprehensive examples demonstrating the usage of Navigine SDK's NotificationManager functionality across all supported platforms.
Overview
NotificationManager is used to manage local notifications that are triggered by iBeacon signals. It detects proximity to beacons and notifies users about events based on parameters configured in CMS.
Key Components
NotificationManager
- Purpose: Manages local notifications and iBeacon signal detection
- Key Methods:
addNotificationListener(NotificationListener listener)
- Add a listener for notification events
removeNotificationListener(NotificationListener listener)
- Remove a previously added listener
NotificationListener
- Purpose: Interface for receiving notification events and errors
- Key Methods:
onNotificationLoaded(Notification notification)
- Called when a notification is successfully loaded
onNotificationFailed(Error error)
- Called when notification loading fails
Notification
- Purpose: Contains information about a notification
- Properties:
id
- Unique identifier of the notification
title
- Title of the notification
content
- Content/body of the notification
imageUrl
- Optional image URL for the notification
Platform-Specific Files
Dart/Flutter
- File:
dart/notification_manager_example.dart
- Key Tags:
[dart_NavigineSdk_getNotificationManager]
[dart_NotificationManager_addNotificationListener]
[dart_NotificationManager_removeNotificationListener]
[dart_NotificationListener_onNotificationLoaded]
[dart_NotificationListener_onNotificationFailed]
[dart_Notification_getId]
[dart_Notification_getTitle]
[dart_Notification_getContent]
[dart_Notification_getImageUrl]
Java
- File:
java/NotificationManagerExample.java
- Key Tags:
[java_NavigineSdk_getNotificationManager]
[java_NotificationManager_addNotificationListener]
[java_NotificationManager_removeNotificationListener]
[java_NotificationListener_onNotificationLoaded]
[java_NotificationListener_onNotificationFailed]
[java_Notification_getId]
[java_Notification_getTitle]
[java_Notification_getContent]
[java_Notification_getImageUrl]
Kotlin
- File:
kotlin/NotificationManagerExample.kt
- Key Tags:
[kotlin_NavigineSdk_getNotificationManager]
[kotlin_NotificationManager_addNotificationListener]
[kotlin_NotificationManager_removeNotificationListener]
[kotlin_NotificationListener_onNotificationLoaded]
[kotlin_NotificationListener_onNotificationFailed]
[kotlin_Notification_getId]
[kotlin_Notification_getTitle]
[kotlin_Notification_getContent]
[kotlin_Notification_getImageUrl]
Objective-C
- Files:
- Key Tags:
[objc_NavigineSdk_getNotificationManager]
[objc_NotificationManager_addNotificationListener]
[objc_NotificationManager_removeNotificationListener]
[objc_NotificationListener_onNotificationLoaded]
[objc_NotificationListener_onNotificationFailed]
[objc_Notification_getId]
[objc_Notification_getTitle]
[objc_Notification_getContent]
[objc_Notification_getImageUrl]
Swift
- File:
swift/NotificationManagerExample.swift
- Key Tags:
[swift_NavigineSdk_getNotificationManager]
[swift_NotificationManager_addNotificationListener]
[swift_NotificationManager_removeNotificationListener]
[swift_NotificationListener_onNotificationLoaded]
[swift_NotificationListener_onNotificationFailed]
[swift_Notification_getId]
[swift_Notification_getTitle]
[swift_Notification_getContent]
[swift_Notification_getImageUrl]
Common Usage Patterns
1. Basic Notification Handling
final notificationManager = sdk.getNotificationManager(locationManager);
final listener = NotificationListener(
onNotificationLoaded: (notification) {
print('Notification: ${notification.title}');
},
onNotificationFailed: (error) {
print('Error: ${error.message}');
},
);
notificationManager.addNotificationListener(listener);
notificationManager.removeNotificationListener(listener);
2. Multiple Listeners
notificationManager.addNotificationListener(analyticsListener);
notificationManager.addNotificationListener(uiListener);
notificationManager.addNotificationListener(loggingListener);
3. Notification Processing
void onNotificationLoaded(Notification notification) {
print('ID: ${notification.id}');
print('Title: ${notification.title}');
print('Content: ${notification.content}');
if (notification.imageUrl != null) {
print('Image: ${notification.imageUrl}');
}
}
4. Error Handling
void onNotificationFailed(Error error) {
print('Notification failed: ${error.message}');
if (error.message.contains('network')) {
} else if (error.message.contains('timeout')) {
}
}
Running Examples
Dart/Flutter
cd dart
dart notification_manager_example.dart
Java
cd java
javac NotificationManagerExample.java
java NotificationManagerExample
Kotlin
cd kotlin
kotlinc NotificationManagerExample.kt -include-runtime -d NotificationManagerExample.jar
java -jar NotificationManagerExample.jar
Objective-C
cd objc
clang -framework Foundation NotificationManagerExample.m -o NotificationManagerExample
./NotificationManagerExample
Swift
cd swift
swift NotificationManagerExample.swift
Features Demonstrated
- SDK initialization and manager retrieval
- Notification listener setup and management
- Notification event handling and processing
- Error handling and recovery strategies
- Notification property access (ID, title, content, image URL)
- Multiple listener management
- Notification simulation
- Resource cleanup
Use Cases
Retail Applications
- Welcome notifications when entering a store
- Special offers based on location
- Product recommendations
- Event reminders
Event Management
- Event notifications
- Schedule updates
- Location-based information
- Emergency alerts
Navigation Apps
- Location updates
- Point of interest notifications
- Route changes
- Safety alerts
Notes
- All examples follow the same logical structure across platforms
- Error handling is implemented consistently across all platforms
- Async patterns are handled appropriately for each platform (Future, Thread, coroutines, etc.)
- Notifications are simulated to demonstrate functionality
- Proper cleanup is performed to prevent memory leaks
- iBeacon signal detection is handled automatically by the SDK
- Notifications should be configured in CMS before use