プッシュ通知用にアプリを正常に登録できます。
UIApplication.SharedApplication.RegisterForRemoteNotificationTypes(
UIRemoteNotificationType.Alert
| UIRemoteNotificationType.Badge
| UIRemoteNotificationType.Sound);
しかし、これを実行するたびに、UI が通常 2 ~ 3 秒間ハングします。アプリのライフサイクルの早い段階で推奨されている場合でも (例: WillFinishLaunching
)、最初の ViewController が読み込まれると UI がハングします。
私の最初の考えは、別のスレッドで登録を実行することでしたが、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のフリーズを隠蔽?