简体   繁体   English

UrbanAirship的iOS推送通知错误

[英]iOS Push Notification error with UrbanAirship

I've finally got push notifications working from UrbanAirship. 我终于从UrbanAirship获得了推送通知。 But now I have a problem, searched here and can't find a solution. 但是现在我有一个问题,在这里搜索并找不到解决方案。

When the app is running and I get a notification, clicking the notification takes me into the app and all is well. 当应用程序运行且收到通知时,单击通知会将我带入应用程序,一切正常。

When I kill the app and I get a notification, the app dies with SIGKILL. 当我杀死该应用程序并收到通知时,该应用程序将以SIGKILL死亡。

Here is the log: log 这是日志: log

OK, here is my appdelegate.m: 好的,这是我的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); 
}

Any help greatly appreciated before this Mac Mini goes through the window :-) 在此Mac Mini通过窗口之前,将不胜感激任何帮助:-)

This has nothing to do with Urban Airship I don't think. 我认为这与城市飞艇无关。 If you: 如果你:

  1. Create a brand new project 创建一个全新的项目
  2. Plug in your device 插入您的设备
  3. Run the app 运行应用
  4. force close the app from the phone (you might have to try re-opening it) 强制从手机关闭应用程序(您可能必须尝试重新打开它)

You will get the same error message. 您将收到相同的错误消息。

Since it happens in a brand new project without even touching it, I assume this behaviour is expected. 由于它发生在一个全新的项目中,甚至没有涉及它,因此我认为这是预期的行为。

You did mention that... 你确实提到...

When I kill the app and I get a notification, the app dies with SIGKILL. 当我杀死该应用程序并收到通知时,该应用程序将以SIGKILL死亡。

I'd check your applicationDidBecomeActive:(UIApplication *)application method. 我会检查您的applicationDidBecomeActive:(UIApplication *)应用程序方法。 Apple docs says that... 苹果文档说...

This method is called to let your app know that it moved from the inactive to active state. 调用此方法可让您的应用知道它已从非活动状态变为活动状态。 This can occur because your app was launched by the user or the system. 发生这种情况是因为您的应用是由用户或系统启动的。 Apps can also return to the active state if the user chooses to ignore an interruption (such as an incoming phone call or SMS message) that sent the app temporarily to the inactive state. 如果用户选择忽略将应用程序暂时发送到非活动状态的中断(例如来电或SMS消息),则应用程序也可以返回到活动状态。

You should use this method to restart any tasks that were paused (or not yet started) while the app was inactive. 您应使用此方法重新启动应用程序处于非活动状态时已暂停(或尚未启动)的所有任务。 For example, you could use it to restart timers or throttle up OpenGL ES frame rates. 例如,您可以使用它重新启动计时器或限制OpenGL ES帧速率。 If your app was previously in the background, you could also use it to refresh your app's user interface. 如果您的应用先前位于后台,则还可以使用它刷新应用的用户界面。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM