Skip to content

Commit

Permalink
fix(ios): forceShow to display toast but trigger event until tapped
Browse files Browse the repository at this point in the history
  • Loading branch information
erisu committed Dec 17, 2024
1 parent b230703 commit c87a4a7
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/ios/PushPlugin.m
Original file line number Diff line number Diff line change
Expand Up @@ -384,13 +384,15 @@ - (void)willPresentNotification:(NSNotification *)notification {

self.notificationMessage = [modifiedUserInfo copy];
self.isInline = YES;
[self notificationReceived];

UNNotificationPresentationOptions presentationOption = UNNotificationPresentationOptionNone;
if (@available(iOS 10, *)) {
if(self.forceShow) {

if(self.forceShow) {
if (@available(iOS 10, *)) {
presentationOption = UNNotificationPresentationOptionAlert;
}
} else {
[self notificationReceived];
}

if (completionHandler) {
Expand Down Expand Up @@ -489,11 +491,9 @@ - (void)notificationReceived {
NSMutableDictionary* message = [NSMutableDictionary dictionaryWithCapacity:4];
NSMutableDictionary* additionalData = [NSMutableDictionary dictionaryWithCapacity:4];

// Remove "actionCallback" when application state is not foreground. Only applied to foreground.
NSNumber *applicationStateNumber = mutableNotificationMessage[@"applicationState"];
UIApplicationState applicationState = (UIApplicationState)[applicationStateNumber intValue];
if (applicationState != UIApplicationStateActive
&& [[mutableNotificationMessage objectForKey:@"actionCallback"] isEqualToString:UNNotificationDefaultActionIdentifier]) {
// Exclude "UNNotificationDefaultActionIdentifier" from "actionCallback" as it is platform-specific.
// Use the default "notification" callback or a custom-defined callback instead.
if ([[mutableNotificationMessage objectForKey:@"actionCallback"] isEqualToString:UNNotificationDefaultActionIdentifier]) {
[mutableNotificationMessage removeObjectForKey:@"actionCallback"];
}
// @todo do not sent applicationState data to front for now. Figure out if we can add
Expand Down

0 comments on commit c87a4a7

Please sign in to comment.