0

我第一次使用 APNS,我尝试使用 iOS 5.0.1 设备运行概念验证,结果didFailToRegisterForRemoteNotificationsWithError被触发。我知道它已被解雇,因为我显示UIAlertView通知错误:

- (void)application:(UIApplication*)application
   didFailToRegisterForRemoteNotificationsWithError:(NSError*)error
{
   // Inform the user that registration failed
   NSString* failureMessage = @"There was an error while trying to \

     register for push notifications.";

   UIAlertView* failureAlert = [[UIAlertView alloc] initWithTitle:@"Error"
                                                      message:failureMessage
                                                     delegate:nil
                                            cancelButtonTitle:@"OK"
                                            otherButtonTitles:nil];

   [failureAlert show];
   [failureAlert release];
}

如何获取有关错误的更多信息?

4

2 回答 2

0

尝试做类似NSLog(@"%@", error.userInfo");的事情,应该将一些信息输出到终端。

于 2012-07-04T15:59:11.253 回答
0

我最终得到了这段代码,它有效,让我进步了一点:

NSString* failureMessage = error.localizedDescription;    
UIAlertView* failureAlert = [[UIAlertView alloc] initWithTitle:@"Error"
                                                 message:failureMessage
                                                 delegate:nil
                                                 cancelButtonTitle:@"OK"
                                                 otherButtonTitles:nil];
[failureAlert show];

对不起,这里是 iObjectiveC 菜鸟。

于 2012-07-04T16:37:26.423 回答