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.
Related
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 .
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
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]
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?
In iPhone OS 3.0, UIApplication allows you to set a applicationSupportsShakeToEdit flag. The documentation says "The default value is YES. Set the property to NO if you don’t want your application to display the Undo and Redo buttons when users shake the device."
This is all great and it ties in to the new NSUndoManager class nicely. However - I don't want to use the built in NSUndoManager in my app! I'm writing a drawing app, and I already have an undo/redo manager that does some fancy stuff (it manages the data required for each undo operation, and will page it to disk if the app is low on memory). I'd much rather just listen for a notification from the UIApplication and trigger undo myself. (I could just make a bogus NSUndoManager, but I also don't want the "Are you sure?" panel to show...)
Does anyone know if such a notification exists? I figure it must - but I can't find it documented anywhere. Is there a way to monitor all notifications going through the app, maybe?
Thanks!
You may well have solved this issue by now, but in case someone comes across this searching for a Shake solution as I did I laid out how you can get the 3.0 Shake event messsages easily in this thread:
How do I detect when someone shakes an iPhone?
It outlines how you can respond to shake without using an UndoManager or presenting the Undo API. Even if you set applicationSupportsShakeToEdit to NO, these events will still be received..