简体   繁体   English

iOS推送通知-application:didRegisterForRemoteNotificationsWithDeviceToken:是否在主线程中执行?

[英]iOS push notifications - does application:didRegisterForRemoteNotificationsWithDeviceToken: execute in main thread?

I am wondering if an iOS app delegate's application:didRegisterForRemoteNotificationsWithDeviceToken: method executes in the main thread? 我想知道iOS应用程序委托的application:didRegisterForRemoteNotificationsWithDeviceToken:方法是否在主线程中执行?

Ultimately I would like to know whether it is safe to put UI code in this method and if I should keep blocking code (like network interactions) out of it. 最终,我想知道将UI代码放入此方法是否安全,是否应该阻止代码(例如网络交互)。

In general, are delegate methods executed in the main thread? 通常,委托方法是否在主线程中执行?

The application delegate methods such as: 应用程序委托方法,例如:

application:didRegisterForRemoteNotificationsWithDeviceToken:

are executed on the main thread. 在主线程上执行。

If you want your application to be responsive for the user you should but blocking code in a background thread. 如果希望您的应用程序对用户响应,则应在后台线程中阻止代码。

It is safe and recommended to execute UI code on the main thread. 建议在主线程上执行UI代码是安全的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM