Hi there. I received a nearables pack and have been trying to get them to trigger a notification when moved in my custom iOS app. Note that they show up as moving in the Estimote app when I move them. It must be a problem with my code but I can’t figure it out. Can someone help?
CODE SNIPPIT
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate, ESTTriggerManagerDelegate {
var window: UIWindow?
let beaconManager = ESTBeaconManager()
let triggerManager = ESTTriggerManager()
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
// add this below:
self.beaconManager.requestAlwaysAuthorization()
triggerManager.delegate = self
let motionRule = ESTMotionRule.motionStateEquals(true, for: .bag)
let trigger = ESTTrigger(rules: [motionRule], identifier: "moving")
self.triggerManager.startMonitoring(for: trigger)
return true
}
private func triggerManager(manager: ESTTriggerManager!,
triggerChangedState trigger: ESTTrigger!) {
if (trigger.identifier == "moving" && trigger.state == true) {
let notification = UILocalNotification()
notification.alertBody = "Your shoe is moving!"
UIApplication.shared.presentLocalNotificationNow(
notification)
}
}