• Stars
    star
    149
  • Rank 248,619 (Top 5 %)
  • Language
    Objective-C
  • License
    MIT License
  • Created almost 10 years ago
  • Updated over 7 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Location manage framework working in different modes

AGLocationDispatcher

Dispatcher provides easy-to-use access to iOS device location/background location/tracking/etc. It wraps CoreLocation with convenient well customized interface. Dispatcher's classes for tracking current user location, direct and reverse geocoding , tracking enter/exit region, logging user route and speed.

CI Status Version License Platform

Usage

To run the example project, clone the repo, and run pod install from the Example directory first.

Add required .plist entries

By reason of iOS 8 you are required to define a message that will be presented to the user on location authorization request. You should define this message into your app's *-Info.plist file. Add at least one of the following keys, depending on which location update mode you request:

NSLocationWhenInUseUsageDescription or NSLocationAlwaysUsageDescription

Make sure you added this key in the right .plist file (common mistake is entering it into test-Info.plist) and appropriate message text as a value.

Tracking user location

To start tracking location, initialize AGLocationDispatcher or AGRouteDispatcher with default init for standart setup
(default updating interval - 1 min, horizontal accuracy - 100 meters)

also you can customize service with following initializer -

initWithUpdatingInterval: andDesiredAccuracy:

Demo apps:

AGGeoBackgroundDemo.xcodeproj

Demo Demo

A simple app which displays current device location (and carries out some actions with these data) in a background app state. The app identifies the location and displays this information in case it is changed significantly (about 1000 ft) or when the app processes fetch action from iOS (1015 minutes interval). In a background mode app can identify location within a time limit (as well as send location to a server or save in coredata). Our AGBackgroundLocationDispatcher class integrates the location method with one simple API. (See AppDelegate.m).

Additional information: 1 Significant location 2 Background fetch

AGGeoCodeDemo.xcodeproj

Demo

Demonstrate our simple wrapper that proposes method for multiple provider geocoder service. App shows geocode (location into address) and reverse geocode (address into location), with selection a provider from our list (Yandex, Google, Apple).

AGGeoRegionTrackingDemo.xcodeproj

Demo

This demo app indicates when a user enters/exits the picked region with diameter un 100m. User can pick a region by dragging green circle, start tracking this region (start button in bottom), track his position on the map and receive notifications when entering or exiting the region. Just stop tracking current region and pick another one. Have fun! P.S. If you want to simulate location tracking: tap “Simulate location” icon in Xcode bottom bar and pick “New York City Marathon” when you start your app or go to you scheme > Edit scheme > Pick “New York City Marathon” in Default location list.

AGGeoTrackingDemo.xcodeproj

Demo

This demo app can track your current position, record your route, show your current average speed and distance. Also you can save your routes and view them later. Besides that you can pick one of 3 position markers styles. Just tap Start rec button and go on. You will see your current route drawn with green line. Press Stop & Save and go to saved routes screen by tapping Saved routes button. Here you can see your last saved route. You can pick any of your routes by tapping Saved routes button in bottom. Have fun!

P.S. If you want to simulate location tracking: tap “Simulate location” icon in Xcode bottom bar and pick “New York City Marathon” when you start your app or go to you scheme > Edit scheme > Pick “New York City Marathon” in Default location list.

Example:

AGRouteDispatcher *routeDisptcher = [AGRouteDispatcher initWithUpdatingInterval:kDefaultLocationTimeIntervalUpdateOneMinute andDesiredAccuracy:kAGHorizontalAccuracyThresholdBlock]

At viewcontroller's module, you can use this methods with blocks:

- (void)startUpdatingLocationWithBlock: errorBlock:
- (void)startUpdatingLocationAndSpeedWithBlock: errorBlock:
- (void)requestUserLocationWhenInUseWithBlock:
- (void)requestUserLocationAlwaysWithBlock:
- (void)currentLocationWithBlock: errorBlock:

inits and getters:

+ (BOOL)locationServicesEnabled;
+ (BOOL)significantLocationChangeMonitoringAvailable;

- (instancetype)init;
- (instancetype)initWithUpdatingInterval:(NSTimeInterval)interval andDesiredAccuracy:(CLLocationAccuracy)horizontalAccuracy;
- (CLLocationManager *)locationManager;
- (CLLocationAccuracy)horizontalAccuracyThreshold;

Background Tracking user location

AGLocationDispatcher allows several methods of background location, depends of application info plist configuratons and locationUpdateBackgroundMode setting (default is AGLocationBackgroundModeSignificantLocationChanges mode) When application is suspended or terminated you need use spectial background location wrapper: AGBackgroundLocationDispatcher (see example AppDelegate methods)

Background location modes:

  • No background location mode: When app go to backgroud location updated will stop. After app did become active location updating will be activated again. Set locationUpdateBackgroundMode property (AGLocationDispatcher object) to AGLocationBackgroundModeForegroundOnly state;

  • Always actiwe: required UIBackgroundModes "location" key, application never suspend, location accuracy and battery rate will be maximum, no need additional code. Set locationUpdateBackgroundMode property (AGLocationDispatcher object) to any state except AGLocationBackgroundModeForegroundOnly;

  • Significant location mode: Work when app is terminated/suspended, provide GPS-level accuracy (over 500 metters positon change) and very low-energy location updating. Required UIBackgroundModes "location" key and implementin special handler(based on AGBackgroundLocationDispatcher wrapper) in app delegate code (see example appDelegate method didFinishLaunchingWithOptions). Set locationUpdateBackgroundMode property (AGLocationDispatcher object) to AGLocationBackgroundModeSignificantLocationChanges state;

  • Fetch based location mode: Work when app is suspended, provide normall accuracy and very middle-energy location updating, but activated when device is unblock/activate. Required UIBackgroundModes "fetch" key and implementin special handler(based on AGBackgroundLocationDispatcher wrapper) in app delegate code (see example appDelegate method performFetchWithCompletionHandler). Set locationUpdateBackgroundMode property (AGLocationDispatcher object) to AGLocationBackgroundModeFetch state;

AGBackgroundLocationDispatcher code runs when app is NOT active, you default apps object amd UI will NOT exist. AGBackgroundLocationDispatcher code must store location locally (in file, coredata etc), send it to server side or create UILocalNotification (for start the app in normal mode). AGBackgroundLocationDispatcher code will be terminated by system after 10s~30s after active running.

AGBackgroundLocationDispatcher wrapper provide init method with block for you background code and callback block, you need call that block when you location task will complete.

Example AGBackgroundLocationDispatcher code:

[[AGBackgroundLocationDispatcher alloc] initWithASynchronousLocationUpdateBlock:^(AGLocation *newLocation, LDSignificationLocationASynchronousEndUpdateBlock updateCompletionBlock) {

    NSString *string = [NSString stringWithFormat:@"example.com?location=%@",  [newLocation description] ];
    NSURL *url = [NSURL URLWithString:string];
    NSURLRequest *request = [NSURLRequest requestWithURL:url];

    AFHTTPRequestOperation *operation = [[AFHTTPRequestOperation alloc] initWithRequest: request];
    
    [operation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject) {

        updateCompletionBlock(); //data send successfully

    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {

        updateCompletionBlock(); //data dont send 

    }];

    [operation start];

}];

Use geocoding

Use AGGeoDispatcher class for direct and reverse geocoding.

Just initialize AGGeoDispatcher class

AGGeoDispatcher *geoDispatcher = [[AGGeoDispatcher alloc] init]

implement following methods:

- (void)requestGeocodeForLocation: success: andFail:
- (void)requestLocationForAddress: success: andFail:

To choose geocode provider (Apple, Google, Yandex) use following method:

- (void)setGeocoderProvider:

Manage your route

AGRouteDispatcher class provide save/load AGRoute data in local storage with methods:

- (AGRoute *)loadRouteWithName:
- (void)saveRoute: name:
- (void)deleteDocWithName:

Regions Dispatcher

AGRegionDispatcher class used for monitoring enter/exit some region. Use this block methods for monitoring:

- (void)addCoordinateForMonitoring: updateBlock: failBlock:
- (void)addCoordinateForMonitoring: withRadius: desiredAccuracy: updateBlock: failBlock:
- (void)addRegionForMonitoring: desiredAccuracy: updateBlock: failBlock:
- (void)stopMonitoringForRegion:
- (void)stopMonitoringAllRegions

Requirements

Installation

AGLocationDispatcher is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod "AGLocationDispatcher"

Author

Agilie [email protected]

Contact us

[email protected]

License

AGLocationDispatcher is available under the MIT license. See the LICENSE file for more info.

More Repositories

1

AGCircularPicker

AGCircularPicker is helpful component for creating a controller aimed to manage any calculated parameter
Swift
627
star
2

DisPlayers-Audio-Visualizers

DisPlayer is a customizable audio visualization component that works with recording and playing back audio files
Objective-C
312
star
3

AGImageControls

cool tools for image edition
Swift
226
star
4

AGVolumeControlView

Visual regulator can be connected to a player or other smart house’s device making the process of controlling the level of a particular characteristic
Swift
171
star
5

AGInterfaceInteraction

library performs interaction with UI interface
Swift
156
star
6

instagram_api_gem

A Ruby wrapper for the Instagram API
Ruby
105
star
7

CircularPicker

CircularPicker is helpful for creating a controller aimed to manage any calculated parameter.
Kotlin
84
star
8

VolumeControlView

Visual regulator can be connected to a player or other smart house’s device making the process of controlling the level of a particular characteristic much easier.
Kotlin
75
star
9

dribbble-ios-sdk

Unofficial Dribbble iOS wrapper allows you to integrate Dribble API into iOS application (Designer, Shot, Comment, User Story, Like, Follow)
Objective-C
73
star
10

InterfaceInteraction

Interact your app's interface elements with different effects!
Kotlin
56
star
11

RotatableAutofitEditText

Extended EditText which allows to move, rotate and resize text at the same time
Java
54
star
12

GoButton

This button is used for displaying an animation while a request is going. It could be run with infinite animation loop or with finish animation as well.
JavaScript
51
star
13

MobileGift

Simplifies interaction with GIF images.
Kotlin
45
star
14

canvas-image-cover-position

Calculating image position for scaling it on the canvas.
HTML
39
star
15

AGMobileGiftInterface

simplified interaction with GIF animations
Swift
39
star
16

dribbble-android-sdk

Dribbble Android SDK is an unofficial wrapper for Dribbble API v1. (Designer, Shot, Comment, User Story, Like, Follow)
Java
31
star
17

AnimatedToggleMenu

The Animated Toggle Menu is helpful for creating websites. It’s lightweight, easy-to-use and requires minimum lines of code.
CSS
28
star
18

science-fiction-magazines-blog

Blog template (concept) is inspired by stylish science fiction magazines of the 80-90s.
CSS
27
star
19

PXSDK

Objective-C
27
star
20

gtm-in-viewport-manager

A manager of in-viewport events for GTM (Google Tag Manager).
HTML
21
star
21

Web-Time-Tracker

Plugin named Timetracker is a time counter that works in both increase and decrease directions.
JavaScript
21
star
22

Rails-Application-Template

Base template for creating rails applications.
Ruby
18
star
23

ng2-dialog-window

Modal/dialog windows and popups module for Angular applications.
JavaScript
17
star
24

Bouncing-Carousel

The bouncing carousel is an experiment with SVG animations technology.
CSS
14
star
25

viper_sample

Swift
10
star
26

electrum-proxy-middleware

ExpressJS middleware to add functionality for proxying requests to Electrum servers
TypeScript
7
star
27

vimeo-api-gem

A Ruby wrapper for the Vimeo API. Utilizes v3 API version
Ruby
6
star
28

AIS-MobileDesign

A Mobile Design API client for Agilie IT School teaching purposes
JavaScript
5
star
29

swift_viper_template

The template for creating VIPER module using generamba in Swift
Liquid
4
star
30

Agilie-IT-School

A sandbox repository for experiments with AngularJS techniques and studying purposes for Agilie IT School students
HTML
4
star
31

kraken-wsclient-js

Kraken WebSockets client in JS for the Kraken websocket API.
TypeScript
2
star
32

rails-generators

Rails ready-to-use generators to improve adding libs that we are usually using
Ruby
2
star
33

angular-helpies

Helping instances for developing Angular applications
HTML
2
star
34

action-button

JavaScript
1
star
35

ra-tinymce-input

Rich Text Input component for React Admin, useful for editing HTML content in admin GUI
JavaScript
1
star
36

ebanq_api

A Ruby wrapper for the EBANQ Rest API
Ruby
1
star