我想知道如果 iOS 应用程序委托(delegate)的 application:didRegisterForRemoteNotificationsWithDeviceToken:
方法在主线程中执行?
最终,我想知道将 UI 代码放入此方法是否安全,以及是否应该将阻塞代码(如网络交互)排除在外。
一般来说,委托(delegate)方法是在主线程中执行的吗?
最佳答案
应用程序委托(delegate)方法,例如:
application:didRegisterForRemoteNotificationsWithDeviceToken:
在主线程上执行。
如果您希望您的应用程序对用户做出响应,您应该在后台线程中阻止代码。
安全且推荐在主线程上执行 UI 代码。
关于multithreading - iOS 推送通知 - 应用程序 :didRegisterForRemoteNotificationsWithDeviceToken: execute in main thread?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4408461/