9class NotificationManagerExample {
15 NotificationManagerExample() {
17 _setupNotificationListener();
23 void _initializeSdk() {
51 print(
"LocationManager and NotificationManager successfully initialized");
54 print(
"Error initializing SDK: $e");
61 void _setupNotificationListener() {
64 onNotificationLoaded: (Notification notification) {
65 print(
"Notification loaded");
66 _demonstrateNotificationUsage(notification);
71 onNotificationFailed: (Error error) {
72 print(
"Notification failed: ${error.message}");
73 _demonstrateErrorHandling(error);
84 print(
"NotificationManager not initialized");
91 print(
"Added notification listener");
95 Future.delayed(Duration(seconds: 2), () {
99 print(
"Removed notification listener");
107 void _demonstrateNotificationUsage(Notification notification) {
108 if (notification ==
null) {
109 print(
"Notification is null");
115 int id = notification.
id;
116 print(
"Notification ID: $id");
121 String title = notification.
title;
122 print(
"Notification title: $title");
127 String content = notification.
content;
128 print(
"Notification content: $content");
133 String? imageUrl = notification.
imageUrl;
134 if (imageUrl !=
null) {
135 print(
"Notification image URL: $imageUrl");
137 print(
"Notification has no image URL");
145 void _demonstrateErrorHandling(Error error) {
146 print(
"Handling notification error:");
147 print(
" Error message: ${error.message}");
148 print(
" Error type: ${error.runtimeType}");
154 Future<void> runExample() async {
155 print(
"=== NotificationManager Example ===");
160 await Future.delayed(Duration(seconds: 5));
162 print(
"=== Example completed ===");