0.0
No commit activity in last 3 years
No release in over 3 years
Simple location library for Rubymotion
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
 Dependencies

Development

~> 0
 Project Readme

motion-locman

Simple and easy location monitoring for RubyMotion

Installation

Add this line to your application's Gemfile:

gem "motion-locman", "~> 0.3"

And then execute:

$ bundle

Or install it yourself as:

$ gem install motion-locman

Preparing Rakefile

Before you start, you need to add NSLocationAlwaysUsageDescription and NSLocationWhenInUseUsageDescription key to the Info.plist with appropriate message. For example, add this on your Motion::Project::App.setup block:

app.info_plist["NSLocationAlwaysUsageDescription"] = "We utilize location data to enhance your app experience."
app.info_plist["NSLocationWhenInUseUsageDescription"] = "We utilize location data to enhance your app experience."

In addition, if you want to get an location data update on background, add this to your Motion::Project::App::Setup block:

app.info_plist["UIBackgroundModes"] = ["location"]

Usage

Initialize a new Locman::Manager, request for user authorization:

@manager = Locman::Manager.new(
  background: true, # for background updates
  accuracy: :ten_meters,
  distance_filter: 20 # in meter
)

@manager.after_authorize = lambda do |authorized|
  puts "Authorized!" if authorized
end

@manager.authorize!

Start monitoring and receiving location updates:

@manager.on_update = lambda do |locations|
  locations.each { |loc| puts "(#{loc.latitude}, #{loc.longitude})" }
end

@manager.update! # Starts receiving normal location updates
@manager.update_significant! # Starts receiving significant location updates

Start monitoring and receiving visits:

@manager.on_visit = lambda do |visit|
  puts "#{visit.latitude},#{visit.longitude} @ #{visit.departed_at}~#{visit.arrived_at}"
end

@manager.update_visits! # Start receiving visit updates

License

MIT