iPhone Urban Airship Crash InstanceNotExitsts

时间:2013-06-05 17:26:49

标签: iphone ios notifications push urbanairship.com

所以,我遵循了UA文档并且一切正常。问题是我一直在下面发生这次崩溃。

Terminating app due to uncaught exception 'InstanceNotExists', reason: 'Attempted to access instance before initializaion. Please call takeOff: first.'

似乎只有当您打开应用程序关闭它然后尝试重新打开它时,或者如果您打开应用程序关闭应用程序,发送通知然后尝试单击通知。它在第一次加载时永远不会崩溃。我在下面安装的代码。

#import "UAirship.h"
#import "UAPush.h"

 -(BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
NSMutableDictionary *takeOffOptions = [NSMutableDictionary dictionary];
[takeOffOptions setValue:launchOptions forKey:UAirshipTakeOffOptionsLaunchOptionsKey];

[UAirship takeOff:takeOffOptions];

// Register for notifications
[[UAPush shared]
 registerForRemoteNotificationTypes:(UIRemoteNotificationTypeBadge |
                                     UIRemoteNotificationTypeSound |
                                     UIRemoteNotificationTypeAlert)];


-(void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {
 //Updates the device token and registers the token with UA.
 NSLog(@"My token is: %@", deviceToken);
 [[UAPush shared] registerDeviceToken:deviceToken];
}

-(void)applicationWillTerminate:(UIApplication *)application
 {
  // Saves changes in the application's managed object context before the application terminates.
 [UAirship land];
 [self saveContext];

}

我错过了什么吗?任何帮助,将不胜感激!感谢

0 个答案:

没有答案