本文介绍了在iPhone SE iOS 10.1.1上调用UNUserNotificationCenter.current().getPendingNotificationRequests崩​​溃的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在使用iOS 10.1.1的iPhone SE上,调用UNUserNotificationCenter getPendingNotificationRequests崩​​溃.

这似乎是个极端案例-它也使该iPhone 5s上的iOS崩溃.

有趣"的事情不仅会导致应用程序崩溃,而且似乎跳板也会崩溃-我们不是发送到主屏幕,而是锁定屏幕(在看到旋转的动画几秒钟后).似乎iOS内的某些内容(在此iPhone SE上已损坏)...我们的应用程序可能做错了什么,但这似乎可以归结为对 UNUserNotificationCenter.current()的确切调用.getPendingNotificationRequests .我猜没有人碰到这个吗?就像我说的那样,到目前为止,我们仅在这台iPhone SE设备上看到了这一点,并且大概使用了10s或20s的其他设备也没问题.

此外,这通常在跳板崩溃之前在调试控制台中打印:

我将继续寻找罪魁祸首...最后,我可能会尝试将所述设备更新到最新的iOS(10.3.1 atm),看看效果是否更好.

It crashed iOS on that iPhone 5s too.

The "funny" thing is not only does the app crash, it seems like springboard also crashes - we are not sent to home screen, but to lock screen (after seeing the spinning animation for a few seconds). It seems like something inside of iOS - on this iPhone SE - is broken... it is possible that we did something wrong in our app, but it seems to boil down to the exact call to UNUserNotificationCenter.current().getPendingNotificationRequests. I guess no one ran into this? As I said, we've only seen this on this one iPhone SE device so far, and we have used probably 10s or 20s of other devices with no problem.

Also, this is normally printed in the debug console before springboard crashes:

I'll continue looking for the culprit... in the end I might try updating said device to latest iOS (10.3.1 atm) and see if things work better.

Update 1: It seems to be a bug in iOS, between 10.0 and 10.1, and might be fixed in iOS 10.2. I can't just update this iPhone SE just yet, I guess I might have to workaround the problem...

Update 2: Making a new simple app that basically just calls UNUserNotificationCenter.current().getPendingNotificationRequests and running it on the iPhone SE renders NO crash... the plot thickens... There might be some circumstance where I am using UNUserNotificationCenter in my real app which makes it crash.

Update 3: For some reason, it seems to be related to the current app bundle identifier. If I change it for our current app, the problem seems to go away. This is very weird. I have yet to confirm if this really works for the current app in its full state - I have currently removed almost all other code, just testing this notification line. It crashes even with that, using our default bundle identifier. Update-within-update: Confirmed that the full-blown app WORKS if I just change the bundle identifier. STRANGE. But even if it works right now, there is nothing saying that it will start crashing later on. There should be no problem with our first bundle identifier. It's just a string, after all. This is very very likely a bug within iOS (which I knew before, but just sayin). I have yet to find a workaround. Current policy is to support iOS 9... and with that, this app will most likely have a few percent crashes for iOS 10.0~10.1 users.

Update 4: After some more testing it turned out that the iPhone 5s on iOS 10.1.1 also crashes the app and springboard in the exact same way. Not sure what happened earlier, someone else was testing on this device...

Update 5: UNUserNotificationCenter.current().add() crashes too. I tried adding a notification before looking if any existed, but the add function also crashes iOS. It was a good idea.

解决方案

After a lot of testing I found a piece of code that seem to magically fix everything. Without further ado

UNUserNotificationCenter.current.removeAllPendingNotificationRequests()

Call this at first launch of app. That's it. It will need more testing however, but seems to work for now.

这篇关于在iPhone SE iOS 10.1.1上调用UNUserNotificationCenter.current().getPendingNotificationRequests崩​​溃的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-04 15:05
查看更多