我终于得到了UrbanAirship的推送通知。但是现在我遇到了问题,在这里搜索并找不到解决方案。
当应用程序运行并收到通知时,点击通知会将我带入应用程序,一切正常。
当我杀死应用程序并收到通知时,应用程序将死于SIGKILL。
以下是日志:log
好的,这是我的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通过窗口之前,任何帮助都非常感激: - )
答案 0 :(得分:1)
这与我不认为的Urban Airship无关。如果你:
您将收到相同的错误消息。
由于它发生在一个全新的项目中,甚至没有触及它,我认为这种行为是可以预期的。
答案 1 :(得分:0)
你确实提到过......
当我杀死应用程序并收到通知时,应用程序将死于SIGKILL。
我会检查您的applicationDidBecomeActive:(UIApplication *)应用程序方法。 Apple文档说......
调用此方法可让您的应用知道它已从非活动状态移至活动状态。这可能是因为您的应用程序是由用户或系统启动的。如果用户选择忽略将应用暂时发送到非活动状态的中断(例如来电或短信),应用也可以返回活动状态。
您应该使用此方法重新启动应用处于非活动状态时暂停(或尚未启动)的任何任务。例如,您可以使用它来重新启动计时器或限制OpenGL ES帧速率。如果您的应用之前位于后台,您还可以使用它来刷新应用的用户界面。