我可以成功地为推送通知注册我的应用程序:
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);我怎么能
发布于 2013-05-31 13:50:58
你是否覆盖了公共覆盖无效RegisteredForRemoteNotifications(UIApplication应用程序,NSData deviceToken)
或
公共覆盖无效FailedToRegisterForRemoteNotifications(UIApplication应用程序,NSError错误)
我也遇到过类似的问题.函数时,我调用了一个web服务来上传设备令牌。但是网络调用不在另一个线程中,所以它导致UI冻结。
https://stackoverflow.com/questions/14741386
复制相似问题