Skip to content

Commit

Permalink
bug/invertase#1109-invertase#1096-remote-onForegroundEvent-getInitial…
Browse files Browse the repository at this point in the history
…Notification
  • Loading branch information
LunatiqueCoder committed Oct 8, 2024
1 parent 75d494f commit 4d739c0
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 19 deletions.
19 changes: 12 additions & 7 deletions ios/NotifeeCore/NotifeeCore+NSNotificationCenter.m
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,18 @@ + (void)load {
#pragma mark Application Notifications

- (void)application_onDidFinishLaunchingNotification:(nonnull NSNotification *)notification {
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
UILocalNotification *launchNotification =
(UILocalNotification *)notification.userInfo[UIApplicationLaunchOptionsLocalNotificationKey];
[[NotifeeCoreUNUserNotificationCenter instance]
onDidFinishLaunchingNotification:launchNotification.userInfo];
[[NotifeeCoreUNUserNotificationCenter instance] getInitialNotification];
NSDictionary *notifUserInfo =
notification.userInfo[UIApplicationLaunchOptionsLocalNotificationKey];

if (!notifUserInfo) {
// Fallback to remote notification key if local notification key is not available
notifUserInfo = notification.userInfo[UIApplicationLaunchOptionsRemoteNotificationKey];
}

if (notifUserInfo) {
[[NotifeeCoreUNUserNotificationCenter instance] onDidFinishLaunchingNotification:notifUserInfo];
[[NotifeeCoreUNUserNotificationCenter instance] getInitialNotification];
}

[[NotifeeCoreUNUserNotificationCenter instance] observe];
}
Expand Down
15 changes: 3 additions & 12 deletions ios/NotifeeCore/NotifeeCore+UNUserNotificationCenter.m
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
#import "NotifeeCoreUtil.h"

@implementation NotifeeCoreUNUserNotificationCenter

struct {
unsigned int willPresentNotification : 1;
unsigned int didReceiveNotificationResponse : 1;
Expand Down Expand Up @@ -104,7 +103,6 @@ - (void)userNotificationCenter:(UNUserNotificationCenter *)center
NSDictionary *notifeeNotification =
notification.request.content.userInfo[kNotifeeUserInfoNotification];

// we only care about notifications created through notifee
if (notifeeNotification != nil) {
UNNotificationPresentationOptions presentationOptions = UNNotificationPresentationOptionNone;
NSDictionary *foregroundPresentationOptions =
Expand Down Expand Up @@ -148,23 +146,16 @@ - (void)userNotificationCenter:(UNUserNotificationCenter *)center
presentationOptions |= UNNotificationPresentationOptionAlert;
}

NSDictionary *notifeeTrigger = notification.request.content.userInfo[kNotifeeUserInfoTrigger];
if (notifeeTrigger != nil) {
// post DELIVERED event
[[NotifeeCoreDelegateHolder instance] didReceiveNotifeeCoreEvent:@{
// post DELIVERED event
[[NotifeeCoreDelegateHolder instance] didReceiveNotifeeCoreEvent:@{
@"type" : @(NotifeeCoreEventTypeDelivered),
@"detail" : @{
@"notification" : notifeeNotification,
}
}];
}
}];

completionHandler(presentationOptions);

} else if (_originalDelegate != nil && originalUNCDelegateRespondsTo.willPresentNotification) {
[_originalDelegate userNotificationCenter:center
willPresentNotification:notification
withCompletionHandler:completionHandler];
}
}

Expand Down

0 comments on commit 4d739c0

Please sign in to comment.