Nearables not trigger when moved

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)
        }
    }

I know this is an older post, but I’m having the same trouble in Swift. After following this tutorial, I tried just using the ESTMotionRule for ESTNearableType, but it never changes the trigger state.

This works …

import UIKit

class ViewController: UIViewController, ESTTriggerManagerDelegate, ESTBeaconManagerDelegate {
    let triggerManager = ESTTriggerManager()
    let beaconManager = ESTBeaconManager()

    override func viewDidLoad() {
        super.viewDidLoad()
        self.beaconManager.requestAlwaysAuthorization()
        self.triggerManager.delegate = self 
        //WORKING RULE: 
        let rule1 = ESTMotionRule.motionStateEquals(true, forNearableIdentifier: "96567d1ca1a27038")
        let trigger = ESTTrigger(rules: [rule1], identifier: "tom the trigger")
        self.triggerManager.startMonitoring(for: trigger)
    }

    func triggerManager(_ manager: ESTTriggerManager, triggerChangedState trigger: ESTTrigger) {
        if (trigger.identifier == "tom the trigger" && trigger.state == true) {
            print("Hello, digital world! The physical world has spoken.")
        } else {
            print("Goodnight. <spoken in the voice of a turret from Portal>")
        }
    }

}

But this doesn’t …

override func viewDidLoad() {
     super.viewDidLoad()
     self.beaconManager.requestAlwaysAuthorization()
     self.triggerManager.delegate = self 
     //NOT WORKING RULE: 
     let rule1 = ESTMotionRule.motionStateEquals(true, for: .all)
     let trigger = ESTTrigger(rules: [rule1], identifier: "tom the trigger")
     self.triggerManager.startMonitoring(for: trigger)
}

I’d appreciate any help/advice - thanks!