Skip to content

Commit

Permalink
bug/#1109-#1096-remote-onForegroundEvent-getInitialNotification - cal…
Browse files Browse the repository at this point in the history
…l onForegroundEvent() when app starts from terminated state - same as getInitialNotification()
  • Loading branch information
LunatiqueCoder committed Oct 8, 2024
1 parent 5d46de0 commit 08c0f47
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion ios/NotifeeCore/NotifeeCore+UNUserNotificationCenter.m
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,31 @@ - (void)onDidFinishLaunchingNotification:(nonnull NSDictionary *)notifUserInfo {

- (nullable NSDictionary *)getInitialNotification {
if (_initialNotificationGathered && _initialNotificationBlock != nil) {

// copying initial notification
if (_initialNotification != nil &&
[_initialNoticationID isEqualToString:_notificationOpenedAppID]) {
NSDictionary *initialNotificationCopy = [_initialNotification copy];

NSMutableDictionary *event = [NSMutableDictionary dictionary];
NSMutableDictionary *initialNotificationCopy = [_initialNotification mutableCopy];
initialNotificationCopy[@"initialNotification"] = @1;

_initialNotification = nil;

// Runs getInitialNotification() on JavaScript side with payload:
_initialNotificationBlock(nil, initialNotificationCopy);

// Prepare onForegroundEvent() payload
event[@"detail"] = [initialNotificationCopy copy];
if ([event[@"detail"][@"pressAction"][@"id"] isEqualToString:@"default"]) {
event[@"type"] = @1; // PRESS
} else {
event[@"type"] = @2; // ACTION_PRESS
}

// Call onForegroundEvent() on Javascript side with payload:
[[NotifeeCoreDelegateHolder instance] didReceiveNotifeeCoreEvent:event];

} else {
_initialNotificationBlock(nil, nil);
}
Expand Down

0 comments on commit 08c0f47

Please sign in to comment.