captnemo
captnemo

Reputation: 31

Solution for iPhone leaving home

I searching for a solution to tell a Linux-application that the iPhone left the house and come back again. (in Swift ;-) )

I testing some ways, but nothing works in the right way. When i using WLAN-connection lost, so the Linux think that i'm away when my iPhone goes to standby, because iOS shutdown the WLAN in Background. When i using background location the time between the location updates is too long.

Can i use the Homekit to do something like that? Or is there anyone who did something like this?

Upvotes: 1

Views: 106

Answers (1)

andrewxhill
andrewxhill

Reputation: 259

The SetSDK will allow you to setup an in-app notification for when a user arrives to or departs from home, https://cocoapods.org/pods/SetSDK. The SDK learns where home is and then starts to fire the notifications off. So for departing home, you would do,

SetSDK.instance.onDeparture(from: .home) { 
    /* do your Swift things here */
}

In that example, you rely on the SetSDK to learn where home is first. If you already know a location where you want to get departure alerts, the easiest right now is to do,

SetSDK.instance.onDeparture(from: .any) { departedPlace in
    /* Compare the departed location with the one of interest */
    if departedPlace.location.distance(from: knownLocation) < 50 {
      /* do your things here */
    }
}

Upvotes: 3

Related Questions