Push notifications stored on iOS notification center being deleted

HI!

Some time ago we asked this question for ios 5.6 [Content removed] As some changes were done in the engine side, we waited for the 5.7 update to check this issue again.

The behaviour depicted in the previous question is the same in 5.7, but we have went a little bit further in order to identify what is happening behind the scenes.

First, we have push notificaitons on the project configured for iOS as it follows, having enabled the settings “Enable Remote Notifications Support” and “Enable Background Fetch”.

When the app is closed, if we send a push notification with the following payload, the push notifications are stored in the notification center. When we open the app using the push, it’s processed, and the rest are still kept on the notification center.

{"aps":{"alert":{"subtitle":"subtitle","body":"body","title":"No badge"}}}Then, if we send a push with the next payload, the notifications are still kept on the notifications center, but when we open the app using any of the notifications, they’re all deleted from the notification center.

{"aps":{"alert":{"subtitle":"subtitle","body":"body","title":"badge one"},"badge":1}}Also, if we have notifications stored in the notifications center, if we send a push with the following payload, all the notifications are deleted, as the app is opened in background and the push is processed, because the “content-available” flag is set

{"aps":{"alert":{"subtitle":"subtitle","body":"body","title":"content test"},"content-available":1,"badge":1}}But if instead, we send the following, the notifications are still kept.

{"aps":{"alert":{"subtitle":"subtitle","body":"body","title":"content test"},"content-available":1}}

So, we think, at somepoint, the push notifications are being deleted after the app is opened and somehow it’s related to having the badge number set.

Regards.

[Attachment Removed]

Steps to Reproduce
Project for iOs.

In the project configuration:

“Enable Remote notification support” enabled

“Enable Background Fetch” enabled

[Attachment Removed]

Hi!

I went a little bit deeper and found this:

The file

Source/Runtime/Launch/Private/IOS/LaunchIOS.cpp,

the method

void FAppEntry::PreInit(IOSAppDelegate* AppDelegate, UIApplication* Application)

contains the following piece of code

#if !PLATFORM_TVOS
	// reset badge count on launch
	// Deprecated iOS17 - suppress warning if deployment target	> iOS17
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
	Application.applicationIconBadgeNumber = 0;
#pragma clang diagnostic pop
#endif

We have performed some tests, and when we remove the line

Application.applicatonIconBadgeNumber = 0;or we sets the Badge number to a different value, the notifications stored in the notification center are kept.

So this makes me wonder if there is any observer in any library or something similar that erases all the notifications from the ios notification center when the badge number is set to 0, as this is not the behaviour we need or expect on the app side.

Regards.

[Attachment Removed]

Hi Emilio,

This is likely iOS internal behaviour.

Does setting:

Application.applicatonIconBadgeNumber = -1;properly clear the badge count while keeping the notifications in the notification center?

Alternatively:

[[UNUserNotificationCenter currentNotificationCenter] setBadgeCount:0 withCompletionHandler:nil];may resolve as well.

Let us know if either of these two workarounds gets the desired behaviour.

Best regards.

[Attachment Removed]

HI!

Both methods solves the issue, but I think, after reading the Apple documentation, the second one is more suitable as, the first one is already deprecated. Can this fixed for newer versions of the engine?

Also, I’ve noticed the issue with the notifications being deleted also happens with local notifications.

Regards.

[Attachment Removed]

Hi Emilio, thanks for confirming! I’ll look at getting that into the main Engine release.

Best regards.

[Attachment Removed]

Thanks!

Any clue for which version of the Engine?

Regards.

[Attachment Removed]

Hi Emilio,

This will be in 5.8. However, you can integrate 50727844

Best regards.

[Attachment Removed]