Checking incoming call notification in iPhone - iphone

I am working on iPhone game application, in which user can play game and records some data.
My problem is that the application not supporting background processing. In my application if call's appearing then my application is terminated. But I need to save user current state.
I have read some blog and post in which they have mention that core telephony frame work can give us all such state and notification. But someone mention that core telephony API is an private API. If will use this API then APPLE accept my application or not? I need to save my application current state.

You are looking for the answers in the wrong place. You do not need any access to the telephony API.
Apps by default enter the background and return to the foreground, on modern devices and iOS versions - Perhaps you are running your app on an older device or on iOS version 3.x, in which case all apps (not just yours) will be terminated when they are "exited".
Even in this case the solution is not the telephony API, but handling a notification sent to your app about your application terminating - You can save state there, and then reload it when your app is re-run.
Check out these links for more information:
App states and transitions
Multitasking

Related

Acceptance of Location tracking app with nsTimer in background in apple market

I have created this location tracking app, that uses nstimer in background to fetch location every 4 mins.
I am wondering if there will be any problem in submitting the app in the market place..
If you know something regarding it, can you please let me know.
Thanx.
If it's relevant to what your app is doing I don't think it will be a problem.
This is from Apple's App Store Review Guidelines:
4.1 Apps that do not notify and obtain user consent before collecting, transmitting, or using location data will be rejected
4.2 Apps that use location-based APIs for automatic or autonomous control of vehicles, aircraft, or other devices will be rejected
4.3 Apps that use location-based APIs for dispatch, fleet management, or emergency services will be rejected
4.4 Location data can only be used when directly relevant to the features and services provided by the app to the user or to support
approved advertising uses
But pay attention that if you want your app to keep getting location updates even in background, you need to declare this in your plist file, otherwise when the app goes to background you won't be able to get location updates.
Declaring Your App’s Supported Background Tasks
Support for some types of background execution must be declared in
advance by the app that uses them. An app declares support for a
service using its Info.plist file. Add the UIBackgroundModes key to
your Info.plist file and set its value to an array containing one or
location—The app keeps users informed of their location, even while it
is running in the background.
I've gotten one app through. You have to make sure that the user is informed exactly as to what is going on. So dialogs have to be very specific and have a privacy policy in place.
4 minutes is a little bit extreme if that's a permanent state of your app.. I don't think Apple would allow that if they found it during app review. Would it not suffice to just have it updated based on movement? ie. the significant location change api?
The app I did this for used significant location change api for background location tracking and then stepped it up to higher frequency tracking if the app was actually open.

iPhone iOS5 iCloud do both apps have to be open to receive each other's iCloud updates?

I'm testing a library-based iPhone app with iCloud enabled. With such app, changes to the core data persistent store are propagated across multiple devices.
What interests me is: Do iCloud "documents and data" changes are propagated across devices when the app that needs to be updated is closed?
Scenario: Device A makes changes, Device B's app is closed. Once the user restarts device B some time later, the changes are already present.
or
Does the app have to be open on additional devices to request data model updates?
Scenario: Device A makes changes to iCloud based core data stack. Device B's app comes online, checks if there are changes, requests changes to be downloaded.
Thank you for the clarification!
The former option is closer to the reality, but neither of your options describes the situation correctly.
The point is, if you use CoreData with the iCloud, the update will come whenever
your app is running
and the OS decides it's the right time to tell the app.
Your app then passively respond to what the OS tells you, as in any event-driven app development. Read Apple's documentation and/or related WWDC slides available again on Apple's developer website.
Also, Drew McCormack has a series of great blog posts on this topic, called "Under the sheets with iCloud and CoreData", starting here.

iphone: backgrounded app sync webservice

I know this question may be a little bit common and over asked but I cannot find any precise information... so :
Is it possible to have some kind of thread running when the app is in background so I can perform basic sync with my webservice ?
App is in background : I mean the user clicked the Home button, or switched to another app
basic sync : photo upload and download with AFNetworking. I know it has method to continue an HTTPRequest while app is in background, but this is not my point.
My goal would be to make some kind of sync manager, reading a list of photos to update created while the user was on the app, and perform those changes.
I know that the manager could be killed by the OS, but since my server uses atomic transfers it is not a problem. I just need a way to relaunch it... Push ?
I think apps like Google Latitude or Mail and those kind of apps uses what I am looking for but I cannot find any relevant details on it. And using iOS5 is not a problem but waiting for iOS6 would not be a solution.
Thank you for your replies !
PS : well I almost forgot. the app is designed for an enterprise program, so maybe rules are different ? I don't think there is any check for in-house deployment so it might lead to new possibilities...
Apple's Mail client has a background daemon which keeps it running but you can't have that with your own applications. Once an app enters a background state, it must halt it's operations. You can request for a little more time when backgrounded to finish off any transfers or writes to disk (see the Executing a Finite-Length Task in the Background section on Apple's Multitasking Guide)
Google Latitude has events generated based on location. This is a special type of backgrounding introduced by Apple for certain types of applications (see Implementing Long-Running Background Tasks section on Apple's Multitasking Guide) but this can't be used for HTTP syncing. It can only be used for audio, location, voip, newstand content, bluetooth and external hardware attachments.
Push doesn't seem like a solution because it only generates an alert. It doesn't trigger any action until the user triggers the opening of the notification.
You'll want to read Tech Note 2277 Networking and Multitasking.
Basically you have a couple of options:
If you can convince Apple that your app is a VoIP app then you can register a VoIP socket and the OS will resume your background app whenever there is activity on that socket.
Your main option though is to register a background task for any outstanding activity that you have to do when your app is put in the background. You typically get 10 minutes to finish up that work.
Mail is a special app with privileges you don't get.
Apps like Latitude typically register themselves for location updates, specifically to be woken up when there are major geo-position changes. Apps that record GPS tracks do similar things.
Found it !
Using Suhail Patel 's link on Apple's Multitasking Guide I added the voip tag to UIBackgroundModes in Info.plist and use setKeepAliveTimeout:handler: method of UIApplication to relaunch it if needed once the app is going to sleep.
I hope this will help a lot of you !
Of course this app won't be allowed to be on the App Store but for in house development this is in my opinion the best way to do so.
Thanks everyone for showing me the right direction !

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.

sms notification

I am a new iphone application developer.
i am making an application which requires an incoming message notification even if the application is closed.
can anybody tell me how to do that...
Thanks
Rachit Taneja
Apple has not implemented a way for your application to listen for incoming text messages or phone calls. iOS only sends out notification about changes to your applications state. For example, when your phone rings in which case your application will receive the applicationWillResignActive (on versions older than iOS4 applicationWillTerminate) notification.
Strictly speaking these are not actual notifications, these methods will be called in your applications delegate.
The closes solution would probably be what Brad suggests in this thread.
You can use core telephony framework but you cant upload your app on app store.Because it's private framework which apple doesn't allow.Using this framework you can send sms upto ios 5 for ios 6 i am looking into this.