自2017年11月起,我有一个iOS(swift)应用程序可用AppStore.我添加了Firebase Analytics和Crashlytics,以主动查看在开发和测试期间未发生的问题.
我目前正在努力使用以下Stacktrace,我在Firebase Crashlytics Dashboard中多次使用:
来自Firebase的Stacktrace
致命异常:NSInternalInconsistencyException此请求已被绝育 - 您不能调用-sendResponse:两次,也不能在编码后
Fatal Exception: NSInternalInconsistencyException
0 CoreFoundation 0x1ac20bef8 __exceptionPreprocess
1 libobjc.A.dylib 0x1ab3d9a40 objc_exception_throw
2 CoreFoundation 0x1ac12006c +[_CFXNotificationTokenRegistration keyCallbacks]
3 Foundation 0x1acc0c3e0 -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:]
4 BaseBoard 0x1aea6cd68 __40-[BSAction sendResponse:withCompletion:]_block_invoke
5 libdispatch.dylib 0x1abc44484 _dispatch_client_callout
6 libdispatch.dylib 0x1abc24754 _dispatch_lane_barrier_sync_invoke_and_complete
7 BaseBoard 0x1aea20c60 -[BSAction sendResponse:withCompletion:]
8 UIKitCore 0x1d8c20698 -[UIHandleRemoteNotificationAction sendResponse:]
9 UIKitCore 0x1d9054d3c __91-[UIApplication _handleNonLaunchSpecificActions:forScene:withTransitionContext:completion:]_block_invoke_3.2891
10 libdispatch.dylib 0x1abc436c8 _dispatch_call_block_and_release
11 libdispatch.dylib 0x1abc44484 _dispatch_client_callout
12 libdispatch.dylib 0x1abc23b44 _dispatch_main_queue_callback_4CF$VARIANT$armv81
13 CoreFoundation 0x1ac19a1bc __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__
14 CoreFoundation 0x1ac195084 __CFRunLoopRun
15 CoreFoundation …
Run Code Online (Sandbox Code Playgroud) 我希望iOS11版本能解决无声推送问题,这是最新的测试版和通用版iOS版.
目前我很难理解,为什么我没有收到任何静音推送消息,这实际上应该唤醒我的应用程序以在后台执行一些所需的任务.
在iOS 10中,我只使用后台获取功能,并在我的AppDelegate中实现了"唤醒代码",如下面的代码所示.
在iOS 11中,注册代码仍然正常工作,我的后端也向Apples DEV服务器(沙箱)和PROD服务器(生产版本)提供推送通知.不幸的func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable : Any], fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void)
是,静音推送通知从不调用该函数.
我真的错过了iOS 11的东西吗?
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
// .. some variables here ...
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
// register silent push notification in backend
application.registerForRemoteNotifications()
// ... some code here ...
// Set Background Fetch Intervall for background services / terminated app
UIApplication.shared.setMinimumBackgroundFetchInterval(UIApplicationBackgroundFetchIntervalMinimum)
// ... some code here ... …
Run Code Online (Sandbox Code Playgroud) 我刚注意到我的键盘高度识别码不再适用于iOS11.
对于iOS10设备,我使用此逻辑来检测,如果键盘将隐藏特定的输入字段(在我的情况下是文本字段).如果是这种情况,键盘将显示在最后一个活动文本字段下,以使用户能够正确输入.
对于iOS 11,键盘高度的识别不起作用.
键盘的助手类示例willAppear逻辑 这里只是keyBoardWillShow所做的一个例子 - >它只是检查,如果视图需要在键盘上方移动,如果键盘将隐藏文本字段.
我做了一些调试,发现下面的代码行在iOS 10和iOS 11之间的工作方式不同:
if let keyboardSize = (notification.userInfo?[UIKeyboardFrameBeginUserInfoKey] as? NSValue)?.cgRectValue
Run Code Online (Sandbox Code Playgroud)
iOS10调试器输出
keyboardSize CGRect(origin =(x = 0,y = 568),size =(width = 320,height = 216))
iOS11调试器输出
keyboardSize CGRect(origin =(x = 0,y = 568),size =(width = 320,height = 0))
下面你可以看到完整的代码 - 它一直工作到iOS 10.3
func keyboardWillShow(notification: NSNotification, view: UIView, activeTextField: UITextField?, scrollView: UIScrollView?) {
if let keyboardSize = (notification.userInfo?[UIKeyboardFrameBeginUserInfoKey] as? NSValue)?.cgRectValue {
if view.frame.origin.y == 0{
var aRect : CGRect = (view.viewWithTag(2)?.frame)!
aRect.size.height -= …
Run Code Online (Sandbox Code Playgroud) 我根据编辑时的UITextView
光标位置有一个tableView的自动滚动功能cell
.
它适用于以前的iOS版本.从iOS11开始它就坏了.
我已tableView
contentInset
根据键盘高度设置了.使用以下代码进行自动滚动textViewDidChange
if let confirmedTextViewCursorPosition = textView.selectedTextRange?.end {
let caretPosition = textView.caretRect(for: confirmedTextViewCursorPosition)
var textViewActualPosition = tableView.convert(caretPosition, from: textView.superview?.superview)
textViewActualPosition.origin.y += 22.0
tableView.scrollRectToVisible(textViewActualPosition, animated: false)
}
Run Code Online (Sandbox Code Playgroud)