{"id":1244,"url":"https://github.com/benzamin/BBLocationManager","last_synced_at":"2025-07-30T20:32:59.977Z","repository":{"id":56902695,"uuid":"80339224","full_name":"benzamin/BBLocationManager","owner":"benzamin","description":"A Location Manager for easily implementing location services \u0026 geofencing in iOS. Ready for iOS 11.","archived":false,"fork":false,"pushed_at":"2018-01-18T11:14:55.000Z","size":3317,"stargazers_count":106,"open_issues_count":1,"forks_count":20,"subscribers_count":9,"default_branch":"master","last_synced_at":"2024-11-18T03:19:01.229Z","etag":null,"topics":["block","cocoapods","corelocation","delegate","geocoder","geofence","geofences","ios","iphone","location","locationmanager","objective-c"],"latest_commit_sha":null,"homepage":"","language":"Objective-C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/benzamin.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-01-29T10:03:12.000Z","updated_at":"2024-10-27T06:22:25.000Z","dependencies_parsed_at":"2022-08-21T01:50:52.119Z","dependency_job_id":null,"html_url":"https://github.com/benzamin/BBLocationManager","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/benzamin%2FBBLocationManager","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/benzamin%2FBBLocationManager/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/benzamin%2FBBLocationManager/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/benzamin%2FBBLocationManager/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/benzamin","download_url":"https://codeload.github.com/benzamin/BBLocationManager/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":228187611,"owners_count":17882335,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["block","cocoapods","corelocation","delegate","geocoder","geofence","geofences","ios","iphone","location","locationmanager","objective-c"],"created_at":"2024-01-05T20:15:42.086Z","updated_at":"2024-12-04T20:31:11.407Z","avatar_url":"https://github.com/benzamin.png","language":"Objective-C","readme":"![BBLocationManager](https://raw.githubusercontent.com/benzamin/BBLocationManager/master/screens/BBLocationManager-logo.png)   \nA Location Manager for easily implementing location services \u0026 geofencing in iOS, written in Objective-C. **Ready for iOS 11.**\n\n## Features\n\n* Get current/continious/frequent location and get current geocode/address with simple API call. \n* Add or remove [Geofence](https://developer.apple.com/library/content/documentation/UserExperience/Conceptual/LocationAwarenessPG/RegionMonitoring/RegionMonitoring.html) at current/given location. Get callback via delegate when user enter/exit a geofence, supports foreground/background, even when [app is not running](https://developer.apple.com/reference/corelocation/cllocationmanager#//apple_ref/doc/uid/TP40007125-CH3-SW32). \n* Read location permission status and if not provided ask for location permisssion automatically. \n* High performance, easy to use, battery friendly, use via block or delegate. Stops automatically when location update is not required. \n* [Example App](https://github.com/benzamin/BBLocationManager/archive/master.zip) included for demonstrating all the features. Supports iOS 6.0 and later. \n\n![Current location and GeoCode](https://raw.githubusercontent.com/benzamin/BBLocationManager/master/screens/locationNgeofence.gif  \"Getting current location and Geocode\")\n\n## Getting Started\n[Location services](https://developer.apple.com/library/content/documentation/UserExperience/Conceptual/LocationAwarenessPG/CoreLocation/CoreLocation.html) is a powerful feature of iOS, but sometimes its not easy to understand all the API's and learn how to use them. With BBLocationManager, you can start using iOS Location Services API in no time. It provides good code documentation for better understanding of the methods and delegates. If you are making a location aware app or building a geofencing app like the [Alarm](https://developer.apple.com/library/content/documentation/DataManagement/Conceptual/EventKitProgGuide/ConfiguringAlarms/ConfiguringAlarms.html) app in iOS which reminds you to buy milk when you are near home, BBLocationManager can be your choice.\n\n\n## Installation\nBBLocationManager can be installed through Cocoapods or manually. You can check out the example project by [downloading the full source code](https://github.com/benzamin/BBLocationManager/archive/master.zip)\n\u003e Supports iOS 6.0 and later.\n\n### Installing with CocoaPods\n\n[CocoaPods](http://cocoapods.org) is very popular dependency manager for iOS projects. It automates and simplifies the process of using 3rd-party libraries like BBLocation in your projects. If you don't have cocoapods installed in your mac already, you can install it with the following command:\n\n```bash\n$ gem install cocoapods\n```\n\n#### Podfile\nIf you already have a Podfile, add the following line in your podfile:\n\n```ruby\npod 'BBLocationManager'\n```\n\nIf you already dont have a podfile, To integrate BBLocationManager into your Xcode project using CocoaPods, create and add it in your `Podfile`:\n\n```ruby\nsource 'https://github.com/CocoaPods/Specs.git'\nplatform :ios, '7.0'\n\ntarget 'YourTargetName' do\npod 'BBLocationManager'\nend\n```\n\nThen, run the following command:\n\n```bash\n$ pod install\n```\nAnd the pod should be installed in your project. **PLEASE NOTE:** Close the yourProject.xcodeProj and open the yourProject.xcworkspace, as the pod has been initiated, from now one use the yourProject.xcworkspace to work with. Please refer to [CocoaPods](http://cocoapods.org) for detailed info.\n\n#### Manual Installation\nJust add the BBLocationManager.h and BBLocationManager.m files in your project [From Here](https://github.com/benzamin/BBLocationManager/tree/master/BBLocationManager/BBLocationManagerClasses). Import the BBLocationManager.h file in your class where you need location support.\n\n## Permission\nBBLocationManager automatically reads the current location permission status of the app and requests for permission if needed. But you need to provide some information in your info.plist file of your project depending on the minimum iOS version you are trageting. For iOS Version **earlier then 8.0**, a description of your purpose is recommended to provide by setting a string for the key `NSLocationUsageDescription` in your app's Info.plist file.\n\n#### For iOS 11 and later\nFor **iOS 11** provide a description for how your app uses location services by setting a string for the key `NSLocationWhenInUseUsageDescription` or `NSLocationAlwaysAndWhenInUseUsageDescription` in your app's Info.plist file. When you build your app using the iOS 11 SDK, you are now required to provide an NSLocationWhenInUseUsageDescription key in all cases (if you use location at all). For “Always” access, you can additionally provide a second key, which is now called NSLocationAlwaysAndWhenInUseUsageDescription. If you only provide NSLocationAlwaysAndWhenInUseUsageDescription but not NSLocationWhenInUseUsageDescription, asking for “Always” access will not work. The old iOS 8/9/10 key NSLocationAlwaysUsageDescription is now only needed for backwards compatibility, if you’re still making the app available to iOS 10 or earlier users. It’s not needed or used on iOS 11 devices.\n\nBBLocationManager automatically reads which level of permissions to request based on which description key you provide. You should only request the minimum permission level that your app requires, therefore it is recommended that you use the \"When In Use\" level unless you require more access. If you want to get **loation update in background** (even when app not running), you **MUST** provide a key called `UIBackgroundModes` and add a item called `location` inside it. Please see the attached image for these keys for iOS 11 with compatibility:\n \n![Setting the keys in info.plist](https://raw.githubusercontent.com/benzamin/BBLocationManager/master/screens/iOS-11-keys.png  \"Configure these keys correctly for iOS 11, otherwise the location update might not work correctly.\")\n\n\n#### For iOS 8 and later\nStarting with **iOS 8, you MUST** provide a description for how your app uses location services by setting a string for the key `NSLocationWhenInUseUsageDescription` or `NSLocationAlwaysUsageDescription` in your app's Info.plist file. BBLocationManager automatically reads which level of permissions to request based on which description key you provide. You should only request the minimum permission level that your app requires, therefore it is recommended that you use the \"When In Use\" level unless you require more access. If you provide values for both description keys, the more permissive \"Always\" level is requested. \nAlso, if you want to get **loation update in background** (even when app not running), you **MUST** provide a key called `UIBackgroundModes` and add a item called `location` inside it. Please see the attached image for these keys for iOS 8/9/10:\n \n![Setting the keys in info.plist](https://raw.githubusercontent.com/benzamin/BBLocationManager/master/screens/keys.png  \"Configure these keys correctly, otherwise the location update might not work correctly.\")\n\n## Usage\n\nFirst import `BBLocationManager.h` header in your class. Calling `[BBLocationManager sharedManager]` creates an singleton class of `BBLocationManager` and manages everything from here. You can either use `BBLocationManagerDelegate` to get location/geofence related callbacks, or use Objective-C blocks to get location. For useing Geofence, the `BBFenceInfo` is a easy to use object, using which `BBLocationManager` delivers fence related data to your class. You can use `lastKnownGeocodeAddress` and `lastKnownGeoLocation` properties to get the last location/geocode the class got before.\n\n* To know the current location permission status call `+ (BOOL)locationPermission` method.\n* To manually ask the user for location permission before accessing location, call `-(void)getPermissionForStartUpdatingLocation` method.\n\n#### Getting current location (Using Block)\nGet BBLocationManager's shared instance, set the `desiredAcuracy` and `distanceFilter` parameter as you like, then request for current location using block or delegate.\n```objective-c\nBBLocationManager *manager = [BBLocationManager sharedManager];\nmanager.desiredAcuracy = 100; //how accurate you want your location, in meters   \nmanager.distanceFilter = 500; //you'll be notified if user moves away 500 meters from his initial location\n[manager getCurrentLocationWithCompletion:^(BOOL success, NSDictionary *latLongAltitudeDictionary, NSError *error) {\n        //access the 'latLongAltitudeDictionary' dictionary using BB_LATITUDE, BB_LONGITUDE, BB_ALTITUDE key\n        NSLog(@\"Current Location latitude: %@\", latLongAltitudeDictionary[BB_LATITUDE]);\n}];\n```\n#### Getting current location (Using Delegate)\n\n```objective-c\nBBLocationManager *manager = [BBLocationManager sharedManager];\nmanager.desiredAcuracy = 100; //how accurate you want your location, in meters   \nmanager.distanceFilter = 500; //you'll be notified if user moves away 500 meters from his initial location\n[manager getCurrentLocationWithDelegate:self];  \n......\n......\n#pragma mark - BBLocationManagerDelegate methods\n-(void)BBLocationManagerDidUpdateLocation:(NSDictionary *)latLongAltitudeDictionary\n{\n    //access the 'latLongAltitudeDictionary' dictionary using BB_LATITUDE, BB_LONGITUDE, BB_ALTITUDE key\n    NSLog(@\"Current Location Latitude: %@\", latLongAltitudeDictionary[BB_LATITUDE]);\n}\n```\n#### Getting current geocode/address (Using Block)\nYou can get user's current geocode AKA address from apple's geocode/maps server. You might need it for different purpose, and it might take a little time to get the location first and then determine the address.\n```objective-c\nBBLocationManager *manager = [BBLocationManager sharedManager];\n    [manager getCurrentGeoCodeAddressWithCompletion:^(BOOL success, NSDictionary *addressDictionary, NSError *error) {\n        //access the dict using BB_LATITUDE, BB_LONGITUDE, BB_ALTITUDE, BB_ADDRESS_NAME, BB_ADDRESS_STREET, BB_ADDRESS_CITY, BB_ADDRESS_STATE, BB_ADDRESS_COUNTY, BB_ADDRESS_ZIPCODE, BB_ADDRESS_COUNTY, BB_ADDRESS_DICTIONARY\n        NSLog(NSString stringWithFormat:@\"Current GeoCode/Address: %@\", addressDictionary.description);\n    }];\n```\n\n#### Add a geofence in current location\n\n```objective-c\nBBLocationManager *manager = [BBLocationManager sharedManager];\nmanager.delegate = self;\n[manager addGeofenceAtCurrentLocation];\n/*****can be also done using one of the following methods *****/\n//[manager addGeofenceAtCurrentLocationWithRadious:100];\n//[manager addGeofenceAtlatitude:59.331981f andLongitude:18.068435f withRadious:100 withIdentifier:@\"MyFence-1\";\n//[manager addGeofenceAtCurrentLocationWithRadious:100 withIdentifier:@\"MyFence-1\"];\n//[manager addGeofenceAtCoordinates:CLLocationCoordinate2DMake(59.331981f, 18.068435f) withRadious:100 withIdentifier:@\"MyFence-1\"];\n//[manager addGeofenceAtCoordinates:CLLocationCoordinate2DMake(59.331981f, 18.068435f) withRadious:100 withIdentifier:nil];//If you provide identifier name 'nil', BBLocationManager will automatically asign a identifier string\n ```\n \n![Geofence and alert](https://raw.githubusercontent.com/benzamin/BBLocationManager/master/screens/geofence.gif  \"Adding Geofence and getting alert\")\n![Geofence Alert](https://raw.githubusercontent.com/benzamin/BBLocationManager/master/screens/geofence-alert.gif  \"Geofence enter/exit alert while app in background/exited\")\n \n #### Get all added geofences \nSee which geofence is already added to get enter/exit callbacks. **NOTE:** You can add [maximum 20 geofences, its a limit [apple put](https://developer.apple.com/library/content/documentation/UserExperience/Conceptual/LocationAwarenessPG/RegionMonitoring/RegionMonitoring.html) in region monitoring.\n```objective-c\n BBLocationManager *manager = [BBLocationManager sharedManager];\n    \n    NSArray *geoFences = [manager getCurrentFences];\n    NSString *allFencetxt = @\"All fences: \";\n    for (BBFenceInfo *geofence in geoFences)\n    {\n        NSString *txt = [NSString stringWithFormat:@\"Geofence '%@' is Active at Coordinates: %@:%@ with %@ meter radious \\n\", geofence.fenceIDentifier, [geofence.fenceCoordinate objectForKey:BB_LATITUDE],[geofence.fenceCoordinate objectForKey:BB_LONGITUDE], [geofence.fenceCoordinate objectForKey:BB_RADIOUS]];\n        NSLog(@\"%@\", txt);\n    }\n```\n\n #### Delete a spefific geofence\n\n```objective-c\n BBLocationManager *manager = [BBLocationManager sharedManager];\n[manager deleteGeoFenceWithIdentifier:@\"My-Geofence-3\"];\n```\n\n#### Subscribe to Continious location\nTo get continuous location updates, use `-getContiniousLocationWithDelegate:` method. This will enable the BBLocationManager to listen every bit of change in location, and will keep you updated using the `-BBLocationManagerDidUpdateLocation:` delegate call. To stop getting continious location, call `-stopGettingLocation` method. Note that, until you stop the continious location, it will keep updating and will use battery life.\n```objective-c\nBBLocationManager *manager = [BBLocationManager sharedManager];\n[manager getContiniousLocationWithDelegate:self];\n```\n#### Subscribe to Significant location change\nTo get significant location changes, use `-getSingificantLocationChangeWithDelegate:` method. This will start looking for for significant location changes, which is very power efficient. The delegate callback `-BBLocationManagerDidUpdateLocation:` will be called everytime BBLocationManager finds any significant location change. This can be stoped by calling the `-stopGettingLocation` method. \n```objective-c\nBBLocationManager *manager = [BBLocationManager sharedManager];\n[manager getSingificantLocationChangeWithDelegate:self];\n```\n**NOTE:** Significant location change will not be called frequently. According to [Apple documentation:](https://developer.apple.com/library/content/documentation/UserExperience/Conceptual/LocationAwarenessPG/CoreLocation/CoreLocation.html)\n\u003e\"Apps can expect a notification as soon as the device moves 500 meters or more from its previous notification. It should not expect notifications more frequently than once every five minutes. If the device is able to retrieve data from the network, the location manager is much more likely to deliver notifications in a timely manner.\"\n\n#### Stop getting all kind of location\n\n```objective-c\nBBLocationManager *manager = [BBLocationManager sharedManager];\n[manager stopGettingLocation];\n```\n#### BBLocationManagerDelegate methods\n```objective-c\n-(void)BBLocationManagerDidUpdateLocation:(NSDictionary *)latLongAltitudeDictionary;\n\n-(void)BBLocationManagerDidUpdateGeocodeAdress:(NSDictionary *)addressDictionary;\n\n-(void)BBLocationManagerDidAddFence:(BBFenceInfo *)fenceInfo;\n-(void)BBLocationManagerDidFailedFence:(BBFenceInfo *)fenceInf\n-(void)BBLocationManagerDidEnterFence:(BBFenceInfo *)fenceInfo\n-(void)BBLocationManagerDidExitFence:(BBFenceInfo *)fenceInfo;\n\n```\n## Example Project\n [Downloading the full source code](https://github.com/benzamin/BBLocationManager/archive/master.zip) or checking out using git will provide you the example project. Give it a try, dont forget to specify a location in the iOS Simulator's Debug \u003e Location menu if you aren't testing on real device.\n \n## Other Reads\n\n* [BBLocationManager: Simple yet powerfull](http://redgreen.studio/blog/2017/03/21/bblocationmanager-simple-yet-powerfull/) - A blog post on BBLocationManager.\n\n## Issues and Contributions\n\nPlease [raise an issue here](https://github.com/benzamin/BBLocationManager/issues) if you find any bug, I'll try to resolve it asap. You can also make [pull requests](https://github.com/benzamin/BBLocationManager/pulls) if you want.\n\n## License\n\nThis project is licensed under the MIT License - see the [LICENSE.md](LICENSE.md) file for details. \n\n### Using BBLocationManager in your project?\nIf you are using this library in your project, and happy about it, please send me a [email](mailto:benzamin1985@gmail.com) and let me know, I'll add a references of your app. Thanks :)\n\n","funding_links":[],"categories":["Hardware"],"sub_categories":["Location","Other free courses"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbenzamin%2FBBLocationManager","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbenzamin%2FBBLocationManager","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbenzamin%2FBBLocationManager/lists"}