Skip to content

Commit

Permalink
[NOT-3059] background state
Browse files Browse the repository at this point in the history
  • Loading branch information
anamachadoldo committed Jun 25, 2024
1 parent 2296888 commit 1395ec8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
5 changes: 5 additions & 0 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ Future<void> _firebaseMessagingBackgroundHandler(RemoteMessage message) async {
DitoSDK dito = DitoSDK();
dito.onBackgroundMessageHandler(message,
apiKey: Constants.ditoApiKey, secretKey: Constants.ditoSecretKey);
dito.setOnMessageClick((data) {
print('app is in a terminated or background state');
print(data.toJson());
});
}

void main() async {
Expand All @@ -22,6 +26,7 @@ void main() async {
apiKey: Constants.ditoApiKey, secretKey: Constants.ditoSecretKey);
await dito.initializePushNotificationService();
dito.setOnMessageClick((data) {
print('app is open');
print(data.toJson());
});

Expand Down
4 changes: 1 addition & 3 deletions package/lib/dito_sdk.dart
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,7 @@ class DitoSDK {
/// This method is a handler for manage messages in the background.
/// It initializes Firebase and Dito, then push the message.
Future<void> onBackgroundMessageHandler(RemoteMessage message,
{required String apiKey,
required String secretKey,
Function(DataPayload)? onMessageClicked}) async {
{required String apiKey, required String secretKey}) async {
_api.setKeys(apiKey, secretKey);
await Firebase.initializeApp();
await _notificationInterface.initialize();
Expand Down

0 comments on commit 1395ec8

Please sign in to comment.