Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

iOS-FCM-Foreground-not-working-fixes #47

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

ashutosh2014
Copy link

@ashutosh2014 ashutosh2014 commented Jan 28, 2025

fixes #39

@ashutosh2014
Copy link
Author

@alamin-karno, Please look into this.

@alamin-karno alamin-karno self-requested a review January 28, 2025 12:12
@alamin-karno alamin-karno added the bug Something isn't working label Jan 28, 2025
@@ -124,17 +124,27 @@ public class SwiftFlutterCrispChatPlugin: NSObject, FlutterPlugin, UIApplication
completionHandler([.alert, .sound])
}
} else {
completionHandler([])
// Notify Flutter or rethrow to allow other handlers to process the notification
channel?.invokeMethod("onNotificationReceived", arguments: notification.request.content.userInfo)
Copy link
Owner

Choose a reason for hiding this comment

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

Can you explain this onNotificationReceived channel? from where this is receiving in this package? Because I didn't create this channel.

Copy link
Author

Choose a reason for hiding this comment

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

The onNotificationReceived channel is part of the FlutterMethodChannel created in the register(with:) method of your iOS plugin, with the name "flutter_crisp_chat". This method channel enables communication between the native iOS code and the Dart side of your Flutter app. When a non-Crisp notification is received or tapped, the iOS plugin uses channel?.invokeMethod to invoke a method (onNotificationReceived in this case) on the Dart side, passing the notification data for further handling in Flutter. If you haven't explicitly implemented handling for this method on the Dart side, it must be added to process these events.

Copy link
Owner

Choose a reason for hiding this comment

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

Okay, I need to test if it is working fine then I will add this changes on next update!!

public func userNotificationCenter(_ center: UNUserNotificationCenter,
didReceive response: UNNotificationResponse,
withCompletionHandler completionHandler: @escaping () -> Void) {
let notification = response.notification
if CrispSDK.isCrispPushNotification(notification) {
CrispSDK.handlePushNotification(notification)
} else {
// Notify Flutter about the interaction or rethrow for further processing
channel?.invokeMethod("onNotificationTapped", arguments: response.notification.request.content.userInfo)
Copy link
Owner

Choose a reason for hiding this comment

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

Can you explain this onNotificationTapped channel? from where this is receiving in this package? Because I didn't create this channel.

Copy link
Author

Choose a reason for hiding this comment

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

same for onNotificationTapped

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

iOS FCM Foreground not working in ^2.2.2
2 participants