{"id":15587483,"url":"https://github.com/peterstaev/nativescript-geofence-manager","last_synced_at":"2025-04-13T05:50:53.196Z","repository":{"id":190622818,"uuid":"683086170","full_name":"PeterStaev/nativescript-geofence-manager","owner":"PeterStaev","description":"A NativeScript plugin to work with geofences","archived":false,"fork":false,"pushed_at":"2023-11-09T08:26:30.000Z","size":266,"stargazers_count":2,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-26T22:36:06.629Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/PeterStaev.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null},"funding":{"github":null,"patreon":null,"open_collective":null,"ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"lfx_crowdfunding":null,"custom":["https://revolut.me/petarstaev"]}},"created_at":"2023-08-25T15:05:49.000Z","updated_at":"2023-08-31T06:33:37.000Z","dependencies_parsed_at":null,"dependency_job_id":"7ba4f5dc-59bb-4370-850f-09f0fc3614a6","html_url":"https://github.com/PeterStaev/nativescript-geofence-manager","commit_stats":null,"previous_names":["peterstaev/nativescript-geofence-manager"],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PeterStaev%2Fnativescript-geofence-manager","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PeterStaev%2Fnativescript-geofence-manager/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PeterStaev%2Fnativescript-geofence-manager/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PeterStaev%2Fnativescript-geofence-manager/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/PeterStaev","download_url":"https://codeload.github.com/PeterStaev/nativescript-geofence-manager/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248670501,"owners_count":21142901,"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":[],"created_at":"2024-10-02T22:01:51.329Z","updated_at":"2025-04-13T05:50:53.134Z","avatar_url":"https://github.com/PeterStaev.png","language":"TypeScript","funding_links":["https://revolut.me/petarstaev"],"categories":[],"sub_categories":[],"readme":"# NativeScript Geofence Manager\n\nA NativeScript plugin to work with Geofences\n\n## Installation\n\nRun the following command from the root of your project:\n\n`tns plugin add nativescript-geofence-manager`\n\nThis command automatically installs the necessary files, as well as stores nativescript-geofence-manager as a dependency in your project's package.json file.\n\n## API\n\n### Events\n* **enterRegion**  \nTriggered when the the device reports that it enters a geofence region. \n\n* **exitRegion**  \nTriggered when the the device reports that it exists a geofence region. \n\n### Instance Properties\n* **enterRegionEvent** - *string*  \nString value used when hooking to enterRegion event.\n\n* **exitRegionEvent** - *string*  \nString value used when hooking to exitRegion event.\n\n* **activeGeofenceIds** - *string[]*  \nGets the currently active Geofence IDs.\n\n### Methods \n* **canMonitor(): boolean**  \nReturn if the device currently is capable of monitoring geofences.\n\n* **startMonitoringRegion(region: CircularRegion): void**  \nStarts monitoring the geofence defined by given circular region. \n\n* **stopMonitoringRegion(identifier: string): void**  \nStops monitoring the given geofence id. \n\n* **stopMonitoringAllRegions(): void**  \nStops monitoring all geofences defined by the app. \n\n## Usage (Core)\n\nYou need to import the geofence manager in the start up file for the app. This setups the needed native event listeners.  \nIt is recommended to also subscribe to the manager's events in the main app file to ensure that when the device is awaken by the OS you will receive the notification. Note that this has to be done before calling `run()` for your app\n\n```ts\nimport { GeofenceManager, RegionChangedEventData } from \"nativescript-geofence-manager\";\n\nGeofenceManager.on(GeofenceManager.enterRegionEvent, (args: RegionChangedEventData) =\u003e {\n    console.log(\"GeofenceManager.enterRegionEvent\", args.region.identifier);\n});\n\nGeofenceManager.on(GeofenceManager.exitRegionEvent, (args: RegionChangedEventData) =\u003e {\n    console.log(\"GeofenceManager.exitRegionEvent\", args.region.identifier);\n});\n\nApplication.run({ moduleName: \"app-root\" });\n```\n\nIn order to receive event notifications even when the app is in the background you need to request always location usage permissions. This has some caveats deppending on what platform and for android even on what SDK version is your app running. You can check the code of the demo app to see what I found to work best, but you can change this to better suit your needs as needed. \n\nIn order to start monitoring for a given region you can simply call the `startMonitoring` method and pass the circular region you want to monitor as well as if you want to monitor enter, exit, or both events. The `identifier` must be unique as if you call a second time `startMonitoringRegion` with the same `identifier` it will simply edit previous region. \n```ts\nimport { GeofenceManager } from \"nativescript-geofence-manager\";\n\nGeofenceManager.startMonitoringRegion({\n    identifier: \"Apple HQ\",\n    center: { latitude: 37.330551, longitude: -122.030583 },\n    radius: 30,\n    notifyOnEntry: true,\n    notifyOnExit: true,\n});\n```\n\nOnce you are no longer intereseted in a region remember to call `stopMonitoringRegion`\n```ts\nGeofenceManager.stopMonitoringRegion(\"Apple HQ\");\n```\n\n## Usage in other NativeScript flavors (Angular, Vue, etc.)\n\nCurrently the plugin has not been tested nor made to support other NS flavors, since I'm not actively using those. If you are such a dev, I'm happily accepting PRs to support all the NS flavors ot there :)\n\n## Caveats\n* Each platform has different limitations to maximum allowed geofences. For iOS this 20 while for android this is 100. Once that number is reached calls to `startMonitoringRegion` will stop adding further geofences. \n* Testing for android in emulator is supbar. Although you can define a route and start it, seems location isn't updated correctly. The only way I managed to get it working is to start the route AND open Google Maps on the device. This seems to be forcing the emulator to crrectly report position and trigger the events. \n\n## License\n\nApache License Version 2.0, January 2004\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpeterstaev%2Fnativescript-geofence-manager","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpeterstaev%2Fnativescript-geofence-manager","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpeterstaev%2Fnativescript-geofence-manager/lists"}