Post not yet marked as solved
The app retreats to the background for 1 day. When entering the app, you need to refresh the data from the new drop-down. In the background one day, does the controller automatically clear the interface and data? How to obtain the data from the new one
Post not yet marked as solved
Hello!
Can someone please confirm whether or not an app will trigger background fetch after it has been force-quit by the user?
Currently my app works performs background fetches correctly when it has been backgrounded, but after force-quitting the app it stops fetching.
Specifically I am referring to scheduled background fetches, not fetches initiated by notifications - although I am interested to know if that would be an alternative.
I've tried searching online and there's a lot of confusing and contradictory information about this - including old Apple documentation that explicitly says it will not launch, however that documentation has since been removed. The new documentation does not explicitly mention the force-quit scenario.
Can anyone please confirm?
Thanks!
Post not yet marked as solved
Hi, i'm quite new to iOS Development and i'm looking for some useful informations for my project.
The phone connects to a device via BLE and receives data from it at an high rate ( 4x hundreds data points per seconds) [--> Thread 1 ]
and this data need to be analyzed in real time [--> Thread 2].
The app has to work for between 1 to 8 hours and all of this needs to work both when the phone is in the foreground and when is in the background (Background Task).
Can you help me with any useful tips / information on how to accomplish this?
Thank you
Post not yet marked as solved
We use External accessories framework for Bluetooth communication with medical equipment.
Mobile App was in Foreground but iOS (15.5 beta) triggered AppDelegage callback applicationDidEnterBackground event, when external accessories framework establish the connection to or disconnect from the medical equipment.
iOS should trigger this event only when the user moves application to background. We encounter this issue in iOS 15.5 Beta version, which seems to be iOS 15.5 beta issue.
Post not yet marked as solved
Hi,
I have implemented iCloud Sync using NSPersistentCloudKitContainer. However, I have a lot of data to sync in my use case which can take quite some time (minutes) especially when starting with a new device (10's of minutes).
I was wondering if there is a way to make good use of BGProcessingTaskRequest (ie long running task over night, potentially with requiresExternalPower). The idea is to let the device catch up with the remote store during such a long running background task over night/during charge.
I already tried to hack my way into this by trying to just listen to sync events during the task and not finish the task until sync events have stopped but it seems the sync processor does have its own awareness of the app moving to the background and therefore might not even wake up during the background task.
Any idea how I can help the CloudKitContainer to catch up in the background with very large workloads?
Thanks!
Post not yet marked as solved
This is happening on all iOS 15 apps. I am running on an iPhone 12 mini (iOS 15.4.1)
Open any app
Close the app and quickly reopen. This will cause the app to crash if you do it fast enough. It seems to work as expected if you wait at least one second before reopening.
To resolve this issue close ALL background apps so the "recent apps" are empty. When you do this, the problem in step 2 does not happen. To "re-activate" the crash, open 5 to 10 apps and put them in the background. All apps will then continue to crash when re-opening.
All of our crash reports have been for devices running iOS 15. We believe some of the packages we use are having trouble initializing correctly when the app state changes. None of our crashes have been on iOS 14.
https://drive.google.com/file/d/1Gg00d9N1_N94yxkHpyfVAqiCEiTX9c1M/view?usp=sharing
Post not yet marked as solved
Hello,
Our app gets rejected by Apple multiple times because of the use of location in UIBackgroundModes:
Your app declares support for location in the UIBackgroundModes key in your Info.plist file but still does not have any features that require persistent location. Apps that declare support for location in the UIBackgroundModes key in your Info.plist file must have features that require persistent location. Specifically, we were unable to locate features within the app that needs to use location in the background. Our answer in the Resolution Center was this:
This app is monitoring UUID’s to detect iBeacons in the background. The proces is as following: When the device is in range of an iBeacon, the app is activated in the background by a call on the delegate function ‘didEnterRegion’ from CLLocationManager.
The app starts ranging for iBeacons to detect the Major and Minor.
The app uses that information to know which desk this is and connects with the BLE Dongle in the desk.
Finally it sends the preferred height of the user to the BLE Dongle, which will result in the desk moving to that height. This all is happening in the background, without requiring the user to open the app. The "location" setting in the UIBackgroundModes key is needed to detect the iBeacon. So in summary, our app needs to detect an iBeacon in the background and for that needs the location background mode. But Apple keeps persisting that we don't need it.
When we remove the background mode and test the app in background, the process of detecting beacons is stopped.
In the info.plist it's like this:
		<key>UIBackgroundModes</key>
<array>
<string>bluetooth-central</string>
<string>location</string>
</array>
The bluetooth-central background mode is needed to connect with a BLE device.
Is there something wrong with our setup, or do we need some different way of explaining this to Apple?
Post not yet marked as solved
Hi all,
My app downloads data from various API endpoints and stores it in corresponding CoreData entities for fast offline access. It does an initial sync the first time the app launches, and users can pull to refresh the data from the appropriate endpoints on the corresponding screens.
I’m also using a BGProcessingTask to handle these data syncs passively when the app is backgrounded. I’m hitting quite a few API endpoints in a chained series of completion handlers, and if the user is logged in, I’m hitting a few more on top of that.
I understand that BGProcessingTasks are designed for long running processes. My question is are there any best (or wrong) practices for having multiple BGProcessingTasks in your app? I’m looking to split everything up into 3 or 4 separate tasks so that each one can complete faster, and hopefully with a higher success rate.
Thank you in advance!
Scott
Post not yet marked as solved
I'm trying to add Background Tasks (not a timer) to a SwiftUI project for iOS 15 to fetch data from an API periodically.
It seems I'm seeing issues with my Published variable not updating my SwiftUI View until the application has been opened. Second issue is, I'm seeing AsyncImage not loading after a background task has been run, it will just show my placeholder ProgressView loading.
I'm notified by UserNotifications when the background task has been run, and I assumed the Published variable from my ObservableObject class would have been updated in the background? I'm also not sure why AsyncImage breaks while using Background Tasks.
Data Model
struct Pokemon: Codable {
let sprites: Sprites
let name: String
enum CodingKeys: String, CodingKey {
case sprites
case name
}
}
struct Sprites: Codable {
let frontDefault: String
enum CodingKeys: String, CodingKey {
case frontDefault = "front_default"
}
}
class DataModel: ObservableObject {
let taskIdentifier = "com.example.test.refresh"
private var cancellables = Set<AnyCancellable>()
@Published var pokemon = Pokemon(sprites: Sprites(frontDefault: "", frontShiny: ""), name: "", types: [])
func getpokemon() {
let request = URLRequest(url: URL(string: "https://pokeapi.co/api/v2/pokemon/\(Int.random(in: 1..<450))")!)
URLSession.shared.dataTaskPublisher(for: request)
.map{ $0.data }
.decode(type: Pokemon.self, decoder: JSONDecoder())
.receive(on: DispatchQueue.main)
.sink(receiveCompletion: { print ("Received completion: \($0).") },
receiveValue: { pokemon in
self.pokemon = pokemon
})
.store(in: &cancellables)
}
func register() {
BGTaskScheduler.shared.register(forTaskWithIdentifier: taskIdentifier, using: nil) { task in
self.handleAppRefresh(task: task as! BGAppRefreshTask)
}
}
func scheduleAppRefresh() {
let request = BGAppRefreshTaskRequest(identifier: taskIdentifier)
request.earliestBeginDate = Date(timeIntervalSinceNow: 10 * 60)
do {
try BGTaskScheduler.shared.submit(request)
} catch {
print("Could not schedule app refresh: \(error)")
}
}
func handleAppRefresh(task: BGAppRefreshTask) {
scheduleAppRefresh()
task.expirationHandler = {
print("expired")
//task.setTaskCompleted(success: false)
}
self.getpokemon()
task.setTaskCompleted(success: true)
}
}
App
import SwiftUI
import BackgroundTasks
@main
struct BackgroudTaskApp: App {
@ObservedObject var data = DataModel()
init() {
data.register()
data.scheduleAppRefresh()
}
var body: some Scene {
WindowGroup {
ContentView()
.environmentObject(data)
.onAppear(perform: data.getpokemon)
}
}
}
SwiftUI View
struct ContentView: View {
@EnvironmentObject var data: DataModel
var body: some View {
Button(action: {
withAnimation {
data.getpokemon()
}
}, label: {
VStack(spacing: 0) {
AsyncImage(url:URL(string:data.pokemon.sprites.frontDefault)) { image in
image
.resizable()
} placeholder: {
ProgressView()
}
.frame(width: 120, height: 120)
}}
).buttonStyle(.plain)
}
}
Post not yet marked as solved
Is it possible to periodically (or as soon as the OS is able to) call the app from Termination state to Background state (using Location updates capability and creating and exiting Regions), setting up a background task to get location and send JSON data to backend using URLSession on applicationWillTerminate?
According to the documentation, Region Monitoring does trigger the app to run when the user either enters a region or exits a region. But URLSession has not been working after the app terminates. Would I need to use Async for that?
Post not yet marked as solved
My app has applied for the permission to play audio and video in the background, but I found that it survived for a long time without hanging when the audio and video were not played in the background. I want to locate the cause, is there any good way?
Post not yet marked as solved
According to our firebase events, background fetch triggers with SplashViewController(First View Controller when the app starts). And our background fetch task leads to some concurrency problems when the app is in the foreground.According to feedback and from our users, I would like to ask a couple of questions related to this issue
1 - ) Can background fetch(performFetchWithCompletionHandler) trigger with push notification ?
2 -) What happens if the app opens while background fetch working in the background? If it continues to work, how can we prevent background fetch from running in the foreground?
3 -) Is it normal that background fetch starting when the user opens the application? If it is, how can we prevent it?
Post not yet marked as solved
As per title, we are having issues with our app in iOS 15 and the new prewarming features.
Anecdotally, users impacted by this have been able to workaround the issue by disabling background app refresh for our app.
So the question is, does disabling background app refresh for an app also disable ALL ios15 prewarming calls? Or is there no relationship ? , that is, regardless of background app refresh app setting, can prewarming still be executed on our app if the OS decides to.
Thanks,.
Hi, I need to develop an app for IOS, that acts like a middleware, but only runs on one device and interacts with some of the apps on that device. I know with a URL I could make calls to another app and from them to my app, but I don't want my app to have an interface. So when another app calls mine, it should only process the data and the user shouldn't see anything. So I need some kind of background URL call. Is there a way to accomplish this? Thanks.
Post marked as Apple Recommended
Hello,
Since the first iOS 15 beta and even with all the next public releases, we have a very weird crash each time our app enters background.
The crash logs don't help at all unfortunately
Each time we see:
Exception Type: EXC_CRASH (SIGKILL)
Exception Codes: 0x0000000000000000, 0x0000000000000000
Exception Note: EXC_CORPSE_NOTIFY
Triggered by Thread: 0
and
Thread 0 name:
Thread 0 Crashed:
0 libsystem_kernel.dylib 0x00000001b7a08564 mach_msg_trap + 8
1 libsystem_kernel.dylib 0x00000001b7a08bfc mach_msg + 76 (mach_msg.c:119)
2 CoreFoundation 0x0000000181089698 __CFRunLoopServiceMachPort + 372 (CFRunLoop.c:2646)
3 CoreFoundation 0x000000018108d98c __CFRunLoopRun + 1212 (CFRunLoop.c:3000)
4 CoreFoundation 0x00000001810a13c8 CFRunLoopRunSpecific + 600 (CFRunLoop.c:3268)
5 GraphicsServices 0x000000019c8b238c GSEventRunModal + 164 (GSEvent.c:2200)
6 UIKitCore 0x0000000183a47060 -[UIApplication _run] + 1100 (UIApplication.m:3457)
7 UIKitCore 0x00000001837c4b8c UIApplicationMain + 2124 (UIApplication.m:5013)
And sometimes we have:
Kernel Triage:
VM - Compressor failed a blocking pager_get
or
Kernel Triage:
VM - pmap_enter failed with resource shortage
VM - Compressor failed a blocking pager_get
But no other info.
We can't reproduce it on simulators or on real devices with non-production release (linked to Xcode).
But the crashes are here each time we build a release version.
Any help would be appreciated!
NB: it seems similar to this one but we are not even sure
2021-11-01_00-13-03.9761_+0100-a5388bfdcea65316d79dc2c3a4ac95ad146c2cb3.crash
Post not yet marked as solved
I currently am working on an application that will collect sensor data on an Apple watch and then transfer it to an iPhone and then send it to my database. The biggest struggle I'm currently having is that I cannot get the watch to continue to collect data when the watch face is not pointed at the user. I have tried turning settings on within the watch and done some research on background activity within my app, but nothing is working. All I really need to be able to do is have the watch be always on/active and not "fall asleep" whenever the wrist is turned. This will allow me to continuously collect data and send it, even when the user is moving their hand around
Post not yet marked as solved
Hi,
I tried to launch the BGAppRefreshTaskRequest from ColorFeed sample project on simulator. It is not working. Any idea why?
Here is logging.
2022-03-16 09:59:18.133956-0400 ColorFeed[1225:23444] Simulating launch for task with identifier com.example.apple-samplecode.ColorFeed.refresh
2022-03-16 09:59:21.510051-0400 ColorFeed[1225:24949] No task request with identifier <decode: missing data> has been scheduled
The command for debugger:
e -l objc -- (void)[[BGTaskScheduler sharedScheduler] _simulateLaunchForTaskWithIdentifier:@"com.example.apple-samplecode.ColorFeed.refresh"]
ColorFeed project:
https://developer.apple.com/documentation/backgroundtasks/refreshing_and_maintaining_your_app_using_background_tasks
Post not yet marked as solved
We have noticed recently that when our app is installed from the App Store, it is automatically launched into the background.
After the App Store installs our app, it is started into the background (no UI) without the user pressing ‘Open’ from the App Store or tapping the app icon in the home screen.
Testing with iOS 15.
I assume this is not the correct behavior, an app automatically being launched after being installed. I submitted a bug report (FB9971657), but wanted to know if anyone else was seeing this behavior.
Post not yet marked as solved
We have build PWA application, Where we have functionality to make it work on the offline also. On offline the record is getting saved in indexedDB but when user comes online it is not getting fired. Where as in MAC desktop chrome browser is working fine. MAC desktop Safari, iPhone Chrome and Safari browser is not working. I wonder do background sync as been supported by IOS iphone or Not?
Post not yet marked as solved
I know if you want to play a video in picture in picture mode you have to enable the background mode to achieve it.
But I found when I made an action extension (you can't add background mode to an action extension since there is no this option in its capabilities page),I can still play a video in picture in picture mode using the action extension.
Why is this happening?Does the extension share the capabilities of its host app or its containing app?Thanks!