This sensor is used to track device significant motion. Also used internally by AWARE if available to save battery when the device is still with high-frequency sensors. SignificantMotionSensor.Observer allows programmers to take actions on detection of a significant motion.
Based of: sensorplatforms/open-sensor-platform/significantmotiondetector.c
iOS 13 or later
You can integrate this framework into your project via Swift Package Manager (SwiftPM) .
-
Open Package Manager Windows
- Open
Xcode-> SelectMenu Bar->File->App Package Dependencies...
- Open
-
Find the package using the manager
- Select
Search Package URLand typegit@github.com:awareframework/com.awareframework.ios.sensor.significantmotion.git
- Select
-
Import the package into your target.
-
Import com.awareframework.ios.sensor.significantmotion library into your source code.
import com_awareframework_ios_sensor_significantmotioninit(config:SignificantMotionSensor.Config?): Initializes the significant motion sensor with the optional configuration.start(): Starts the significant motion sensor with the optional configuration.stop(): Stops the service.
Class to hold the configuration of the sensor.
sensorObserver: SignificantMotionObserver: Callback for live data updates.enabled: Bool: Sensor is enabled or not. (default =false)debug: Bool: Enable/disable logging. (default =false)label: String: Label for the data. (default ="")deviceId: String: Id of the device that will be associated with the events and the sensor. (default ="")dbEncryptionKey: String?: Encryption key for the database. (default =nil)dbType: DatabaseType: Which db engine to use for saving data. (default =.none)dbPath: String: Path of the database. (default ="aware_significantmotion")dbHost: String?: Host for syncing the database. (default =nil)
SignificantMotionSensor.ACTION_AWARE_SIGNIFICANT_MOTION_STARTED: fired when there is a significant motion.SignificantMotionSensor.ACTION_AWARE_SIGNIFICANT_MOTION_ENDED: fired when the significant motion has ended.
SignificantMotionSensor.ACTION_AWARE_SIGNIFICANT_MOTION_START: received broadcast to start the sensor.SignificantMotionSensor.ACTION_AWARE_SIGNIFICANT_MOTION_STOP: received broadcast to stop the sensor.SignificantMotionSensor.ACTION_AWARE_SIGNIFICANT_MOTION_SYNC: received broadcast to send sync attempt to the host.SignificantMotionSensor.ACTION_AWARE_SIGNIFICANT_MOTION_SET_LABEL: received broadcast to set the data label. Label is expected in theSignificantMotionSensor.EXTRA_LABELfield of the intent extras.
Contains the motion changes.
| Field | Type | Description |
|---|---|---|
| moving | Bool | Indicates that a significant motion was detected or not. |
| label | String | Customizable label. Useful for data calibration or traceability |
| deviceId | String | AWARE device UUID |
| timestamp | Int64 | unixtime milliseconds since 1970 |
| timezone | Int | Timezone of the device |
| os | String | Operating system of the device (ex. ios) |
| jsonVersion | Int | JSON schema version |
let sensor = SignificantMotionSensor.init(SignificantMotionSensor.Config().apply { config in
config.sensorObserver = Observer()
config.debug = true
})
sensor.start()
sensor.stop()
}class Observer:SignificantMotionObserver{
func onSignificantMotionStart() {
// Your code here...
}
func onSignificantMotionEnd() {
// Your code here...
}
}- Core Motion | Apple Developer Documentation
- CMMotionManager | Apple Developer Documentation
- CMAccelerometerData | Apple Developer Documentation
Yuuki Nishiyama (The University of Tokyo), nishiyama@csis.u-tokyo.ac.jp
Copyright (c) 2025 AWARE Mobile Context Instrumentation Middleware/Framework (http://www.awareframework.com)
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.