Make call when app is in background

The app I have created use GPS position for making calls automatically: when applications is in foreground app make call correctly but when app itself is in background don't happen anything: can I solve, if is possible make calls when app is in background?

Accepted Reply

… however I don't use any API …

Last I checked,

-openURL:
was an API (-:

Seriously though, if your app is in the background,

-openURL:
is a no-op. This is a long-standing restriction that prevents background apps from switching the frontmost app out from underneath the user. There’s no way around this, and there’s no alternatively approach for starting a phone call.

What we recommend in situations like this is that you post a local notification where the default button activates your app; your app will then be able to present whatever UI it likes. The only problem in your specific case is that your UI will switch apps again (to the Phone app) which is not the most elegant solution.

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"

Replies

What do you mean by “call”? A phone call? What API are you using to maket it?

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"

...yes, I mean a phone call: however I don't use any API, only the below function that work when app is in foreground.

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:[NSString stringWithFormat:@"tel:%@", telephoneNumber]] options:@{} completionHandler:nil];

I wait your advice!


PS If you prefer that I send an email you only have to say to me...


Bye

… however I don't use any API …

Last I checked,

-openURL:
was an API (-:

Seriously though, if your app is in the background,

-openURL:
is a no-op. This is a long-standing restriction that prevents background apps from switching the frontmost app out from underneath the user. There’s no way around this, and there’s no alternatively approach for starting a phone call.

What we recommend in situations like this is that you post a local notification where the default button activates your app; your app will then be able to present whatever UI it likes. The only problem in your specific case is that your UI will switch apps again (to the Phone app) which is not the most elegant solution.

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"

Firstly, thanks for your reply and, secondly, for your advice…but I need an app that work in completely automatic mode and since there isn't any way around this I would ask you if I can send automatic SMS (always in background) instead make a telephone call.


Thanks in advance.

… but I need an app that work in completely automatic mode …

You’re not going to be able to do this on device. This is a pretty basic security measure; we don’t want apps making calls or sending text messages without the user’s explicit consent.

One option that I’ve seen other developers use is to set up their own SMS gateway. When your app needs to send a message, it uses TCP/IP networking (which is available in the background) to make a web service request to that gateway, at which point the gateway sends the SMS on the app’s behalf. That way you’re responsible for dealing with the security aspects (billing, spam avoidance, and so on) of these messages.

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"

Would it be possible to make a call by using Actions inside notification (while in the background), with CallKit?

Would it be possible to make a call by using Actions inside notification (while in the background), with CallKit?

I think it’d be better for you to start a new thread for that specific question. Feel free to reference this one if you think the info here is relevant.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"