我终于得到了 UrbanAirship 的推送通知。但是现在我有一个问题,在这里搜索并找不到解决方案。
当应用程序正在运行并且我收到通知时,单击通知会将我带入应用程序,一切都很好。
当我杀死应用程序并收到通知时,应用程序会因 SIGKILL 而死。
这是日志:日志
好的,这是我的 appdelegate.m:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
//Init Airship launch options
NSLog(@"Before NSMutableDictionary");
NSMutableDictionary *takeOffOptions = [[NSMutableDictionary alloc] init];
[takeOffOptions setValue:launchOptions forKey:UAirshipTakeOffOptionsLaunchOptionsKey];
// Create Airship singleton that's used to talk to Urban Airship servers.
// Please populate AirshipConfig.plist with your info from http://go.urbanairship.com
NSLog(@"Before takeOff");
[UAirship takeOff:takeOffOptions];
// Register for notifications
NSLog(@"Before UIApplication");
[[UIApplication sharedApplication]
registerForRemoteNotificationTypes:(UIRemoteNotificationTypeBadge |
UIRemoteNotificationTypeSound |
UIRemoteNotificationTypeAlert)];
NSLog(@"Before reset badge");
//reset badge
application.applicationIconBadgeNumber = 0;
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
// Override point for customization after application launch.
self.viewController = [[ViewController alloc] initWithNibName:@"ViewController" bundle:nil];
self.window.rootViewController = self.viewController;
[self.window makeKeyAndVisible];
return YES;
}
-(void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken
{
NSLog(@"didRegisterForRemoteNotifications");
[[UAirship shared] registerDeviceToken:deviceToken];
}
-(void)application:(UIApplication *)application didFailToRegisterForRemoteNotificationsWithError:(NSError *)error
{
NSString *str = [NSString stringWithFormat: @"Error: %@", error];
NSLog(@"Error:%@",str);
}
在此 Mac Mini 通过窗口之前,非常感谢您提供的任何帮助 :-)