I am currently working on regionMonitoring in Swift, where I check if a user is around a certain location. I use background modes (location) to check the location every 50 meters the user moves. This wakes up my app and it provides a location key in application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?).
I also check, on the first viewController, if the user has a working internet connection. If not, a message is shown: "Please make sure you are connected to the Internet."
In the past days, I noticed this message was shown even when I did have a working connection, but my Internet was off when I was on the move. So I think the application was woken up and then directed towards the first view controller after didFinishLaunchingWithOptions.
Is this possible? Does my app start up "completely" when a new location is gathered? Can I implement the following in didFinishLaunchingWithOptions to prevent this:
if(launchOptions?[UIApplication.LaunchOptionsKey.location] != nil) {
// handle new location that was sent, but don't launch the rest of the application
} else {
// do all the regular stuff, such as setting keyWindow etc
}
Or would this cause trouble in some cases? If I open up the app myself, is it possible to have a location key included in there?
I just figured that I need to launch the entire app, otherwise I will end up on a black screen when I re-open the app (because launching has already been initialized). So what I do now, is check in willEnterForeground if the app is stuck on the "fake" splash screen viewController and if so, I re-check the connection and launch from there.