Abirami Bala
Abirami Bala

Reputation: 790

Hide unwanted Logs printing - in Xcode 9

I already set OS_ACTIVITY_MODE to disable, but after migrating to Xcode 9 there was some unwanted logs printing like the below.

Edit: I already referred Hide strange unwanted Xcode logs, but doesn't work for me in Xcode 9.

================================================================= Main Thread Checker: UI API called on a background thread: -[UIApplication registerForRemoteNotifications] PID: 1303, TID: 27861, Thread name: (none), Queue name: com.apple.usernotifications.UNUserNotificationServiceConnection.call-out, QoS: 0 Backtrace: 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 Couldn't register: Error Domain=NSCocoaErrorDomain Code=3010 "remote notifications are not supported in the simulator" UserInfo={NSLocalizedDescription=remote notifications are not supported in the simulator} Couldn't register: Error Domain=NSCocoaErrorDomain Code=3010 "remote notifications are not supported in the simulator" UserInfo={NSLocalizedDescription=remote notifications are not supported in the simulator} Couldn't register: Error Domain=NSCocoaErrorDomain Code=3010 "remote notifications are not supported in the simulator" UserInfo={NSLocalizedDescription=remote notifications are not supported in the simulator} 22

Can Anyone help me to hide these logs....? Thanks in advance!

Upvotes: 0

Views: 627

Answers (2)

Parth Adroja
Parth Adroja

Reputation: 13514

It's not an unwanted log. You need to call registerForRemoteNotifications() in main thread.

Replace code as below.

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()
                }
            }
        }

Upvotes: 0

Alex
Alex

Reputation: 1245

It's not just a log. It's a warning. [UIApplication registerForRemoteNotifications] must be called on the main thread. You should move call of this method to didFinishLaunchingWithOptions of your AppDelegate.

Upvotes: 1

Related Questions