Simple library to detect motion type (walking, running, automotive) and count users steps. This library will make motion detection much more easily.

Overview

SOMotionDetector

Simple library to detect motion for iOS by arturdev .

Based on location updates and acceleration.

###Requierments iOS > 6.0

Compatible with iOS 9

Works on all iOS devices (i.e. not need M7 chip)

This demo project also demonstrates how to use this library to relaunch the app from killed state.

USAGE

Copy SOMotionDetector folder to your project.

Link CoreMotion.framework, CoreLocation.framework.

Import "SOMotionDetector.h" file and set SOMotionDetector's callbacks

#import "SOMotionDetector.h

//...

[SOMotionDetector sharedInstance].motionTypeChangedBlock = ^(SOMotionType motionType) {
    //...
};
    
[SOMotionDetector sharedInstance].locationChangedBlock = ^(CLLocation *location) {
    //...
};

[SOMotionDetector sharedInstance].accelerationChangedBlock = ^(CMAcceleration acceleration) {
    //...    
};

If you need to know when location updates were automatically paused due to your app running in the background...

[SOMotionDetector sharedInstance].locationWasPausedBlock = ^(BOOL changed) {
    //...    
};

###NOTE! To Support iOS > 8.0 you must add in your info.plist file one of the following keys:
NSLocationAlwaysUsageDescription
NSLocationWhenInUseUsageDescription

To enable background location updates in iOS > 9.0 you must set allowsBackgroundLocationUpdates to YES

    [SOLocationManager sharedInstance].allowsBackgroundLocationUpdates = YES;

You are done!

Now to start motion detection just call

[[SOMotionDetector sharedInstance] startDetection];

To stop detection call

[[SOMotionDetector sharedInstance] stopDetection];

To start step counter call

    [[SOStepDetector sharedInstance] startDetectionWithUpdateBlock:^(NSError *error) {
        //...
    }];

###Detecting motion types

typedef enum
{
  MotionTypeNotMoving = 1,
  MotionTypeWalking,
  MotionTypeRunning,
  MotionTypeAutomotive
} SOMotionType;

CUSTOMIZATION

/**
 * Set this parameter to YES if you want to use M7 chip to detect more exact motion type. By default is No.
 * Set this parameter before calling startDetection method.
 * Available only on devices that have M7 chip. At this time only the iPhone 5S, the iPad Air and iPad mini with retina display have the M7 coprocessor.
 */
@property (nonatomic) BOOL useM7IfAvailable;

/**
 *@param speed  The minimum speed value less than which will be considered as not moving state
 */
- (void)setMinimumSpeed:(CGFloat)speed;

/**
 *@param speed  The maximum speed value more than which will be considered as running state
 */
- (void)setMaximumWalkingSpeed:(CGFloat)speed;

/**
 *@param speed  The maximum speed value more than which will be considered as automotive state
 */
- (void)setMaximumRunningSpeed:(CGFloat)speed;

/**
 *@param acceleration  The minimum acceleration value less than which will be considered as non shaking state
 */
- (void)setMinimumRunningAcceleration:(CGFloat)acceleration;

Installation with CocoaPods

CocoaPods is a dependency manager for Objective-C, which automates and simplifies the process of using 3rd-party libraries installation in your projects.

Podfile

pod "SOMotionDetector"

LICENSE

SOMotionDetector is under MIT License (see LICENSE file)
Comments
  • Doesn't Ask for Authorization

    Doesn't Ask for Authorization

    At no point is there a call for requestWhenInUseAuthorization or requestAlwaysAuthorization for ios8 and ios9 support. I think this should either be asked upon startDetection and/or should be exposed to the developer to call whenever they see fit so that they can ask for it at the right time in their UX.

    Either way this issue makes it really weird to get Core Location updates because we either have to edit your Pod or ask for it manually on an unused Location Manager instance.

    opened by johnnyshankman 5
  • Not Working in Background

    Not Working in Background

    Hi, Thank you so much for your hard work.

    I am trying to detect change in Activity type while the app is in background. It works perfectly in foreground but doesn't work in background. I have enabled background location update mode.

    Thank you for your help.

    opened by extremechatter 5
  • Documentation not up to date?

    Documentation not up to date?

    In your documentation you write [SOLocationManager sharedInstance].allowsBackgroundLocationUpdates = YES;

    But I can't find this in code? The background mode is especially important for me.

    opened by ogezue 2
  • iOS9 Background Location Support

    iOS9 Background Location Support

    Currently we cannot do background location updates with SOMotionDetector on iOS9

    We have to expose a way to set the allowsBackgroundLocationUpdates property of the SOLocationManager's instance of CLLocationManager to YES or NO.

    https://developer.apple.com/library/prerelease/ios/releasenotes/General/iOS90APIDiffs/Objective-C/CoreLocation.html

    https://developer.apple.com/library/prerelease/ios/documentation/CoreLocation/Reference/CLLocationManager_Class/index.html#//apple_ref/occ/instp/CLLocationManager/allowsBackgroundLocationUpdates

    opened by johnnyshankman 1
  • motionTypeChangedBlock does not fire when running in the background

    motionTypeChangedBlock does not fire when running in the background

    Hi,

    First things first, THANK YOU ! for this great library. Now to the question..., I am initiating SOMotionDetector in my App Delegate (didFinishLaunchingWithOptions). But when my app goes into background state, I do not get alerts.

    My App Delegate --> didFinishLaunchingWithOptions contains:

    ... ... ... ... [SOMotionDetector sharedInstance].motionTypeChangedBlock = ^(SOMotionType motionType) { [myClass MotionTypeChanged: motionType]; }; ... ... ... ...

    Is it something the software doesn't support or am I doing it wrong ?

    opened by SimplyKeshav 1
  • Add location was paused block

    Add location was paused block

    When the app goes into the background, the OS will eventually pause location updates even if pausesLocationUpdatesAutomatically is false if it thinks the app doesn't need updates (not moving). This is all good but sometimes you need to take action on that. Especially because it doesn't seem to ever resume without bringing the app into the foreground.

    opened by sanderpick 0
  • Cache the check for motion hardware

    Cache the check for motion hardware

    On older devices, such as iPhone 4S, repeatedly calling [CMMotionActivityManager isActivityAvailable] causes an unnecessary performance overhead. As this value will never change, this fix involves saving the result so that the system call is only made once.

    opened by ricsantos 0
  • Delegate not appropriate for Singleton

    Delegate not appropriate for Singleton

    The use of a single delegate to receive callbacks doesn't really fit well with at singleton pattern. One option to remedy this is to change from a protocol for callbacks to notifications. Another option would be to remove the singleton part.

    opened by ricsantos 0
  • allow installation as Carthage framework

    allow installation as Carthage framework

    Enable to install library from Carthage. Xcode project created using XcodeTool:

    XcodeTool template --name="ComponentCrossPlatform" --target=SOMotionDetector
    

    Cartfile

    github "arturdev/SOMotionDetector"
    
    opened by mauron85 1
  • Calculate travel time

    Calculate travel time

    Is it possible to detect the timeslot when the user was travelling?

    I'm only interested in the start and end time of my travel. And this even if the app is not running, like the Moves-app is doing.

    opened by ogezue 0
  • CoreMotion authorization message

    CoreMotion authorization message

    Hi,

    In the first installation the application is frozen by CoreMotion.

    Include the new "Privacy - Motion Usage Description" key in my iOS app .plist???

    https://developer.apple.com/library/ios/documentation/General/Reference/InfoPlistKeyReference/Articles/CocoaKeys.html

    Congratulations for the project. Thank you very much.

    opened by Quadram 0
  • CMMotionActivity

    CMMotionActivity

    Would you mind if i ask a question not relating to SOMotionDetector? Now i`m using M7 in ios to detect the status of device. I get a trouble that device sometimes detects wrong status. For example, when i shake my device the status turns into "in the car", while im not in the car. So can you show me how to decrease wrong detection. Thank you very much.

    opened by phamhung159 0
Releases(v1.0.1)
Owner
Artur Mkrtchyan
Senior Software Engineer at TeamViewer
Artur  Mkrtchyan
Easily get the device's current location on iOS.

INTULocationManager makes it easy to get the device's current location and is currently heading on iOS. It is an Objective-C library that also works g

Intuit 2.6k Dec 21, 2022
A Location Manager for easily implementing location services & geofencing in iOS. Ready for iOS 11.

A Location Manager for easily implementing location services & geofencing in iOS, written in Objective-C. Ready for iOS 11. Features Get current/conti

Benzamin Basher 108 Jul 9, 2022
A simple map with the location of the user and the control of permissions

Proposal The project is based on implementing a simple map with the location of

Raúl Pedraza León 0 Dec 26, 2021
A simple Pebble app to show the nearest available CitiBike NYC dock.

PebCiti A simple iOS app to show the nearest available CitiBike NYC dock on your Pebble. UUID: F6BB82D0-B5BF-4EC7-A97A-405D3A350444 Installation Open

Joe Masilotti 19 Dec 11, 2021
Speedometer - A simple iPhone GPS speedometer

GPS Speedometer A simple iPhone GPS speedometer

Thomas Megantz 2 Aug 18, 2022
The most power-efficient and lightweight iOS location manager for Swift and ObjC

IngeoSDK for iOS Overview IngeoSDK is a power-efficient location manager for iOS (Swift and Objective-C), which extends and improves CoreLocation. It

IngeoSDK 99 Feb 28, 2022
iOS and  Watch app to find city bicycles to rent in your city

Bike-Compass Bike Compass is a full-featured city bicycle finder app for iOS. Using a bike is enjoyable, that is why our app is fast, beautiful, and d

Raul Riera 80 May 18, 2022
🗺️ MAPS.ME — Offline OpenStreetMap maps for iOS and Android

MAPS.ME MAPS.ME is an open source cross-platform offline maps application, built on top of crowd-sourced OpenStreetMap data. It was publicly released

MAPS.ME 4.5k Dec 23, 2022
Israel's tech jobs, startups, incubators and investors iOS App

Startups | Mapped In Israel Startups is a beautiful way to discover new startups, locate co-working spaces and get funded. Startups lets you: Visualiz

Sugar So Studio 31 Feb 9, 2022
Abandonned project - iOS and watchOS apps to travel with Geneva Public Transports

Presentation tpg offline is an iOS app that allows you to travel in Geneva by bus and tramay without cellular data. This application is available on t

tpg offline 14 Jan 1, 2023
🛰 CoreLocation Made Easy - Efficient & Easy Location Tracker, IP Location, Gecoder, Geofence, Autocomplete, Beacon Ranging, Broadcaster and Visits Monitoring

Location Manager Made Easy SwiftLocation is a lightweight Swift Library that provides an easy way to work with location-related functionalities. No mo

Daniele Margutti 3.2k Dec 30, 2022
A ready for use and fully customizable location picker for your app

LocationPicker A ready for use and fully customizable location picker for your app. Features Installation Cocoapods Carthage Swift Package Manager Qui

Zhuoran 397 Nov 16, 2022
A Swift wrapper for forward and reverse geocoding of OpenStreetMap data

Nominatim NominatimKit is a Swift wrapper for forward and reverse geocoding of OpenStreetMap data. Why? Geocoding location data on iOS requires the us

Josef Moser 53 Feb 5, 2022
An original project making use of custom UITableViewCells, date formatting, json parsing, and handling user location.

SunTimes An original project making use of custom UITableViewCells, date formatting, json parsing, date and time formatting based on the json data, an

David Chester 0 Feb 8, 2022
A project to test the accuracy of iOS geofence and visits monitoring.

GeofenceTester iOS About This Component • Build • Support • Contribute • Licensing A project to test the accuracy of iOS geofence and visits monitorin

Telekom Open Source Software 3 Oct 27, 2022
Count It, Never lose the count again

Count It Never lose the count again. Dead simple App with Apple Watch integration that lets you count anything. Laps while exercising. How many beers

Chris Jimenez 62 Nov 28, 2022
A phantom type is a custom type that has one or more unused type parameters.

PhantomTypes A phantom type is a custom type that has one or more unused type parameters. Phantom types allow you to enforce type-safety without sacri

null 3 Nov 4, 2022
This app is a sample app that recognizes specific voice commands such as "make it red", "make it blue", "make it green", and "make it black" and change the background color of the view in the frame.

VoiceOperationSample This app is a sample app that recognizes specific voice commands such as "make it red", "make it blue", "make it green", and "mak

Takuya Aso 3 Dec 3, 2021
Browse the streets of Los Angeles on an Augmented Reality historical walking tour.

Ruscha AR 0.3 Browse the streets of Los Angeles on an Augmented Reality historical walking tour. Explore Hollywood through the photos of Ed Ruscha. Th

Rick van Voorden 2 Jul 9, 2022
golf pose detection Analyzing golf pose with MLKit pose detection

golf-pose golf pose detection Analyzing golf pose with MLKit pose detection (PHI NETWORKS, 창의적통합설계, 2021) Standard & Frameworks iOS platform (Swift, R

Donghyun Lee 1 Jan 24, 2022