我可以成功註冊我的應用程序的推送通知:RegisterForRemoteNotificationTypes使UI掛起
UIApplication.SharedApplication.RegisterForRemoteNotificationTypes(
UIRemoteNotificationType.Alert
| UIRemoteNotificationType.Badge
| UIRemoteNotificationType.Sound);
但每當我執行此,我的UI掛起一般2-3秒。即使我在推薦的應用生命週期早期(例如,即使是WillFinishLaunching
),我的UI仍然會在我的第一個ViewController加載後掛起。
我首先想到的是在一個單獨的線程來執行註冊,但MonoTouch的防止這一點:
// From MonoTouch.UIKit
public virtual void RegisterForRemoteNotificationTypes(UIRemoteNotificationType types)
{
UIApplication.EnsureUIThread();
我的下一個想法是至少彈出一個UIAlertView
框,讓用戶知道的東西是怎麼回事,但由於某種原因,直到發生登記後才顯示,致使UIAlertView
開放並立即關閉!
modalPopup = new UIAlertView("Working", "The application is loading...", null, null);
modalPopup.Show();
// It doesn't show here!
RegisterForRemoteNotificationTypes();
// It shows here!
modalPopup.DismissWithClickedButtonIndex(0, true);
如何,我不是
- 停止推送通知從佔用我的UI線程
- 掩蓋了UI凍結登記?