Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(ios): correctly set foreground flag when forceShow is enabled #338

Merged
merged 1 commit into from
Dec 26, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading