So how to get GPS updates when app is in background?

I obviously removed some protected names and numbers in there, but overall that is the entire build.settings file

Can you file a bug report please. We need a sample that works and demonstrates the problem. It must be a complete project: main.lua, config.lua, build.settings and any assets needed to run. Put this in a .zip file and use the “Report a bug” feature at the top. When you get the confirmation email, please post the CaseID number back here.

This is something that should have never worked. We specifically turn off the GPS on Android and Windows Phone 8 on suspend. It cannot be working there. As for iOS, it should have not worked either though we’ve not heard back if we explicitly turn it off or not.  While asking for a bug report does not imply that we will in any way support this going forward, we do want to know what’s going on.

Rob

Hi Rob, 

I filed a bug report already over the weekend, (case #43891)

I’m sorry for not mentioning that before.

The app that is zipped up in the bug report should be able to replicate the issue -it’s just the sample code with the bg services attempting to run in the background as it has for years now.

The only two pieces of code ever required for me to put GPS in background services are:

UIBackgroundModes = {"location","remote-notification"},

and recently:

NSLocationWhenInUseUsageDescription = "A description to the user of why you need access to location services.", },

Both of them in the build.settings file

Regarding the statement “should have never worked” I find very difficult to swallow for a few reasons. Having been developing on Corona since 2010, and showing our app “Chirp” to David, and Walter myself in person at a couple different events - I know the background services have worked, since all the way back to 2012 when Chirp was first developed.

Chirp is now a top 20 travel app and is in need of an update, which was routine until very recently (iOS 9 related I think).

To reiteration what “I” think this is being caused from -as it relates to iOS, this post: http://stackoverflow.com/questions/32758125/ios9-not-tracking-location-while-in-background speaks of;

if ([self.locationManager respondsToSelector:@selector(setAllowsBackgroundLocationUpdates:)]) {[self.locationManager setAllowsBackgroundLocationUpdates:YES]; }

as a new bit of code (native), needed for BG services on an iOS 9 device.

I hope that helps with some history here, if you want to jump on a call or chat PM I’m available usually day and night and this is a high priority for us, as you can imagine.

I’m on the hunt for an answer and found this post so I wanted to chime in for some feedback from you guys. It seems like the background services for GPS location no longer works using Corona built towards an iOS 9 device. I’ve tried most scenarios I’ve found, nothing works. Not even the example code (modified build settings of course).

It seems to all point towards this: http://stackoverflow.com/questions/30808192/allowsbackgroundlocationupdates-in-cllocationmanager-in-ios9

Anyone else having issues like this?

My app has been in the market for a long time running just fine, even as recent an September 2015 with an update (pre iOS 9).

Do you have this in your build.settings?

NSLocationWhenInUseUsageDescription = “This app uses maps and GPS when active to …”,

I don’t know how much that Apple wants you running the GPS in the background any more.

Rob

Yep, have that. And the app I’m talking about is a top 100 app and been published for two years. Apple is fine with the app - it’s the Corona build to iOS compatibility. 

Try to get the sample project to run in the background (after making the neccessary adjustments to build.settings) and you’ll see what I mean. 

Can you try including this key in your build.settings:   NSLocationAlwaysUsageDescription

It takes a string saying why you always want to use the GPS.

Rob

Hey Rob, 

Yeah - I’ve tried both strings - by themselves, and together, nada.

NSLocationWhenInUseUsageDescription = “blah blah blah”,

NSLocationAlwaysUsageDescription = “blah blah blah blah.”,

I’m at a total loss here.

I know Corona doesn’t officially support running BG services in the background but it’ been working fine until iOS 9 and I really, really think it has to do with the way is access core services.

From:http://stackoverflow.com/questions/32758125/ios9-not-tracking-location-while-in-background

This new property is explained in the WWDC session “What’s New in Core Location”.

The default value is NO if you link against iOS 9.

If your app uses location in the background (without showing the blue status bar) you have to set allowsBackgroundLocationUpdates to YES in addition to setting the background mode capability in Info.plist. Otherwise location updates are only delivered in foreground. The advantage is that you can now have location managers with background location updates and other location managers with only foreground location updates in the same app. You can also reset the value to NO to change the behavior.

I know if this isn’t fixed, it will be a deal killer for me and anyone else using bg services in Corona and publishing an update to > iOS 9

Rob, any update on this? I’m still waiting on a response from Corona.

First of all, it’s the weekend. I’m not going to get any information over the weekend. Secondly, our official response is Corona SDK does not support backgrounding apps. As you said, there’s not “official” support. There is no “kind of supports” either.

Apple made changes in iOS 9. While they allow backgrounded nav apps, they discourage it to save battery life and they want people to know their movements are being measured while backgrounding.

We are having a discussion (during normal business hours) about it. I wouldn’t expect an answer for a few days.

Rob

Just to give me some ammo to go to bat for you, can you provide the links to your app store entries for this app?

Rob

Hi Rob, sure. You can find the iOS and Android  app downloads at http://chirpgps.com

It is #44 on top grossing travel apps again today -

Thanks.

Richard

Can you post your build.settings please?

Thanks

Rob

settings =

{

plugins =

   {

      [“plugin.facebook.v4”] =

{

publisherId = “com.coronalabs”

},

      [“plugin.OneSignal”] =

   {

       publisherId = “com.onesignal”,

   },

   [“plugin.google.play.services”] =

   {

publisherId = “com.coronalabs”,

supportedPlatforms = { android=true, [“android-kindle”]=true },

   },

   },

orientation = {

default = “portrait”, 

supported = {“portrait”},

},

  android =

        {

        versionCode = “5”,

        installLocation=“preferExternal”,

        usesPermissions =

{

“android.permission.INTERNET”,

       “android.permission.ACCESS_FINE_LOCATION”,

“android.permission.ACCESS_COARSE_LOCATION”,

       “android.permission.WRITE_EXTERNAL_STORAGE”,

       “android.permission.VIBRATE”,

       “android.permission.GET_ACCOUNTS”,

“android.permission.RECEIVE_BOOT_COMPLETED”,

“com.google.android.c2dm.permission.RECEIVE”,

“.permission.C2D_MESSAGE”,

},

intentFilters =

     {

        {

           label = “nothing.nothing.com”,

           actions = { “android.intent.action.VIEW” },

           categories =

           {

              “android.intent.category.DEFAULT”,

              “android.intent.category.BROWSABLE”,

           },

           data = { scheme = “test” },

        }

     },

        },

iphone =

{

plist =

{

UIBackgroundModes = {“location”, “fetch”, “remote-notification” },

            NSLocationUsageDescription = “Just some text.”,

            NSLocationWhenInUseUsageDescription = “Just some text.”,

            NSLocationAlwaysUsageDescription = “Just some text.”,

            CFBundleIconFile = “Icon.png”,

       CFBundleIconFiles = {

          “Icon.png”,

                “Icon@2x.png”,

                “Icon-60.png”,

                “Icon-60@2x.png”,

                “Icon-60@3x.png”,

                “Icon-72.png”,

                “Icon-72@2x.png”,

                “Icon-76.png”,

       },

       UILaunchImages = {

        {  – iPhone 6 Plus LandscapeLeft

                    [“UILaunchImageMinimumOSVersion”] = “8.0”,

                    [“UILaunchImageName”] = “Default-Landscape-736h”,

                    [“UILaunchImageOrientation”] = “LandscapeLeft”,

                    [“UILaunchImageSize”] = “{414, 736}”

                },

                {  – iPhone 6 Plus LandscapeRight

                    [“UILaunchImageMinimumOSVersion”] = “8.0”,

                    [“UILaunchImageName”] = “Default-Landscape-736h”,

                    [“UILaunchImageOrientation”] = “LandscapeRight”,

                    [“UILaunchImageSize”] = “{414, 736}”

                },

       },

       NSAppTransportSecurity =

{

NSAllowsArbitraryLoads = true

},

       UIAppFonts = 

{

“Avenir-Book.ttf”

},

       FacebookAppID = “777777777777”,

       

UIApplicationExitsOnSuspend = false,

CFBundleURLTypes =

{

{

CFBundleURLSchemes =

{

“77777777777777”,

“testing”

}

}

},

       UIPrerenderedIcon = true,

CFBundleDisplayName=“Appname”,

CFBundleIdentifier=“app.name.here”,

CFBundleVersion=“10.2”

},

}

}

I obviously removed some protected names and numbers in there, but overall that is the entire build.settings file

Can you file a bug report please. We need a sample that works and demonstrates the problem. It must be a complete project: main.lua, config.lua, build.settings and any assets needed to run. Put this in a .zip file and use the “Report a bug” feature at the top. When you get the confirmation email, please post the CaseID number back here.

This is something that should have never worked. We specifically turn off the GPS on Android and Windows Phone 8 on suspend. It cannot be working there. As for iOS, it should have not worked either though we’ve not heard back if we explicitly turn it off or not.  While asking for a bug report does not imply that we will in any way support this going forward, we do want to know what’s going on.

Rob

Hi Rob, 

I filed a bug report already over the weekend, (case #43891)

I’m sorry for not mentioning that before.

The app that is zipped up in the bug report should be able to replicate the issue -it’s just the sample code with the bg services attempting to run in the background as it has for years now.

The only two pieces of code ever required for me to put GPS in background services are:

UIBackgroundModes = {"location","remote-notification"},

and recently:

NSLocationWhenInUseUsageDescription = "A description to the user of why you need access to location services.", },

Both of them in the build.settings file

Regarding the statement “should have never worked” I find very difficult to swallow for a few reasons. Having been developing on Corona since 2010, and showing our app “Chirp” to David, and Walter myself in person at a couple different events - I know the background services have worked, since all the way back to 2012 when Chirp was first developed.

Chirp is now a top 20 travel app and is in need of an update, which was routine until very recently (iOS 9 related I think).

To reiteration what “I” think this is being caused from -as it relates to iOS, this post: http://stackoverflow.com/questions/32758125/ios9-not-tracking-location-while-in-background speaks of;

if ([self.locationManager respondsToSelector:@selector(setAllowsBackgroundLocationUpdates:)]) {[self.locationManager setAllowsBackgroundLocationUpdates:YES]; }

as a new bit of code (native), needed for BG services on an iOS 9 device.

I hope that helps with some history here, if you want to jump on a call or chat PM I’m available usually day and night and this is a high priority for us, as you can imagine.