2

因此,我遵循了 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];

}

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

4

0 回答 0