How to find out if the application restarted after a phone call?

I have a program that automatically starts a phone call when the program starts. This is implemented in the AppDelegate "applicationDidFinishLaunching" method.

Problem: when the phone call ends and my application starts automatically again, it restarts this cycle and the phone call starts again.

How do I know if an application was returned from this call? Or is it somehow easy to save state or program variables that determine whether a call has already been made?

I just started programming the iPhone, and it came.

+3
source share
3 answers

, , BOOL application NSUserDefaults, , , . callWasMade.

callWasMade NO, YES, NSUserDefaults .

callWasMade (YES) NSUserDefaults, .

NO, .

+1

. , , . , , .

(.. , , ).

, , , Apple Apple.

+3

UIWebview , :

Return to application behavior after talking on the phone in native code than UIWebView

and use basic telephony to check if the call has ended:

//before calling loadRequest:
CTCallCenter *callCenter.callEventHandler=^(CTCall* call) {

        if(call.callState == CTCallStateDialing)
        {
            //The call state, before connection is established, when the user initiates the call.
            NSLog(@"Dialing");
        }
        if(call.callState == CTCallStateIncoming)
        {
            //The call state, before connection is established, when a call is incoming but not yet answered by the user.
            NSLog(@"Incoming Call");
        }

        if(call.callState == CTCallStateConnected)
        {
            //The call state when the call is fully established for all parties involved.
            NSLog(@"Call Connected");
        }   

        if(call.callState == CTCallStateDisconnected)
        {
            [self release];
            NSLog(@"Call Ended");

        }

    };
0
source

Source: https://habr.com/ru/post/1709080/


All Articles