5 Replies
      Latest reply: Oct 27, 2016 12:52 AM by eskimo RSS
      mapan3 Level 1 Level 1 (0 points)

        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?

        • Re: Make call when app is in background
          eskimo Apple Staff Apple Staff (6,490 points)

          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"

            • Re: Make call when app is in background
              mapan3 Level 1 Level 1 (0 points)

              ...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

                • Re: Make call when app is in background
                  eskimo Apple Staff Apple Staff (6,490 points)

                  … 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"

                    • Re: Make call when app is in background
                      mapan3 Level 1 Level 1 (0 points)

                      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.

                        • Re: Make call when app is in background
                          eskimo Apple Staff Apple Staff (6,490 points)

                          … 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"