How to run an app in the background in Swift 3.0

Asked 2 years ago, Updated 2 years ago, 26 views

I am currently creating a healthcare application, and I store the data that CoreMotion acquired during the application launch as numerical data in the location of HealthKit.What should I do if I always want to do this in the background instead of starting the app?

swift

2022-09-29 20:27

1 Answers

I'm a hobby programmer.
I'm sorry if I'm wrong, but I've looked it up for my own study, so I'll give you an answer.

I looked it up online and found out that
In Japanese, I found a way to continue processing in the background with Swift 2.2.
http://qiita.com/SatoTakeshiX/items/8e1489560444a63c21e7

Just write a few lines in AppDelegate.swift.
It's amazing that it can be realized without being tied to the processing program itself.
I have confirmed that using NSTimer works well in my environment (swift2.2).

It's not my environment, so I feel a little less confident, but
According to the detailed English site...
https://www.raywenderlich.com/92428/background-modes-ios-swift-tutorial

When it comes to the features you want,
①Use CoreLocation ("Receiving Location Updates")
②Available in all cases ("Perform finite-length tasks:")
I guessed that it was one of the .

In the case of の,
1. Select the target of the app top and select
from Capabilities -
Back in Xcode, do the following:
on the page 2. Turn BackGround On, Open, and Check Location Updates Inside
3. Add the NSLocationAlwaysUsageDescription key to Info.plist
- Huh? This is the basic thing you need to get GPS, right?

is described as

In the case of の,

Performing Finite-Length Tasks…or, Whatver
in the page It's not exactly background processing, it's API.

The procedure is
Add 1.5 properties to view for processing
2. I would like to continue, but

Also, it will become thinner, so I'll have you read the actual page.
Copy the code, download the sample code, try moving it, etc.
I would appreciate it if you could understand it somehow.

By the way, regarding the background processing repeatedly on this page,
Do you really need it in terms of battery consumption? Don't use it easily.
It is said that it will be difficult to reconsider and review, so
If it is a release application, you may need to be careful about how to code.

I'm sorry that the last one didn't answer.
I hope it helps.


2022-09-29 20:27

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.