-
Notifications
You must be signed in to change notification settings - Fork 264
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
[Bug]: ~30s delays displaying push notifications when using OneSignalExtension.didReceiveNotificationExtensionRequest #1425
Comments
@johnmalatras Thank you for reaching out we will investigate. In order for debug logs to show up you must debug the NotificationServiceExtension target rather than the app target. The easiest way to do this is to start debugging the app and send the device a notification. Then go to "Debug" -> "Attach to Process" -> "OneSignalNotificationServiceExtension". Now you can send more notifications to the device and should get debug logs/breakpoints enabled. If you need to get logs from the first push a device receives you can also use Mac's Console app to search for the logs. |
Hi, I've been debugging the NotificationServiceExtension target without issue. That's how I pinpointed that The logging issue I mentioned is specifically around getting the OneSignal SDK to output verbose logging in the extension. The documentation mentions setting Line 146 in 5e3d8e4
|
Ah I see the issue is that the OneSignal class is likely not available in the notification service extension so you can use |
The issue appears to be that the random delay for sending confirmed deliveries is run on the main thread which could be blocking delivery of subsequent notifications to the NSE until the delay has ended. However, I am not able to reproduce this behavior. I added logging before and after OneSignal processes the notification send and this was my result sending 3 notifications subsequently:
Each notification was delivered immediately regardless of the delay in confirmed delivery processing. |
Are you displaying these as a communication notifications in the extension? To be clear they're delivered immediately for us too when it's a plain notification. The delays only occur for communication notifications (aka notifications where we update the contents with |
@johnmalatras I am still not able to reproduce using the below (objective-c not swift)
|
Weird. The only notable differences I see are that:
|
@johnmalatras Does |
@emawby If the call is outside of the intent donation completion block then the notification isn't rendered as a communication notification |
@johnmalatras Instead of calling it inside the completion can you await on the donation and then call it afterwards like they do in the documentation here? |
Interesting, I actually don't see an async version of |
I am still working in Objective-C, but it works for me if I mock await behavior using dispatch semaphores. This allowed me to make sure the interaction was donated and still have notifications delivered immediately. You can try something similar in Swift as a workaround. The issue is that in order to have a random delay for confirmed deliveries we need to keep the process alive. To do this we are waiting on a dispatch_semaphore after submitting the notification content to the handler. It looks like doing this while in the completion block hangs the entire service extension process. We will look for other ways to get the desired behavior.
|
@emawby I have what I believe should be similar semaphore functionality in Swift but still no cigar; doesn't fix the delay:
|
Interesting your code works for me in Swift, and I am able to reproduce the issue without the semaphore. The only thing I changed was removing the analytics error tracking code and the bodyOverride code. |
@johnmalatras Fixing this issue for communication notifications will likely require an update to the SDK's public interface to either separate the confirmed delivery call from the notification processing, or marking a notification as a communication notification which I don't believe we can detect automatically today. However the option we go with is somewhat dependent on whether or not the dispatch semaphore workaround noted above works for all cases. If you were never able to get that to work please let me know! |
Sorry for the delayed follow up @emawby - we had a potential fix out yet and wanted to let it bake for a bit to ensure nothing was unexpectedly going wrong. We were indeed able to fix with a conceptually similar solution to what you proposed. Directly using a semaphore didn't work but running our |
What happened?
We've been trying to debug some sort of delay or throttling of our push notifications that occurs when a user gets > 1 communication notification in a row. The first one arrives instantly and then each one after arrives about 30 seconds after the last. After debugging through, it seems that this function call:
causes the hang. If I directly call
contentHandler?(bestAttemptContent)
instead the notifications all show instantly.I've tried to debug further by setting a verbose log level but
OneSignal.Debug.setLogLevel(.LL_VERBOSE)
doesn't appear to be available inOneSignalExtension
. Also,serviceExtensionTimeWillExpire
is not hit at any point.Steps to reproduce?
What did you expect to happen?
Push notifications are displayed as soon as they're received.
OneSignal iOS SDK version
3.12.7
iOS version
17
Specific iOS version
Relevant log output
No response
Code of Conduct
The text was updated successfully, but these errors were encountered: