Conversation
- Added flutter_dotenv dependency for environment variable management. - Updated notification service to handle messages without body. - Created DEVELOPER_SETUP.md for setup instructions. - Added MIGRATION.md for migrating to the new push structure. - Included necessary configuration files for Firebase (iOS and Android). - Updated .gitignore to exclude build directories.
There was a problem hiding this comment.
Pull request overview
This PR refactors the push notification system to simplify integration by automatically handling notification events without requiring manual code intervention. The changes modify the Android push notification structure to follow a standard event format with a notification property, and flatten the data payload structure for easier access.
Changes:
- Simplified push notification initialization by removing the
onTapcallback parameter and introducing anonClickproperty - Flattened
DataPayloadstructure by removing the nestedDetailsclass and promoting fields to top-level - Automatic event tracking for received notifications without manual intervention
- Updated documentation with comprehensive migration guides and developer setup instructions
Reviewed changes
Copilot reviewed 14 out of 17 changed files in this pull request and generated 12 comments.
Show a summary per file
| File | Description |
|---|---|
| package/pubspec.yaml | Version bump to 0.5.8 and updated flutter_local_notifications constraint |
| package/lib/services/notification_service.dart | Major refactoring of notification handling, automatic event tracking, and simplified initialization |
| package/lib/entity/data_payload.dart | Flattened structure with renamed fields (identifier→user_id, notification_log_id→log_id) |
| package/lib/dito_sdk.dart | Simplified initialization by removing Firebase setup and onTap parameter |
| package/README.md | Complete documentation rewrite with improved examples and API reference |
| README.md | Root readme updated matching package readme |
| MIGRATION.md | New comprehensive migration guide for upgrading to new structure |
| DEVELOPER_SETUP.md | New developer onboarding documentation |
| example/* | Updated example app to demonstrate new initialization approach |
| example/ios/Runner/AppDelegate.swift | Added iOS notification center delegate configuration |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| _setupNotifications() async {} | ||
|
|
There was a problem hiding this comment.
The _setupNotifications method is now empty but still exists. Consider removing this method entirely since it serves no purpose.
| _setupNotifications() async {} |
| final data = DataPayload.fromJson(jsonDecode(message.payload!)); | ||
|
|
There was a problem hiding this comment.
Potential null pointer exception: If message.payload is null, this will crash with a null check error when trying to use the ! operator. Consider adding a null check before attempting to decode the payload.
| final data = DataPayload.fromJson(jsonDecode(message.payload!)); | |
| final payload = message.payload; | |
| if (payload == null) { | |
| return; | |
| } | |
| final data = DataPayload.fromJson(jsonDecode(payload)); |
| if #available(iOS 10.0, *) { | ||
| UNUserNotificationCenter.current().delegate = self as? UNUserNotificationCenterDelegate | ||
| } | ||
|
|
||
| func userNotificationCenter(_ center: UNUserNotificationCenter, willPresent notification: UNNotification, withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void) { | ||
| completionHandler([.alert, .badge, .sound]) | ||
| } |
There was a problem hiding this comment.
The indentation in the Swift code is inconsistent. Lines 11-16 have incorrect indentation, with the closing brace on line 12 and the function definition on lines 14-16 being nested inside the if statement when they should be at the class level. This will cause the userNotificationCenter method to be defined locally within the application method, which is incorrect.
| () async; | ||
| DitoSDK dito = DitoSDK(); | ||
| dito.initialize(apiKey: ditoApiKey, secretKey: ditoSecretKey); | ||
| await dito.initializePushNotificationService(); //está linha é necessário se for utilizar o serviço de push notification, aqui é feito o registro automático dos eventos de push; |
There was a problem hiding this comment.
Grammar error: "está" should be "esta" (without accent). The correct phrase is "esta linha é necessária".
| await dito.initializePushNotificationService(); //está linha é necessário se for utilizar o serviço de push notification, aqui é feito o registro automático dos eventos de push; | |
| await dito.initializePushNotificationService(); // esta linha é necessária se for utilizar o serviço de push notification, aqui é feito o registro automático dos eventos de push; |
| Future<http.Response> identifyUser() async; | ||
| DitoSDK dito = DitoSDK(); | ||
| dito.initialize(apiKey: ditoApiKey, secretKey: ditoSecretKey); | ||
| await dito.initializePushNotificationService(); //está linha é necessário se for utilizar o serviço de push notification, aqui é feito o registro automático dos eventos de push; |
There was a problem hiding this comment.
Grammar error: "está" should be "esta" (without accent). The correct phrase is "esta linha é necessária".
| await dito.initializePushNotificationService(); //está linha é necessário se for utilizar o serviço de push notification, aqui é feito o registro automático dos eventos de push; | |
| await dito.initializePushNotificationService(); // esta linha é necessária se for utilizar o serviço de push notification, aqui é feito o registro automático dos eventos de push; |
| import 'dart:async'; | ||
| import 'dart:convert'; | ||
| import 'dart:io'; | ||
| import 'dart:ui'; |
There was a problem hiding this comment.
The import 'dart:ui' is added but never used in this file. Consider removing this unused import to keep the codebase clean.
| import 'dart:ui'; |
- Introduced a new rules file for Flutter development best practices. - Updated notification service to improve event tracking and removed unused Android channel setup. - Streamlined notification handling by integrating data payload processing.
- Introduced a new 'identifier' field in the DataPayload class to enhance data structure. - Updated constructor and JSON serialization methods to accommodate the new field.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
O intuito desta Pull Request é aprimorar a push notification, modificando a estrutura de envio para o Android considerando o formato comum de um evento push, contendo a propriedade notification.
Com isso, todos os eventos esperados pela Dito já são emitidos automaticamente, sem a necessidade de intervenção via código, simplificando o uso da SDK.