Skip to content

Commit

Permalink
fix(ios): correctly set foreground flag when forceShow is enabled
Browse files Browse the repository at this point in the history
  • Loading branch information
erisu committed Dec 25, 2024
1 parent abc5225 commit c838e0a
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions src/ios/PushPlugin.m
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ @interface PushPlugin ()
@property (nonatomic, strong) UNNotification *previousNotification;

@property (nonatomic, assign) BOOL isInitialized;
@property (nonatomic, assign) BOOL isInline;
@property (nonatomic, assign) BOOL isForeground;
@property (nonatomic, assign) BOOL clearBadge;
@property (nonatomic, assign) BOOL forceShow;
@property (nonatomic, assign) BOOL coldstart;
Expand Down Expand Up @@ -161,7 +161,7 @@ - (void)init:(CDVInvokedUrlCommand *)command {

[self.commandDelegate runInBackground:^ {
NSLog(@"[PushPlugin] register called");
self.isInline = NO;
self.isForeground = NO;
self.forceShow = [settings forceShowEnabled];
self.clearBadge = [settings clearBadgeEnabled];
if (self.clearBadge) {
Expand Down Expand Up @@ -309,7 +309,7 @@ - (void)didReceiveRemoteNotification:(NSNotification *)notification {
NSLog(@"[PushPlugin] Stored the completion handler for the background processing of notId %@", notIdKey);

self.notificationMessage = [mutableUserInfo copy];
self.isInline = NO;
self.isForeground = NO;
[self notificationReceived];
} else {
NSLog(@"[PushPlugin] Application is not active, saving notification for later.");
Expand Down Expand Up @@ -388,7 +388,7 @@ - (void)willPresentNotification:(NSNotification *)notification {
}

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

UNNotificationPresentationOptions presentationOption = UNNotificationPresentationOptionNone;

Expand Down Expand Up @@ -427,7 +427,7 @@ - (void)didReceiveNotificationResponse:(NSNotification *)notification {
{
NSLog(@"[PushPlugin] App is active. Notification message set with: %@", modifiedUserInfo);

self.isInline = NO;
self.isForeground = YES;
self.notificationMessage = [modifiedUserInfo copy];
[self notificationReceived];
if (completionHandler) {
Expand All @@ -440,6 +440,7 @@ - (void)didReceiveNotificationResponse:(NSNotification *)notification {
NSLog(@"[PushPlugin] App is inactive. Storing notification message for later launch with: %@", modifiedUserInfo);

self.coldstart = YES;
self.isForeground = NO;
self.launchNotification = [modifiedUserInfo copy];
if (completionHandler) {
completionHandler();
Expand Down Expand Up @@ -478,7 +479,7 @@ - (void)didReceiveNotificationResponse:(NSNotification *)notification {

NSLog(@"[PushPlugin] Stored the completion handler for the background processing of notId %@", notIdKey);

self.isInline = NO;
self.isForeground = NO;
self.notificationMessage = [modifiedUserInfo copy];

[self performSelectorOnMainThread:@selector(notificationReceived) withObject:self waitUntilDone:NO];
Expand Down Expand Up @@ -547,7 +548,7 @@ - (void)notificationReceived {
}
}

if (self.isInline) {
if (self.isForeground) {
[additionalData setObject:[NSNumber numberWithBool:YES] forKey:@"foreground"];
} else {
[additionalData setObject:[NSNumber numberWithBool:NO] forKey:@"foreground"];
Expand All @@ -567,7 +568,7 @@ - (void)notificationReceived {
[self.commandDelegate sendPluginResult:pluginResult callbackId:self.callbackId];

self.coldstart = NO;
self.isInline = NO;
self.isForeground = NO;
self.notificationMessage = nil;
}
}
Expand Down

0 comments on commit c838e0a

Please sign in to comment.