iOS App restarts when it comming from background

Jasonix 1 Reputation point
2021-03-25T12:35:05.323+00:00

Hi,

when my App is in the background and i tap on it, so it goes in the foreground, the App restart automatically.
I know Apple kill the session to clean the memory. But my has a timer, like a stoppwatch. And I need the running time when it comes in the foreground.
How can I fix this issue?

Thanks for your help :)

Xamarin
Xamarin
A Microsoft open-source app platform for building Android and iOS apps with .NET and C#.
5,377 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Cole Xia (Shanghai Wicresoft Co,.Ltd.) 6,751 Reputation points
    2021-03-26T04:19:15.203+00:00

    Hello,

    Welcome to Microsoft Q&A!

    There is a strict time limit for background task , we only have less 10 minutes(from iOS7) to handle logic .

    To register the app to run in the background , your app should be included in the following Categories .

    Audio , VoIP , External Accessories and Bluetooth , Newsstand ,Location ,Fetch ,Remote Notifications .

    Apple would never allow us to run a single Timer in the background .

    As a workaround , I suggest you store the time(into file or something else) before going to background , and get the current time when opening it again , then you will easily get how many time it spent in background .


    If the response is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.