I can successfully register my app for push notifications:
UIApplication.SharedApplication.RegisterForRemoteNotificationTypes(
UIRemoteNotificationType.Alert
| UIRemoteNotificationType.Badge
| UIRemoteNotificationType.Sound);
But whenever I execute this, my UI hangs for usually 2-3 seconds. Even if I have it early in the app lifecycle as recommended (e.g., even WillFinishLaunching
) my UI still hangs once my first ViewController loads.
My first thought was to execute the registration in a separate thread, but MonoTouch prevents this:
// From MonoTouch.UIKit
public virtual void RegisterForRemoteNotificationTypes(UIRemoteNotificationType types)
{
UIApplication.EnsureUIThread();
My next thought was to at least pop up a UIAlertView
box to let the user know something's going on, but for some reason it didn't display until after the registration took place, resulting in the UIAlertView
opening and immediately closing!
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);
How can I either
Did you override public override void RegisteredForRemoteNotifications(UIApplication application, NSData deviceToken)
or
public override void FailedToRegisterForRemoteNotifications(UIApplication application, NSError error)
I've had similar problem where within Registered... function, I called a web service to upload the device token. But the web call wasn't within another thread so it caused to freezes UI.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With