I'm using SDK in latest available version at the moment, i.e. 1.4.1, and example snippets are inaccurate.
EPXProximityObserver has been renamed to ProximityObserver
ProximityZone argument order has changed (tag must precede range)
at the top of the snippet ProximityObserver is assigned to self.proximityObserver, and at the very bottom self.observer is being used
Below is fixed example.
let credentials = CloudCredentials(appID: "your-app-id", appToken: "your-app-token")
self.proximityObserver = ProximityObserver(credentials: credentials, onError: { error in
print("Oops! \(error)")
})
// Define zones
let blueberryZone = ProximityZone(tag: "blueberry", range: ProximityRange.near)
blueberryZone.onEnter = { zoneContext in
print("Entered near range of tag 'blueberry'. Attachments payload: \(zoneContext.attachments)")
}
blueberryZone.onExit = { zoneContext in
print("Exited near range of tag 'blueberry'. Attachment payload: \(zoneContext.attachments)")
}
blueberryZone.onContextChange = { contexts in
print("Now in range of \(contexts.count) contexts")
}
// ... etc. You can define as many zones as you need.
// Start proximity observation
self.proximityObserver.startObserving([blueberryZone])
I'm using SDK in latest available version at the moment, i.e. 1.4.1, and example snippets are inaccurate.
EPXProximityObserver
has been renamed toProximityObserver
ProximityZone
argument order has changed (tag
must precederange
)ProximityObserver
is assigned toself.proximityObserver
, and at the very bottomself.observer
is being usedBelow is fixed example.