Skip to content

Feat new push notification approach#25

Open
igorgsduarte wants to merge 11 commits intomainfrom
feat/new-push-approach
Open

Feat new push notification approach#25
igorgsduarte wants to merge 11 commits intomainfrom
feat/new-push-approach

Conversation

@igorgsduarte
Copy link
Collaborator

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.

@igorgsduarte igorgsduarte self-assigned this May 22, 2025
- 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.
Copilot AI review requested due to automatic review settings January 12, 2026 20:50
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 onTap callback parameter and introducing an onClick property
  • Flattened DataPayload structure by removing the nested Details class 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.

Comment on lines 116 to 117
_setupNotifications() async {}

Copy link

Copilot AI Jan 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The _setupNotifications method is now empty but still exists. Consider removing this method entirely since it serves no purpose.

Suggested change
_setupNotifications() async {}

Copilot uses AI. Check for mistakes.
Comment on lines +127 to 128
final data = DataPayload.fromJson(jsonDecode(message.payload!));

Copy link

Copilot AI Jan 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
final data = DataPayload.fromJson(jsonDecode(message.payload!));
final payload = message.payload;
if (payload == null) {
return;
}
final data = DataPayload.fromJson(jsonDecode(payload));

Copilot uses AI. Check for mistakes.
Comment on lines +10 to +16
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])
}
Copy link

Copilot AI Jan 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
() 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;
Copy link

Copilot AI Jan 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Grammar error: "está" should be "esta" (without accent). The correct phrase is "esta linha é necessária".

Suggested change
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;

Copilot uses AI. Check for mistakes.
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;
Copy link

Copilot AI Jan 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Grammar error: "está" should be "esta" (without accent). The correct phrase is "esta linha é necessária".

Suggested change
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;

Copilot uses AI. Check for mistakes.
import 'dart:async';
import 'dart:convert';
import 'dart:io';
import 'dart:ui';
Copy link

Copilot AI Jan 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The import 'dart:ui' is added but never used in this file. Consider removing this unused import to keep the codebase clean.

Suggested change
import 'dart:ui';

Copilot uses AI. Check for mistakes.
igorgsduarte and others added 5 commits January 19, 2026 15:54
- 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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant