Skip to content

Commit

Permalink
fix(messaging): retain all events until consumed
Browse files Browse the repository at this point in the history
It should behave the same as under Android.
  • Loading branch information
robingenz committed Oct 1, 2022
1 parent 5092564 commit a6a0720
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
5 changes: 5 additions & 0 deletions .changeset/unlucky-eagles-travel.md
@@ -0,0 +1,5 @@
---
"@capacitor-firebase/messaging": patch
---

fix(ios): retain all events until consumed
8 changes: 4 additions & 4 deletions packages/messaging/ios/Plugin/FirebaseMessagingPlugin.swift
Expand Up @@ -144,21 +144,21 @@ public class FirebaseMessagingPlugin: CAPPlugin {
func handleTokenReceived(token: String?) {
var result = JSObject()
result["token"] = token
notifyListeners(tokenReceivedEvent, data: result)
notifyListeners(tokenReceivedEvent, data: result, retainUntilConsumed: true)
}

func handleNotificationReceived(notification: UNNotification) {
let notificationResult = FirebaseMessagingHelper.createNotificationResult(notification: notification)
var result = JSObject()
result["notification"] = notificationResult
notifyListeners(notificationReceivedEvent, data: result)
notifyListeners(notificationReceivedEvent, data: result, retainUntilConsumed: true)
}

func handleRemoteNotificationReceived(notification: NSNotification) {
let notificationResult = FirebaseMessagingHelper.createNotificationResult(notification: notification)
var result = JSObject()
result["notification"] = notificationResult
notifyListeners(notificationReceivedEvent, data: result)
notifyListeners(notificationReceivedEvent, data: result, retainUntilConsumed: true)
}

func handleNotificationActionPerformed(response: UNNotificationResponse) {
Expand All @@ -175,7 +175,7 @@ public class FirebaseMessagingPlugin: CAPPlugin {
if let inputType = response as? UNTextInputNotificationResponse {
result["inputValue"] = inputType.userText
}
notifyListeners(notificationActionPerformedEvent, data: result)
notifyListeners(notificationActionPerformedEvent, data: result, retainUntilConsumed: true)
}

@objc private func didRegisterForRemoteNotifications(notification: NSNotification) {
Expand Down

0 comments on commit a6a0720

Please sign in to comment.