iOS Question How do I create the equivalent of the service module

davepamn

Active Member
Licensed User
Longtime User
What b4i function and call back functions replace the service module?

Can you provide a small demonstration
 

davepamn

Active Member
Licensed User
Longtime User
Ok
Then how do I create a threaded function in b4i

Should I always use a timer call back function

Will the timer function only run when the app is active
 
Upvote 0

Peter Simpson

Expert
Licensed User
Longtime User
Directly from Apple's Documentation:

Implementing Long-Running Background Tasks
For tasks that require more execution time to implement, you must request specific permissions to run them in the background without their being suspended. In iOS, only specific app types are allowed to run in the background:
  • Apps that play audible content to the user while in the background, such as a music player app
  • Apps that keep users informed of their location at all times, such as a navigation app Apps that support Voice over Internet Protocol (VoIP) Newsstand apps that need to download and process new content
  • Apps that receive regular update from external accessories
Apps that implement these services must declare the services they support and use system frameworks to implement the relevant aspects of those services. Declaring the services lets the system know which services you use, but in some cases it is the system frameworks that actually prevent your application from being suspended.

~/End of Line
 
Upvote 0

Peter Simpson

Expert
Licensed User
Longtime User
Background Execution


When the user is not actively using your app, the system moves it to the background state. For many apps, the background state is just a brief stop on the way to the app being suspended. Suspending apps is a way of improving battery life it also allows the system to devote important system resources to the new foreground app that has drawn the user’s attention.

Most apps can move to the extended state easily enough but there are also legitimate reasons for apps to continue running in the background. A hiking app might want to track the user’s position over time so that it can display that course overlaid on top of a hiking map. An audio app might need to continue playing music over the lock screen. Other apps might want to download content in the background so that it can minimize the delay in presenting that content to the user. When you find it necessary to keep your app running in the background, iOS helps you do so efficiently and without draining system resources or the user’s battery. The techniques offered by iOS fall into three categories:

  • Apps that start a short task in the foreground can ask for time to finish that task when the app moves to the background.

  • Apps that initiate downloads in the foreground can hand off management of those downloads to the system, thereby allowing the app to be suspended or terminated while the download continues.

  • Apps that need to run in the background to support specific types of tasks can declare their support for one or more background execution modes.
Always try to avoid doing any background work unless doing so improves the overall user experience. An app might move to the background because the user launched a different app or because the user locked the device and is not using it right now. In both situations, the user is signaling that your app does not need to be doing any meaningful work right now. Continuing to run in such conditions will only drain the device’s battery and might lead the user to force quit your app altogether. So be mindful about the work you do in the background and avoid it when you can.
 
Upvote 0

fishwolf

Well-Known Member
Licensed User
Longtime User
Apps that need to run in the background to support specific types of tasks can declare their support for one or more background execution modes.

is it possible do a simple update data process?

1) scheduler a daily event
2) call a download procedure data
3) if data have a specific value, show a notification.

similar to facebook app
 
Upvote 0

Shay

Well-Known Member
Licensed User
Longtime User
Directly from Apple's Documentation:

Implementing Long-Running Background Tasks
For tasks that require more execution time to implement, you must request specific permissions to run them in the background without their being suspended. In iOS, only specific app types are allowed to run in the background:
  • Apps that keep users informed of their location at all times, such as a navigation app Apps that support Voice
~/End of Line

I need to track user location every few seconds, how do I do it?
In B4A I have service for it
 
Upvote 0

Shay

Well-Known Member
Licensed User
Longtime User
The app need to track your location and either show it on google map or to report to other users your location. Such as GetTexi
 
Upvote 0

Shay

Well-Known Member
Licensed User
Longtime User
I think "Endomondo" is using background location tracking and it is not navigation app
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
Upvote 0
Top