我已经将OS_ACTIVITY_MODE设置为禁用,但在迁移到Xcode 9后,会出现一些不需要的日志,如下所示。
编辑:我已经提到Hide strange unwanted Xcode logs,但在Xcode 9中对我不起作用。
=============================================== ================== 主线程检查器:在后台线程上调用UI API: - [UIApplication registerForRemoteNotifications] PID:1303,TID:27861,线程名称:(无),队列名称:com.apple.usernotifications.UNUserNotificationServiceConnection.call-out,QoS:0 回溯: 4 N-Gal 0x000000010b058211 _T05N_Gal11AppDelegateC29registerForRemoteNotificationyyFySb_s5Error_pSgtcfU_ + 193 5 N-Gal 0x000000010b0574d3 _T0Sbs5Error_pSgIxyx_SbSo7NSErrorCSgIyByy_TR + 115 6 libdispatch.dylib 0x0000000111a4c3f7 _dispatch_call_block_and_release + 12 7 libdispatch.dylib 0x0000000111a4d43c _dispatch_client_callout + 8 8 libdispatch.dylib 0x0000000111a5595b _dispatch_queue_serial_drain + 1162 9 libdispatch.dylib 0x0000000111a562df _dispatch_queue_invoke + 336 10 libdispatch.dylib 0x0000000111a5207d _dispatch_queue_override_invoke + 733 11 libdispatch.dylib 0x0000000111a591f9 _dispatch_root_queue_drain + 772 12 libdispatch.dylib 0x0000000111a58e97 _dispatch_worker_thread3 + 132 13 libsystem_pthread.dylib 0x0000000111f141ca _pthread_wqthread + 1387 14 libsystem_pthread.dylib 0x0000000111f13c4d start_wqthread + 13 无法注册:错误域= NSCocoaErrorDomain代码= 3010“模拟器中不支持远程通知”UserInfo = {NSLocalizedDescription =模拟器中不支持远程通知} 无法注册:错误域= NSCocoaErrorDomain代码= 3010“模拟器中不支持远程通知”UserInfo = {NSLocalizedDescription =模拟器中不支持远程通知} 无法注册:错误域= NSCocoaErrorDomain代码= 3010“模拟器中不支持远程通知”UserInfo = {NSLocalizedDescription =模拟器中不支持远程通知} 22
任何人都可以帮我隐藏这些日志......?提前谢谢!
答案 0 :(得分:1)
它不仅仅是一个日志。这是一个警告。必须在主线程上调用[UIApplication registerForRemoteNotifications]
。您应该将此方法的调用移至didFinishLaunchingWithOptions
的{{1}}。
答案 1 :(得分:0)
这不是一个不需要的日志。
您需要在主线程中调用registerForRemoteNotifications()
。
替换如下代码。
let center = UNUserNotificationCenter.current()
center.delegate = self
center.requestAuthorization(options: [.sound, .alert, .badge]) { (granted, error) in
if error == nil{
DispatchQueue.main.async {
UIApplication.shared.registerForRemoteNotifications()
}
}
}