Re: Exception on launch when clicking on an NSUserNotification
Re: Exception on launch when clicking on an NSUserNotification
- Subject: Re: Exception on launch when clicking on an NSUserNotification
- From: Alex Kac <email@hidden>
- Date: Thu, 26 Feb 2015 19:49:42 -0700
It would be a fantastic clue! Except … its not printed in the console, or in the xcode console, or anywhere. So I have no idea. My guess is that the OS is swallowing the exception for launch purposes, which does me no good.
I thought so too that it would have a problem decoding an archived object - however as I wrote in my original email:
1: I am not using any custom objects. Only NSStrings. I have tested with both having a userInfo (again with an NSString), and without. In fact, I’m no longer using userInfo - same issue.
2: It unarchives just fine if the app is already running - it only fails when it launches the app.
NSUserNotification *localNotif = [[NSUserNotification alloc] init];
localNotif.deliveryDate = [NSDate dateWithTimeIntervalSinceReferenceDate:alarmNotification.timeToFire];
localNotif.soundName = soundFile;
localNotif.title = title;
localNotif.informativeText = moreInfo;
[localNotif setHasActionButton: YES];
[localNotif setActionButtonTitle: LOC(@"Snooze")];
localNotif.identifier = [NSString stringWithFormat:@"Alarm-%@",stringInformantID] ;
//set the repeat and category
if ([localNotif respondsToSelector:@selector(setAdditionalActions:)])
{
NSMutableArray* additionalActions = [NSMutableArray array];
[additionalActions addObject:[NSUserNotificationAction actionWithIdentifier:@"Snooze1"
title:[NSString stringWithFormat:LOC(@"Snooze for %@"), StringForDuration(60)]]];
[additionalActions addObject:[NSUserNotificationAction actionWithIdentifier:@"Snooze5"
title:[NSString stringWithFormat:LOC(@"Snooze for %@"), StringForDuration(5*60)]]];
[additionalActions addObject:[NSUserNotificationAction actionWithIdentifier:@"Snooze15"
title:[NSString stringWithFormat:LOC(@"Snooze for %@"), StringForDuration(15* 60)]]];
[additionalActions addObject:[NSUserNotificationAction actionWithIdentifier:@"Snooze30"
title:[NSString stringWithFormat:LOC(@"Snooze for %@"), StringForDuration(30* 60)]]];
[additionalActions addObject:[NSUserNotificationAction actionWithIdentifier:@"Snooze60"
title:[NSString stringWithFormat:LOC(@"Snooze for %@"), StringForDuration(60* 60)]]];
[additionalActions addObject:[NSUserNotificationAction actionWithIdentifier:@"Snooze120"
title:[NSString stringWithFormat:LOC(@"Snooze for %@"), StringForDuration(120* 60)]]];
[additionalActions addObject:[NSUserNotificationAction actionWithIdentifier:@"Snooze86400"
title:[NSString stringWithFormat:LOC(@"Snooze for %@"), StringForDuration(kSecondsPerDay)]]];
[additionalActions addObject:[NSUserNotificationAction actionWithIdentifier:@"Snooze172800"
title:[NSString stringWithFormat:LOC(@"Snooze for %@"), StringForDuration(kSecondsPerDay*2)]]];
localNotif.additionalActions = additionalActions;
}
[[NSUserNotificationCenter defaultUserNotificationCenter] scheduleNotification: localNotif];
> On Feb 26, 2015, at 7:37 PM, Jens Alfke <email@hidden> wrote:
>
>
>> On Feb 26, 2015, at 6:17 PM, Alex Kac <email@hidden> wrote:
>>
>> However I'm having a problem on launching the app by tapping on the notification. My app gets an applicationWillFinishLaunching, and then gets an exception before it hits applicationDidFinishLaunching.
>>
>> https://www.dropbox.com/s/nmf6qr97su43plh/Screenshot 2015-02-25 21.38.37.png?dl=0
>
> That screenshot doesn’t show what the exception is — that’s likely the important clue. If you continue from that breakpoint the exception should get logged to the debugger console.
>
> From the stack it looks like it’s a problem decoding an archived object that’s a property of the notification. My guess is that you put a custom object in your notification userInfo and for some reason it fails to unarchive.
>
> —Jens
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden