Call UNUserNotificationCenter.current (). GetPendingNotificationRequests crashing on iPhone SE iOS 10.1.1

Call UNUserNotificationCenter getPendingNotificationRequests crash on iPhone SE using iOS 10.1.1.

This seems like an edge case - I confirmed that it works on iPhone 5 with the same version of iOS - 10.1.1. He crashed iOS on this iPhone 5s.

The โ€œfunnyโ€ thing is not only in the application crashing, but also in the fact that the springboard also crashes - we do not go to the main screen, but lock the screen (after watching the rotation animation for a few seconds). It seems that something inside iOS - on this iPhone SE - is broken ... itโ€™s possible that we did something wrong in our application, but it seems to UNUserNotificationCenter.current().getPendingNotificationRequests down to calling UNUserNotificationCenter.current().getPendingNotificationRequests . I think no one came across this? As I said, we have only seen this on this iPhone SE device so far, and we have probably used 10 or 20 other devices without problems.

In addition, this is usually printed in the debug console before the ski jumps fail:

[Common] Termination, since there is no system application.

I will continue to search for the culprit ... in the end, I can try updating the specified device to the latest version of iOS (10.3.1 atm) and see if everything works better.

Update 1:. This seems to be a bug in iOS, between 10.0 and 10.1 and can be fixed in iOS 10.2. I canโ€™t just update this iPhone SE yet, I think I may have to solve this problem ...

Update 2: Creating a new simple application that basically just calls UNUserNotificationCenter.current().getPendingNotificationRequests and runs it on iPhone SE, makes NO crash ... the plot thickens ... There may be some circumstances when I use UNUserNotificationCenter in my real application, which leads to its failure.

Update 3: For some reason, this is similar to the current application package identifier. If I changed it for our current application, the problem seems to go away. It is very strange. I have not yet confirmed whether this really works for the current application in its full state - currently I am deleting almost all other codes just by checking this notification line. It crashes even with this using our default bundle id. Update-in-update: It is confirmed that it is a full-featured WORKS application if I just change the package identifier. STRANGE. But even if it works right now, there is nothing saying that it will begin to crumble later. There should be no problem with our first package identifier. In the end, it's just a string. This is very likely a bug in iOS (which I knew about before, but just talking about). I have yet to find a workaround. The current policy is to support iOS 9 ... and at the same time, this application will most likely have several percent failures for users of iOS 10.0 ~ 10.1.

Update 4:. After several more tests, it turned out that the iPhone 5s on iOS 10.1.1 also leads to a crash of the application and the springboard in the same way. Not sure what happened before, someone else tested this device ...

Update 5 error: UNUserNotificationCenter.current().add() . I tried adding a notification before searching if it exists, but the add function also disables iOS. That was a good idea.

0
source share
1 answer

After much testing, I found a piece of code that seems to magically fix everything. Without further ado

 UNUserNotificationCenter.current.removeAllPendingNotificationRequests() 

Call the first launch of the application. It. However, this will require more testing, but it seems to be working now.

+1
source

Source: https://habr.com/ru/post/1012371/


All Articles