Push notifications - catching them? - iphone

okay, so here is the deal.
my app is using iOS notifications.
in app delegate I am catching them in didReceiveRemoteNotification if the app is in foreground
i catch it in didBecomeActive if app was in background and i tapped on the push notification.
however!
if my app is in background, i receive push notification and if i do not tap on push notifications (or just "Cancel" on it in iOS less than 5.0), and open app in say, couple minutes, i can't figure out how do I find this push notification. any suggestions?
thanks!

If your app is in background the OS handles the push notifications. It sets a badge, shows a text or plays a sound. You even can specify a launch image in iOS5 what the app launches with when "OK" is pressed.
However if you do not press OK or cancel the notification PopUp, there is no chance to catch any information.
If you send your notifications from an application server, you could implement an interface (REST or such) on that server which can be asked for the last notification or even the notification history. But that is a workaround.

Related

Notification banners not showing for apps being debugged?

Is there any way to make notification banners show for an app that is being debugged on Xcode?
Not working for me. When I stop the app on Xcode, notification banners show. If the app is being debugged, notification banners won't show.
When I send a notification, application:didReceiveRemoteNotification: is triggered and the notification is received on the userInfo of this method, but the notification banner never appears.
Yes, my device is configured to show notifications as banners for this app. I have double verified that.
Any thoughts?
thanks.
Banners will appear only when the app is closed/in the background. Otherwise, application:didReceiveRemoteNotification: is called.

Showing Push notifications

I set my application for push notification and all is running fine. But i want that push notification should also show when my application is running. I do-not want to show an alert or pop in my application
There's nothing built-in to iOS that will make push notification popup appears if the app for the notification is currently in the foreground. You need to look at the data you get in the notification and create a UIAlertView by hand.

Is there a way to make my background iPhone app to go foreground?

Is there a way to make my background iPhone app to go foreground?
Tnx.
A UILocalNotification will bring the app to the foreground if the device is locked, a notification appears, and the user unlocks the device.
A UILocalNotification with an alertAction will display the alert while the device is unlocked, and if the user taps the View button (or whatever you set it to), your app will be brought to the front.
Not for your app, but the user could do it.
You could schedule a UILocalNotification to inform the user that you are done with your task or whatever.
Nope. But you can do something when you feel must do. For example, use remote Apple Push Notification Service (APNS) to notify your user that you want her to bring your app back to the foreground.
Or, as JustSid put it, use local notification to notify your user that you want her attention.

Push notification during call - iPhone

What happens if I send a push notification to the iPhone and it's during a call, or during incoming call?
would it popup on the screen and show the notification to the user?
Yes, it gets displayed on screen and the user will need to close the notification before they can click the "End Call" button. It's a little distracting, but does ensure that the notification has a chance at being viewed. After all, it might be an important notification.

Detect Application States

I want to detect application states and send it to the server. In the new OS4, with multitasking there are some methods available to help detecting the states:
application:didFinishLaunchingWithOptions:
applicationDidBecomeActive:
applicationWillResignActive:
applicationDidEnterBackground:
applicationWillEnterForeground:
applicationWillTerminate:
I read that now, we have to use applicationDidEnterBackground instead of applicationWillTerminate. My problem is that i need them both.
When the user send the app to the background, it has the state sleep. But when the user close the app ( from the multitask bar ) the state is closed. So i need to detect both, when the user send the app to the background and when the user ( or the system ) close it.
Is there anyway or workaround to make this?
I try subscribing to UIApplicationWillTerminateNotification but it doesn´t work.
Thanks in advice.
The application will quit notification is no longer fired on iOS 4 (as I am led to believe).
When the user hits the home button, the app is sent to the background, and you will get the did enter background notification. But when a user closes the app from the multitask bar, or if the system closes it, the app is sent a SIGKIL message and quits immediately, firing no notifications or delegate methods.