Speak now
Please Wait Image Converting Into Text...
Embark on a journey of knowledge! Take the quiz and earn valuable credits.
Challenge yourself and boost your learning! Start the quiz now to earn credits.
Unlock your potential! Begin the quiz, answer questions, and accumulate credits along the way.
General Tech Bugs & Fixes 2 years ago
Posted on 31 Aug 2022, this text provides information on Bugs & Fixes related to General Tech. Please note that while accuracy is prioritized, the data presented might not be entirely correct or up-to-date. This information is offered for general knowledge and informational purposes only, and should not be considered as a substitute for professional advice.
Turn Your Knowledge into Earnings.
I was following Apple docs and some other sources. But can't find the answer.
Problem is as follows:
Conditions:
Scenario:
It appears that in this case there's no way to receive notification contents upon application startup. Notification is not lost: it stays inside notification area until user clicks on it, but notification contents are not provided to the app upon app startup.
What did I try so far
I was able to get notification contents in every other scenario:
I have a handler
func userNotificationCenter( _ center: UNUserNotificationCenter, willPresent notification: UNNotification, withCompletionHandler <...>
for when the app is in foreground
When app is in background, the handler
func application( _ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable : Any], fetchCompletionHandler completionHandler: <...>
As a safeguard, I also loop through outstanding notifications like this:
func application( _ application: UIApplication, didFinishLaunchingWithOptions <...> { UNUserNotificationCenter.current() .getDeliveredNotifications { (notifications: [UNNotification]) -> Void in
And, in the same function I am checking if launchOptions contains any notifications.
launchOptions
With this combination it looks like I'm able to cover every single scenario, except for the case I outlined above. That is: when user clicks on app icon while app is not running after notification was delivered:
didReceiveRemoteNotification:fetchCompletionHandler
UNUserNotificationCenter.current().getDeliveredNotifications
didFinishLaunchingWithOptions
This article seems confirms this behavior, but doesn't provide any solution.
I also saw this question, but although it may be that acceptable solution for OP's needs, it does not provide a direct answer to his question, since using content-available flag changes how notification is delivered (see Configuring a Background Update Notification section on this page, and also reduces its priority, as explained in apns-priority section of this page.
content-available
apns-priority
BTW if I click on notification after opening the app, the behavior is as expected, so notification is not completely lost to the app, it's just not provided on its launch.
So what am I dealing with here? some edge case, bug or maybe such behavior is intended? if so, why?
Thanks in advance.
No matter what stage you're at in your education or career, TuteeHub will help you reach the next level that you're aiming for. Simply,Choose a subject/topic and get started in self-paced practice sessions to improve your knowledge and scores.
General Tech 9 Answers
General Tech 7 Answers
General Tech 3 Answers
General Tech 2 Answers
Ready to take your education and career to the next level? Register today and join our growing community of learners and professionals.