我可以成功注册我的应用程序的推送通知: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冻结登记?