Earn 4,500 ($45.00)
iOS/SwiftUI Daily Task That Must Run (Background Tasks/Silent Push Notifications)
Bounty Description
Problem Description
I have a SwiftUI application that needs to tell my backend my location once a day. I have a background task set up, but it never seems to be called. I'm having a hard time testing and fixing the following flow. The background task fetches the user's location and determines the closest city from a local geoJSON file (I don't want to send coordinates to my server). It then sends the name of that city to my backend. The authorization is "When In Use", so I can't use the locationDidUpdate method that comes with CoreLocation. The problems I'm having are from reliably scheduling a background task that runs daily, not really with location. I also have silent remote push notifications, but for some reason not all users receive them. To avoid requiring Always Allow location access, I'm looking into using IPInfo API and just getting rough coordinates from there (I don't really care about coordinate accuracy). I also found some libraries online that use Timers and implement some sort of cron framework, but haven't found anything properly reliable.
Acceptance Criteria
I have everything I need in 3 files. The App.swift file, my LocationManager.swift file, and another file for handling authorization for the backend requests. Any solution that successfully runs in the background and sends the request to my backend is accepted, as long as the location authorization remains When In Use. I am open to other solutions that don't use backgroundTask, like silent remote push notifs or timers, or a combination of some.
Basically whatever combination to ensure I can run a task consistently once a day :)