Re: Exception on launch when clicking on an NSUserNotification
On Thu, Feb 26, 2015, at 08:49 PM, Alex Kac wrote: 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. You're trapped at objc_exception_throw. You can select frame 0 and print the first argument (`po $rdi` on x86-64). --Kyle Sluder ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Exception on launch when clicking on an NSUserNotification
*** -[NSKeyedUnarchiver decodeObjectForKey:]: data to unarchive contains class (NSArray) which has not been allowed However - the only array I’m setting is the additionalActions - a Yosemite property (this is on Yosemite of course). // An array of NSUserNotificationAction objects that describe the different actions that can be taken on a notification in addition to the default action described by actionButtonTitle @property (copy) NSArray *additionalActions NS_AVAILABLE(10_10, NA); And yup that is it. If I comment out the additionalActions, it works. I guess time to file a bug… # 19986044 On Feb 27, 2015, at 9:35 AM, Kyle Sluder k...@ksluder.com wrote: On Thu, Feb 26, 2015, at 08:49 PM, Alex Kac wrote: 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. You're trapped at objc_exception_throw. You can select frame 0 and print the first argument (`po $rdi` on x86-64). --Kyle Sluder ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: https://lists.apple.com/mailman/options/cocoa-dev/alex%40webis.net This email sent to a...@webis.net Alex Kac - President and Founder Web Information Solutions, Inc. It is useless for sheep to pass a resolution in favor of vegetarianism while wolves remain of a different opinion. -- William Randolph Inge ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Exception on launch when clicking on an NSUserNotification
As I have written several times now - I have no user data. If the limit is 1k and it hits that with less than 100 characters for a title and informative string and an ID - then that’s a real bug. I really don’t think I’m hitting that. It would make NSUserNotifications pretty useless for everyone. On Feb 26, 2015, at 11:04 PM, Graham Cox graham@bigpond.com wrote: On 27 Feb 2015, at 4:27 pm, Alex Kac a...@webis.net wrote: What’s not shown above is the identifier - which is a 64 character string, and the sound name which is a 10 character string. I’m pretty sure that’s not more than 1k Right, but it's the resulting archive that has to come in under 1K (a ridiculously small limit!). Archives include all sorts of stuff on top of the actual string content - complete class names for all classes involved, all the keys and a fairly complex structure. You might want to just archive your user data with keyed archiver and check the resulting length of the NSData. --Graham Alex Kac - President and Founder Web Information Solutions, Inc. If at first you don't succeed, skydiving is not for you. -- Francis Roberts ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Exception on launch when clicking on an NSUserNotification
On OS X (this is OS X, not iOS - hence NSUserNotification and not UILocalNotification), when you start an app by tapping on a notification, because you haven’t had a chance yet to register the delegate of the NSUserNotificationCenter (this has nothing to do with NSNotificationCenter), the OS passes in the notification as part of the notification on launch: NSApplicationLaunchUserNotificationKey The following key is an NSUserNotification object that will be present in the notification userInfo dictionary of the NSApplicationDidFinishLaunchingNotification notification if your app was launched because a user activated a notification in the Notification Center. Available in OS X v10.8 and later. Second, as you can see in the printed object below, the length of the strings are: { title: Test informativeText: 9:55 PM actionButtonTitle: “Snooze” What’s not shown above is the identifier - which is a 64 character string, and the sound name which is a 10 character string. I’m pretty sure that’s not more than 1k. And yes, I’ve gone through all the documentation, I’ve gone through EVERY SINGLE property of NSUserNotification in the headers and in the docs to make sure I’m not putting something in there I shouldn’t be. AND remember - this WORKS if the app is running and it delivers the notification to the - (void)userNotificationCenter:(NSUserNotificationCenter *)center didActivateNotification:(NSUserNotification *)notification method. It only fails on startup with the notification in didFinishLaunching. I do believe there is something I am doing wrong…I just can’t figure out what. In my other reply on this, I also posted my code as well and with the info above, you can see what text I posted. This is why its so frustrating. I am getting no meaningful error, the data I’m giving it - as far as I can tell - is correct. What I’ll start doing is cutting it down to the basics - no action, no informative text, no sound - and just start from the very very minimum and see what happens… On Feb 26, 2015, at 9:12 PM, Graham Cox graham@bigpond.com wrote: OK, I may be having a massive misunderstanding about how iOS works (as compared with Mac OS), but the NSUserNotification you post is, as far as I'm aware, completely unrelated to the NSNotification that is passed to -applicationWill/DidFinishLaunching. The latter is just a notification that the application created internally, and as a convenience passed to its delegate before or after broadcasting it using NSNotificationCenter. The user notification you post just triggers the notification system. I realise it's pretty confusing with everything being called more or less the same thing, but they are totally different. The userInfo you pass in your user notificaiton will not turn up in the app delegate's did launch notification. (Unless, that is, iOS is documented to do that. Mac OS definitely doesn't). ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Exception on launch when clicking on an NSUserNotification
On 27 Feb 2015, at 4:27 pm, Alex Kac a...@webis.net wrote: What’s not shown above is the identifier - which is a 64 character string, and the sound name which is a 10 character string. I’m pretty sure that’s not more than 1k Right, but it's the resulting archive that has to come in under 1K (a ridiculously small limit!). Archives include all sorts of stuff on top of the actual string content - complete class names for all classes involved, all the keys and a fairly complex structure. You might want to just archive your user data with keyed archiver and check the resulting length of the NSData. --Graham ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Exception on launch when clicking on an NSUserNotification
The documentation doesn't actually say it's archived - it talks about the serialized size. That could imply that it's passed around as a plist rather than a keyed archive. But a plist has a fair bit of overhead as well, as it's an XML file. --Graham On 27 Feb 2015, at 5:04 pm, Graham Cox graham@bigpond.com wrote: On 27 Feb 2015, at 4:27 pm, Alex Kac a...@webis.net wrote: What’s not shown above is the identifier - which is a 64 character string, and the sound name which is a 10 character string. I’m pretty sure that’s not more than 1k Right, but it's the resulting archive that has to come in under 1K (a ridiculously small limit!). Archives include all sorts of stuff on top of the actual string content - complete class names for all classes involved, all the keys and a fairly complex structure. You might want to just archive your user data with keyed archiver and check the resulting length of the NSData. --Graham ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Exception on launch when clicking on an NSUserNotification
On Feb 26, 2015, at 6:49 PM, Alex Kac a...@webis.net wrote: It would be a fantastic clue! Except … its not printed in the console, or in the xcode console, or anywhere. Yeah, it’s getting caught by something that doesn’t log it. You can usually find the exception object when you’re stopped at the breakpoint — it’ll either be in a CPU register or near the top of the stack. I had that memorized for PowerPC, and then I relearned it for x86, but never figured it out for 64-bit… —Jens ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Exception on launch when clicking on an NSUserNotification
On Feb 26, 2015, at 6:17 PM, Alex Kac a...@webis.net 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%202015-02-25%2021.38.37.png?dl=0 https://www.dropbox.com/s/nmf6qr97su43plh/Screenshot%202015-02-25%2021.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 (Cocoa-dev@lists.apple.com) 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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Exception on launch when clicking on an NSUserNotification
Also, this: The userInfo content must be of reasonable serialized size (less than 1KB) or an exception is thrown. It woud be easy to exceed 1K with a few strings. --Graham On 27 Feb 2015, at 3:12 pm, Graham Cox graham@bigpond.com wrote: OK, I may be having a massive misunderstanding about how iOS works (as compared with Mac OS), but the NSUserNotification you post is, as far as I'm aware, completely unrelated to the NSNotification that is passed to -applicationWill/DidFinishLaunching. The latter is just a notification that the application created internally, and as a convenience passed to its delegate before or after broadcasting it using NSNotificationCenter. The user notification you post just triggers the notification system. I realise it's pretty confusing with everything being called more or less the same thing, but they are totally different. The userInfo you pass in your user notificaiton will not turn up in the app delegate's did launch notification. (Unless, that is, iOS is documented to do that. Mac OS definitely doesn't). --Graham On 27 Feb 2015, at 1:17 pm, Alex Kac a...@webis.net 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%202015-02-25%2021.38.37.png?dl=0 I can continue, and the app then runs…but no NSApplicationLaunchUserNotificationKey in the notification. NSConcreteNotification 0x612555d0 {name = NSApplicationDidFinishLaunchingNotification; object = PIApplication: 0x618000115570; userInfo = { NSApplicationLaunchIsDefaultLaunchKey = 0; }} I am debugging the launch by using XCode's Wait for executable to be launched option in the scheme, then tapping on my notification to launch the app. There is no info in the console. The notification being scheduled is: NSUserNotification:0x10149d2c0 { title: Test informativeText: 9:55 PM actionButtonTitle: Snooze next delivery date: 2015-02-26 04:54:47 + } I am using 10.10 action item (snooze options). I’ve Googled this with no luck. My only guess was that there was something in the notification that wasn’t decodeable…but I’ve checked every property of the notification just to be sure I didn’t do something stupid and its all good. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Exception on launch when clicking on an NSUserNotification
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 j...@mooseyard.com wrote: On Feb 26, 2015, at 6:17 PM, Alex Kac a...@webis.net wrote: However I'm having a problem on launching the app by tapping on the notification. My app gets
Re: Exception on launch when clicking on an NSUserNotification
OK, scratch that - it does seem as if there should be the user notification embedded in the did launch notification: NSApplication If an application is launched because a user selected a notification in the Notification Center, NSApplicationLaunchUserNotificationKey will be present in the userInfo dictionary of NSApplicationDidFinishLaunchingNotification. Its value is an NSUserNotification object. - (void)applicationDidFinishLaunching:(NSNotification *)notification { NSUserNotification *launchNotification = [[notification userInfo] objectForKey:NSApplicationLaunchUserNotificationKey]; if (launchNotification) { // application was launched by a user selection from Notification Center } } NSApplicationLaunchUserNotificationKey has replaced NSApplicationRemoteNotificationKey, which was introduced in Lion but is deprecated in Mountain Lion. So that's something new I learned - sorry for the noise. But the 1K limit presumably still applies... --Graham On 27 Feb 2015, at 3:12 pm, Graham Cox graham@bigpond.com wrote: OK, I may be having a massive misunderstanding about how iOS works ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com