在iPhone SE iOS 10.1.1上调用UNUserNotificationCenter.current().getPendingNotificationRequests崩​​溃 [英] Calling UNUserNotificationCenter.current().getPendingNotificationRequests crashes on iPhone SE iOS 10.1.1

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

问题描述

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

这似乎是个极端案例-我已经确认这可以在具有相同iOS版本(10.1.1)的iPhone 5s上使用.它也使该iPhone 5s上的iOS崩溃.

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

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

[通用]由于没有系统应用程序而终止.

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

更新1:这似乎是iOS中的错误,介于10.0和10.1之间,可能已在iOS 10.2中修复.我不能只更新这个iPhone SE,我想我可能必须解决这个问题...

更新2:制作一个基本上只调用 UNUserNotificationCenter.current().getPendingNotificationRequests 的新简单应用程序,然后在iPhone SE上运行它不会导致崩溃...地块变厚...在某些情况下,我可能会在实际应用中使用UNUserNotificationCenter,这会使它崩溃.

更新3:出于某种原因,它似乎与当前的应用捆绑包标识符有关.如果我为当前的应用程序更改它,问题似乎就消失了.这很奇怪.我尚未确认这是否真正适用于当前应用程序的完整状态-我目前已删除了几乎所有其他代码,仅测试了此通知行.使用我们的默认捆绑包标识符,即使这样,它也会崩溃.更新内更新:确认如果我仅更改捆绑包标识符,成熟的应用程序将起作用.奇怪的.但是即使它现在可以正常工作,也没有任何消息说它将在以后崩溃.我们的第一个捆绑包标识符应该没有问题.毕竟,这只是一个字符串.这很可能是iOS中的一个错误(我之前知道,但是只是说了一下).我还没有找到解决方法.当前的政策是支持iOS 9 ...,与此相关的是,此应用对于iOS 10.0〜10.1用户的崩溃率很可能会达到百分之几.

更新4:经过更多测试,结果发现iOS 10.1.1上的iPhone 5s也以完全相同的方式使应用程序和跳板崩溃.不知道之前发生了什么,其他人正在此设备上进行测试...

更新5: UNUserNotificationCenter.current().add()也崩溃了.在尝试查看是否存在通知之前,我尝试添加通知,但是add函数也会导致iOS崩溃.这是个好主意.

解决方案

经过大量测试,我发现一段代码似乎可以神奇地修复所有问题.事不宜迟

  UNUserNotificationCenter.current.removeAllPendingNotificationRequests() 

在首次启动应用程序时调用它.就是这样.但是,它需要更多的测试,但似乎可以正常工作.

Call UNUserNotificationCenter getPendingNotificationRequests crashes on iPhone SE using iOS 10.1.1.

This seems like an edge case - I have confirmed this works on an iPhone 5s with the same iOS version - 10.1.1. 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:

[Common] Terminating since there is no system app.

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崩​​溃的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆