anoop
anoop

Reputation: 91

How to detect when a phone call is triggered when the application is up?

My application is a coupon shopping,users will download the coupons in phone and when completed they will be directed for the automatic cash payment. If a user downloads 5 coupons and inbetween gets a call as it is iOS4 it goes to background. So when we press the home button also the application goes to background by this behaviour.I have save few data and restore the coupons when the user quits the application by homebutton. But in iOS 4 behaviour homebutton press and phone call interruptions shows the same behaviour and calls the same functions,how i could differentiate between the 2. Please this is a tedious function,please help me.......

Upvotes: 2

Views: 988

Answers (2)

Mr. Berna
Mr. Berna

Reputation: 10655

iOS will not tell an app what caused an interruption such as a phone call, an SMS message, or a press of the home button. This is a deliberate design decision by Apple. Apple expects apps to be designed to exhibit the same behavior no matter what caused the interruption.

Upvotes: 1

EmptyStack
EmptyStack

Reputation: 51374

Without multi-tasking: For applications that do not support background execution or are linked against iOS 3.x or earlier, applicationWillTerminate: method is always called when the user quits the application. For applications that support background execution, this method is generally not called when the user quits the application because the application simply moves to the background in that case.

With multi-tasking: You can implement applicationWillResignActive:delegate method in your app delegate, which gets called during temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.

- (void)applicationWillResignActive:(UIApplication *)application {

    flag = YES;
    [self doCleanUp];
}


- (void)applicationWillTerminate:(UIApplication *)application {

    if (!flag) [self doCleanUp];
}

Upvotes: 2

Related Questions