Alright, never mind! I think I answered my own question there...
The thing is APNs are received in two ways, depending in the application
state, right... So, on the application didFinishLaunchingWithOptions
there's a code I'm not sure why it's there for, that was causing the crash:
self.invokeString = [url absoluteString];
Now, digging a little deeper and google came up with this:
http://stackoverflow.com/questions/7000438/ios-push-notification-term...
Which made me change this chunk of code:
NSArray *keyArray = [launchOptions allKeys];
if ([launchOptions objectForKey:[keyArray objectAtIndex:0]]!=nil)
{
NSURL *url = [launchOptions objectForKey:[keyArray objectAtIndex:0]];
self.invokeString = [url absoluteString];
NSLog(@"Shoes launchOptions = %@",url);
}
To this:
NSArray *keyArray = [launchOptions allKeys];
if ([launchOptions objectForKey:[keyArray objectAtIndex:0]]!=nil)
{
NSURL *url = [launchOptions objectForKey:UIApplicationLaunchOptionsURLKey];
if (url)
{
self.invokeString = [url absoluteString];
NSLog(@"listingApp launchOptions = %@", url);
}
}
And it's all working, fine and dandy. Now, why that code was there for in
the way it was and why is it not documented that if you receive your
notifications while the app isn't loaded nor in the background, options get
received thru other handler? And how would I go about calling
didReceiveRemoteNotification from there, so I don't have to duplicate the
code in both handlers?
I hope this helps someone out there and if you could let me know any of the
above, I greatly appreciate it!
Thanks!
On Wednesday, August 3, 2011 10:37:21 AM UTC-3, paul.obeda wrote:
> I am able to register my device and send a push notification (sandbox
> cert), but when the alert launches my app it immediately crashes ...
> any ideas?
> Note: this happens whether I use the default alert and click "View",
> or the no-button alert (which launches the app by default).
> Thanks in advance!
> ----- Console extract follows, anonymized -----
> Wed Aug 3 09:17:20 iPhone MyApp[1627] <Error>: -[__NSCFDictionary
> absoluteString]: unrecognized selector sent to instance 0x14a030
> Wed Aug 3 09:17:20 iPhone MyApp[1627] <Error>: *** Terminating app
> due to uncaught exception 'NSInvalidArgumentException', reason: '-
> [__NSCFDictionary absoluteString]: unrecognized selector sent to
> instance 0x14a030'
> *** Call stack at first throw:
> (
> 0 CoreFoundation 0x3759dc7b
> __exceptionPreprocess + 114
> 1 libobjc.A.dylib 0x32d9bee8
> objc_exception_throw + 40
> 2 CoreFoundation 0x3759f3e3 -
> [NSObject(NSObject) doesNotRecognizeSelector:] + 98
> 3 CoreFoundation 0x37544467
> ___forwarding___
> + 506
> 4 CoreFoundation 0x37544220
> _CF_forwarding_prep_0 + 48
> 5 MyApp 0x00002303 -[AppDelegate
> application:didFinishLaunchingWithOptions:] + 182
> 6 UIKit 0x35924fd8
> -[UIApplication
> _callInitializationDelegatesForURL:payload:suspended:] + 1116
> 7 UIKit 0x3591ea78
> -[UIApplication
> _runWithURL:payload:launchOrientation:statusBarStyle:statusBarHidden:]
> + 396
> 8 UIKit 0x358d82e4
> -[UIApplication
> handleEvent:withNewEvent:] + 1476
> 9 UIKit 0x358d7b1c
> -[UIApplication
> sendEvent:] + 68
> 10 UIKit 0x358d73b4
> _UIApplicationHandleEvent + 6824
> 11 GraphicsServices 0x33e77c88
> PurpleEventCallback + 1048
> 12 CoreFoundation 0x3752f5cb
> __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 28
> 13 CoreFoundation 0x3752f589
> __CFRunLoopDoSource1 + 164
> 14 CoreFoundation 0x37521835
> __CFRunLoopRun +
> 580
> 15 CoreFoundation 0x3752150b
> CFRunLoopRunSpecific + 226
> 16 CoreFoundation 0x37521419
> CFRunLoopRunInMode + 60
> 17 UIKit 0x3591d554
> -[UIApplication
> _run] + 548
> 18 UIKit 0x3591a558
> UIApplicationMain
> + 972
> 19 MyApp 0x000021b5 main + 80
> 20 MyApp 0x0000212c start + 52
> )
> Wed Aug 3 09:17:20 iPhone
> UIKitApplication:com.mycompany.myappid[0x31c5][1627] <Notice>:
> terminate called after throwing an instance of 'NSException'
> Wed Aug 3 09:17:22 iPhone ReportCrash[1628] <Notice>: Formulating
> crash report for process MyApp[1627]
> Wed Aug 3 09:17:22 iPhone com.apple.launchd[1]
> (UIKitApplication:com.mycompany.myappid[0x31c5][1627]) <Warning>:
> (UIKitApplication:com.mycompany.myappid[0x31c5]) Job appears to have
> crashed: Abort trap
> Wed Aug 3 09:17:22 iPhone SpringBoard[29] <Warning>: Application
> 'MyApp' exited abnormally with signal 6: Abort trap
> Wed Aug 3 09:17:23 iPhone ReportCrash[1628] <Error>: Saved
> crashreport to /var/mobile/Library/Logs/CrashReporter/
> MyApp_2011-08-03-091720_iPhone.plist using uid: 0 gid: 0,
> synthetic_euid: 501 egid: 0