IOS 5 Local Notifications While in Foreground, is there a way - ios5

On IOS 5, we now have the notification bar on top to put messages. I have seen that Local Notifications will only happen if the app is in the background (not sure when queued, and / or when the notification is to fire, assume the latter).
Is there any way to put notifications in the notification bar while the app is in the foreground?

From my understanding, your app will be notified of a local notification while the app is running in the application:didReceiveLocalNotification delegate method, but a banner will not be shown at the top of the device screen, not will an entry be put in Notification Center. Your app is notified however, and this is so you can show your own UI for the notification in the app, or choose to ignore it.
Notification Center is only for notifications that you're missed because the app is not in the foreground, and that's why they disappear when the app is opened.

Yes, local notifications work with the simulator. However, make sure you are implementing application:didreceiveLocalNotification in your app delegate if you want to see the nofication while your app is in the foreground (source)
further troubleshooting steps per our conversation in chat and based on the above.
Like i said there are only 2 possibilities of why its not working. placement (in app delegate vs another class) and the application variable. so if it works in the app delegate then im not sure how to resolve that other then making a public method that you can reach from the class you want the notification to come from. probably not the most elegant or proper way but i dont know what else to say.
If its the application variable then make sure you use the same one i posted, application from the applicationfinishloading arguments list vs [[shared application]

Related

App screen turn white while receiving notification

This is so weird, I've looked and nobody has the same problem as I was.
So, I noticed my app suddenly turn into white screen for few seconds when have incoming notification, this notification from other apps like facebook, whatsapp, etc. But it confuses me, why it effect my app when notification shown in the top screen for like 3 seconds, and my app turn into white except the notification.
This happened on iPhone 5 (iOS6). never happen before on iOS5.
EDIT
My app doesn't register notification, notification comes from other application, which nothing to do on my app. that is the strange one.
By pulling down notification also my app turned into white.
-<>-
So I fixed my own problem. anyone face same problem like I was, can see this solution :
The problem is caused by duplicate window in in App delegate xib. which I might added accidentally into it, Silly of me.
Second window is just empty, unused. contain only white background - which is why this was shown when app received notification or by pulling down notification bar.
by removing it will solve the problem.
I think you call a thread when notification is occurred, Or when notification appeared you call multiple thread with work on views push or pop or hevy load the data , please check on instrument and leak first and resolved the allocation problem and check with notification in second part.
let me know if you have any issues.

How to make a Push Notification opens a specific uiview

I've been trying forever to get this to work, when I send a push notification to my app. When the user opens it, it just takes them to the app. I want to direct them to a specific uiview, how do I do that?
The method application:didReceiveRemoteNotification: is called if your app is running (whether in the background or not).
So that would be the starting point to direct them to the specific UIView.
You can tell whether your app was just brought to the foreground or not in the code in the following answer
Hope this helps .

An event should invoke a method while the app is on Background-iphone

I need to invoke a method each time an event is occurred even if the application is in the background.
In my case -each time I get a picture from the server I want to present it,
and if the application is in the background I want it to reEnter the foreground and present the picture.
Is it possible? if not, what is the nearest alternative?
Thanks,
Asaf
i thnk this is not possible, but use notifications to do this that application will become active when it receive notification.
further see these threads
iPhone OS 4.0.x - transition from background to foreground
How to bring app to foreground programmatically

NSLocalNotification - show notification animation when the app is running in iOS5

Is it possible to show NSLocalNotification when the app is running and in the foremost position? As the Apple document says when the app is in the foremost position the notification will not be shown (it shows in notification center though, just doesn't have the flipping animation on top), then what's the point for method presentLocalNotificationNow: ?
You have to use your own UI to present notifications when your app is active. Use UIApplicationDelegate's application:didReceiveLocalNotification: method to find out when a notification is posted.
Notifications are designed to be triggered when the app is no longer active. And by default, they are suppresed if your app is active. So if you tell it to trigger Now, it won't because it won't display any notifications. For something immediate while your app is active, you would use alerts. I don't believe you will be able to override this default behavior.

How to ignore a local notification when iPhone is locked?

I am implementing a voip app for iphone. Upon receiving an incoming call, the app shows a local notification with two buttons : close and answer. If the user clicks on answer, the app shows in foreground and the call is answered, and if she clicks on 'close', the call is ignored.
The problem, however, is that when iphone is locked, there is no 'close' button, only a slider for which sliding from left to right means 'answer'. Hence there is no way to ignore the call.
Is there a way to solve this? The only solution I found so far is to show another notification for the user to answer or reject, but that seems inconvenient to use.
Re-locking the screen (using the sleep/lock button) usually constitutes ignoring a notification. Have you tested whether your app receives some kind of message when that happens?