RDMgr
Requirements
ios >= 7.0
Installation
RDMgr is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod "RDMgr"
How to Use
permissions
- You Have to enable Background Modes with both Audio and Location updates modes.
- Background Location updates mode is used for outdoor mode when we calculate distance with GPS data.
- Background audio is a trick when we want to record running data in background for indoor mode on devices below iPhone 5S.
- add NSLocationWhenInUseUsageDescription to your info.plist.
In AppDelegate.m, add the code below:
- (void)applicationWillResignActive:(UIApplication *)application {
[[RDManager sharedManager] resignActive];
}
- (void)applicationDidBecomeActive:(UIApplication *)application {
[[RDManager sharedManager] becomeActive];
}
- (void)applicationWillTerminate:(UIApplication *)application {
[[RDManager sharedManager] terminate];
}
Control running:
[[RDManager sharedManager] start];
[[RDManager sharedManager] pause];
[[RDManager sharedManager] stop];
Implement your ViewController as a RDDataDelegate, and set it to the sharedManager with:
[RDManager sharedManager].delegate = myViewController;
and you will receive data through:
- (void)distanceChanged:(double)distance;
- (void)gpsAccuracyChanged:(double)accuracy;
- (void)coordinateChanged:(CLLocation *)location;
- (void)stepChanged:(NSInteger)step;
- (void)durationChanged:(NSInteger)duration;
- (void)paceChanged:(double)pace;
- (void)calorieChanged:(NSInteger)calorie;
- (void)needsGpsAccess;
Force fetch data as RDManager can run and share data between ViewControllers:
- (void)fetchData;
Author
Aki Xavier, aki.xavier@me.com
License
RDMgr is available under the MIT license. See the LICENSE file for more info.