Skip to content

Commit

Permalink
Swift completion handler changed to show default notifications from a…
Browse files Browse the repository at this point in the history
…nother plugins.
  • Loading branch information
rafaelsetragni committed Dec 8, 2021
1 parent af21bab commit 001599c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 11 deletions.
5 changes: 1 addition & 4 deletions .idea/workspace.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 13 additions & 7 deletions ios/Classes/lib/SwiftAwesomeNotificationsPlugin.swift
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,17 @@ public class SwiftAwesomeNotificationsPlugin: NSObject, FlutterPlugin, UNUserNot
jsonData: jsonData,
buttonKeyPressed: response.actionIdentifier,
userText: userText,
completionHandler: completionHandler
withCompletionHandler: completionHandler
)
} else {
print("Received an invalid notification content")
}

if _originalNotificationCenterDelegate?.userNotificationCenter?(center, didReceive: response, withCompletionHandler: completionHandler) == nil {
completionHandler()

if _originalNotificationCenterDelegate != nil {
_originalNotificationCenterDelegate?.userNotificationCenter?(center, didReceive: response, withCompletionHandler: completionHandler)
}
else {
completionHandler()
}
}
}

Expand All @@ -60,7 +63,10 @@ public class SwiftAwesomeNotificationsPlugin: NSObject, FlutterPlugin, UNUserNot
if !receiveNotification(content: notification.request.content, withCompletionHandler: completionHandler) {
// completionHandler was *not* called, so maybe this notification is for another plugin:

if _originalNotificationCenterDelegate?.userNotificationCenter?(center, willPresent: notification, withCompletionHandler: completionHandler) == nil {
if _originalNotificationCenterDelegate != nil {
_originalNotificationCenterDelegate?.userNotificationCenter?(center, willPresent: notification, withCompletionHandler: completionHandler)
}
else {
completionHandler([.alert, .badge, .sound])
}
}
Expand Down Expand Up @@ -319,7 +325,7 @@ public class SwiftAwesomeNotificationsPlugin: NSObject, FlutterPlugin, UNUserNot
}

#if !ACTION_EXTENSION
private func receiveAction(jsonData: String?, buttonKeyPressed:String?, userText:String?, withCompletionHandler: completionHandler){
private func receiveAction(jsonData: String?, buttonKeyPressed:String?, userText:String?, withCompletionHandler completionHandler: @escaping () -> Void){

if(SwiftAwesomeNotificationsPlugin.appLifeCycle == .AppKilled){
fireBackgroundLostEvents()
Expand Down

0 comments on commit 001599c

Please sign in to comment.