How to get phone call ended notification after application is closed for iPhone? - iphone

In an iPhone app every time I end the phone call I want to ask user for yes/no type question & if 'Yes' is clicked the launch my application. I know I can get notifications for call end using CTTelephone but my question here is that is it possible to get the notifications even after my application is closed. If I run my application in background then there are chances that system closes it on low memory. Moreover apple doesn't support for continuos background application.

No, you will not get notification if your app is close. Since you app does not fall in one of the background modes you will not be able to run the app in the background.
In short, the functionality you want is not possible with the official Apple SDK and guidelines.

Related

Close iPhone app from within the app

Is there a way to close the iPhone app from within the app? A client asked me if there was a way to close the app by pushing a button in the app, without manually doing it by double tapping the home button and then press-hold the app icon and then hit the - sign.
Apparently, the client wants to build an app which uses bluetooth and ANT+ devices which are battery hogs and wants the ability to quickly close the app.
Any thoughts?
I'm thinking you should just make the button dispose of the Bluetooth and other 'battery hogs'. You might even make the app smart enough to turn it off based on certain events like when the user leaves the app or when a certain function is completed.
Aside from quitting from a button within the application being against the Apple Human Interface Guidelines, it isn't even recommended behaviour.
But if you still want to close your app. Use 'exit();'.
This behavior is against Apple's Human Interface Guidelines. If you still want to do so, use the C function exit();. But for the user this will look like the application crashed, so I wouldn't do so, even not on an non-AppStore app!

How iPhone application WeatherTunes realized running in the background [duplicate]

This question already has an answer here:
Closed 10 years ago.
Possible Duplicate:
How To Switch music from my app to the ipod
There is an iPhone application named WeatherTunes (天气旋律闹钟 in Chinese) in iPhone AppStor, search with key words "WeatherTunes " e, it appears at the first.
You can add alarm in WeatherTunes, even if you switch this application to background, it still runs. I look into its info.plist file, I noticed it set the "required background modes" with value "App plays audio". But I still can't figure out how it can be run in background? Thanks for any help.
Apps can run in the background if they have any of the 5 requirements:
Apps that play audio while in the Background state. A good example is Instacast while it’s playing a podcast.
Apps that track your location in the background. For example, you still want voice prompts from your turn-by-turn GPS navigation app, even if another app is Active.
Apps that listen for incoming voice-over-IP (VOIP) calls. If you use Skype on iOS, you can receive incoming Skype calls while the app is in the background.
Newsstand apps that are downloading new content.
Apps that receive continuous updates from an external accessory in the background.
It may be possible that this app is playing a silent audio file in the background, a tactic that I have seen before, but generally that will be rejected from the apple store.

Can I create a background service on iphone?

I am developing an iphone app. the iphone which install my app was asked to upload it's location every minute(or hour) to a webservice. So what should i do with this situation?
I know there is a corelocation framework, I could use it for my app. like when I run this app, the corelocation will grab the GPS for my. my question is what if I close the app? Can i still get the GPS and upload it to webservice every minute? If I can't, how could I ?
You could enable background location service, If application is in background and receives a considerable change in location it will activate the app for a brief amount of time, This will give you some time to process. Apple recommends not to use web-service calls during this time, because there wont be any guarantee that the app would be live when it returns back. But since you just want to update the location, you could just post it and dont have to wait for response. Please note that significant location change should be used and this will help you to save your device's battery life. This is when the app is in background state.
May be you could try registering for the proximity/location alert or something. But i am not sure whether it would help when app is closed.
If your app is running in the background then you can get the GPS data but it the application is removed from the Background then you cannot get the GPS data. This is not possible in iPhone.

How to invoke a method daily at a specific time in iPhone application?

I want to invoke a method daily at a specific time in my iPhone application.
How can I achieve this?
There's not a whole lot you can do with the iPhone SDK and a closed app. You can have it send local push notifications at specific times, but that won't execute your code until the user manually opens your app.
See this related question recently asked: Is it possible to have my closed app run code in iOS?
One thing I've seen apps do (like alarm clock apps, etc) is have you leave your app open and just let the phone fall asleep and then it will still execute code when you want it to. But that only works as long as the user doesn't hit the home button.
Schedule a local notification. This is how most basic alarm apps work. The app needs to be running sometime before the method execution time to schedule a local notification. After the local notification has been scheduled, the app can be closed and the method will be invoked at the specific time.
If you have push notifications configured, then your app does not need to run at all to schedule the method. It can all be done from another application.
Check out this documentation on local and push notifications from Apple.
you cannot run a specific code inside your application when its not running ..iOS allow only limited functionality to be run in background or when app is quit.

possible for an iPhone app to make the iPhone "go dark" for a specified number of minutes?

Can an iPhone app be made to stop all calls and text messages for a specified number of minutes, that is, prevent the user from making or getting calls and messages? Can an app turn the device off temporarily? Context: help kids to concentrate while doing their homework/studying and not be interrupted with calls and text-messages from their schoolmates.
Not if you want to get into the App Store or run on non-jailbroken devices, no. One of the guiding principles of the SDK is that you can't "break" core functionality like inbound phone calls or SMSs. You will get notified that your app is about to enter a background state (or terminate), but you can't stop the user taking the call or terminating your app.
For information in events that you do get, have a look at UIApplication and UIApplicationDelegate.