Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Mockup & CodeGen, iPhone & iPad
($9.99)

Make your own iPhone apps
and run them live!
(free)

Manu
($0.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 08-06-2009, 09:52 AM   #1 (permalink)
Humbled Student
 
Dutch's Avatar
 
Join Date: Apr 2009
Location: Long Island, NY
Age: 32
Posts: 883
Send a message via AIM to Dutch
Default Debugging App When Launched by Push Notification

I am currently developing an app that receives Push Notifications. I have this all working 100% through a PHP page. There are several different types of push notifications my app can receive. The PHP handles this and sends different packets of information to my app which are all received just fine.

However, when the users "views" the notification and my app launches, I obviously want to take a different action than I would if the user just launched the app manually - and on top of that, different actions depending on the push notification type. I have got this working fine... structurally.

One of my push types is supposed to open a UIView that makes several connections to several different servers and negotiates data back and forth. This UIView works fine when, for example, triggered from the main menu - however when my push notification is triggering this UIView to appear, the socket connections are not acting as expected.

Now my question is not about the sockets, but more so - How do you debug such a problem?? From what I can tell (I am relatively new) when the app launched from a push notification there is no way to link that execution to the debugger / console / etc... I am having a very difficult time trying to debug the code using UIAlertViews, as there are many lines of communication back and forth between the various servers.

Any advice you have for me would be greatly appreciated.
Dutch is offline   Reply With Quote
Old 08-06-2009, 01:21 PM   #2 (permalink)
Humbled Student
 
Dutch's Avatar
 
Join Date: Apr 2009
Location: Long Island, NY
Age: 32
Posts: 883
Send a message via AIM to Dutch
Default SOLVED! Debugging App When Launched by Push Notification

I was able to get this helpful tip on StackOverflow.

Quote:
You can now configure Xcode to attach the debugger to the app after you launch it, instead of launching the app through the debugger. This lets you debug things that vary based on the launch state of your application, such as URL schemes, pasteboards, and push notifications.

1. In Xcode look in the Source bar, and below Targets there will be Executables.
2. Bring up the inspector for your app in executables.
3. Click on the Debugging tab tab in the inspector.
4. Uncheck "Start executable after starting debugger"
5. Check the "Wait for next launch/push notification"

Now when you click debug from Xcode instead of launching the app a window will display telling it is waiting for the app to launch. You then launch the app normally on the phone and Xcode attaches to it
Works like a charm!!
Dutch is offline   Reply With Quote
Old 08-06-2009, 01:24 PM   #3 (permalink)
Registered Member
 
kelvinkao's Avatar
 
Join Date: Jul 2009
Location: Los Angeles
Posts: 352
Send a message via AIM to kelvinkao
Default

I use two kinds of hacks for something like this. It's not for push notifications, but it's similar, because I was testing starting the app from an URL, which doesn't give me console output either.

1) On-screen output: This is similar to what you are doing. Instead of alerts, I am just putting a plain text label on the screen so I can see the outputs there. Limiting, and new text replaces old text, I know. But at least it's something.

2) Pretend to trigger an event: For example, I created a button just for debugging purposes. When the button is pressed, I manually call the method that normally handles the setups while started from other apps. This way, at least I get to see some console outputs out of it.

Of course, both of these are sort of hacks.
kelvinkao is offline   Reply With Quote
Old 08-06-2009, 01:51 PM   #4 (permalink)
Humbled Student
 
Dutch's Avatar
 
Join Date: Apr 2009
Location: Long Island, NY
Age: 32
Posts: 883
Send a message via AIM to Dutch
Default

Thanks for the tip. My Previous most is EXACTLY what I was looking for (and perhaps it will also help you).

The full thread is located here:
Debugging App When Launched by Push Notification - Stack Overflow
Dutch is offline   Reply With Quote
Old 08-06-2009, 02:24 PM   #5 (permalink)
Registered Member
 
kelvinkao's Avatar
 
Join Date: Jul 2009
Location: Los Angeles
Posts: 352
Send a message via AIM to kelvinkao
Default

Haha, yeah, it would. We were writing those replies at around the same time. If I had seen your first, I would've probably thought "oh, that's a much better idea!" Hehe.
kelvinkao is offline   Reply With Quote
Reply

Bookmarks

Tags
debug, iphone app, push notification

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 234
15 members and 219 guests
ADY, AragornSG, Dani77, Dattee, Duncan C, fkmtc, HDshot, HemiMG, Promo Dispenser, Punkjumper, Rudy, sacha1996, sneaky, spiderguy84, theone8one
Most users ever online was 1,187, 10-11-2011 at 08:09 AM.
» Stats
Members: 158,885
Threads: 89,231
Posts: 380,768
Top Poster: BrianSlick (7,129)
Welcome to our newest member, bookesp
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 03:15 PM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0