0

In Xcode I have added Background mode capabilities, Because of which I am able to execute code in Background.

How I validate this

I checked this through scheduling NSTimer to print logs. Timer is printing logs perfectly with Application state as UIApplication.State.background, When installed on the device through Xcode.

But when the same app is uploaded to Test flight and installed on the device. Timer is only able to log Active and InActive State but not able to log UIApplication.State.background.

Hence my app is not running in background when installed from Test flight.

Can Anyone help me out with this bug or missing checks. Attaching the image of my capabilites and info plist enter image description here enter image description here

7
  • 1
    Background is never guaranteed and Timer is known to not survive background. You have to find a different approach. Commented Jun 5 at 14:05
  • Hey Background is never guaranteed when you look for background task identifer, then in that case its depend on iOS whether it grant you or not. But through background modes its guarnteed as I have test this in my build installed directly through Xcode. Commented Jun 5 at 14:15
  • 1
    I’m sure you were is DEBUG mode and that is why it was working. There are many reasons why something works when installed from Xcode and not production. Commented Jun 5 at 15:11
  • What are you doing in the background? You're declaring multiple unrelated background modes (which will get you rejected if you're abusing any of these btw), so it's hard to tell how iOS is supposed to grant you background privileges. How are you triggering the background execution? Is it via a background task? Incoming VOIP call? You need to edit your question to include all relevant code in the form of a minimal reproducible example in order to make the question on-topic. Commented Jun 5 at 16:36
  • 1
    Apps behave differently when installed/running via Xcode to when they are installed via Testflight/appstore. But what are you expecting those background modes to do anyway? I get the impression you think adding them will mean your app will constantly run in the background, no it won't, they don't work like that.
    – Piepants
    Commented Jun 5 at 16:45

0

Browse other questions tagged or ask your own question.