{"id":18825496,"url":"https://github.com/outsystems/cordova-plugin-geofence","last_synced_at":"2025-04-14T01:31:28.205Z","repository":{"id":46317549,"uuid":"53604917","full_name":"OutSystems/cordova-plugin-geofence","owner":"OutSystems","description":null,"archived":true,"fork":false,"pushed_at":"2024-02-22T19:03:55.000Z","size":3578,"stargazers_count":0,"open_issues_count":11,"forks_count":10,"subscribers_count":27,"default_branch":"master","last_synced_at":"2025-03-05T23:46:21.427Z","etag":null,"topics":["engineering","odc","snyk-archive","ssdlc-rules"],"latest_commit_sha":null,"homepage":null,"language":"Swift","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/OutSystems.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-03-10T17:47:41.000Z","updated_at":"2024-05-22T14:53:17.000Z","dependencies_parsed_at":"2024-11-08T06:01:52.099Z","dependency_job_id":null,"html_url":"https://github.com/OutSystems/cordova-plugin-geofence","commit_stats":null,"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OutSystems%2Fcordova-plugin-geofence","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OutSystems%2Fcordova-plugin-geofence/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OutSystems%2Fcordova-plugin-geofence/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OutSystems%2Fcordova-plugin-geofence/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/OutSystems","download_url":"https://codeload.github.com/OutSystems/cordova-plugin-geofence/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248807571,"owners_count":21164710,"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":["engineering","odc","snyk-archive","ssdlc-rules"],"created_at":"2024-11-08T00:59:43.652Z","updated_at":"2025-04-14T01:31:28.192Z","avatar_url":"https://github.com/OutSystems.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Cordova Geofence Plugin\n\n###This Plugin is an extension from: [cordova-plugin-geofence](https://github.com/cowbell/cordova-plugin-geofence)\n\n---\n\nPlugin forked from Cowbell Repository to extend functionalities. The main goal here was add more features like as:\n\n* Works with the Application closed;\n* On Notification Clicked the app can be opened by a DeepLink, Deeplink is sent in the Geofence Register on the data parameter;\n* Upgrade Google Play Service for version 8.4;\n* When the application is opened from notification the notification data can be delivered as a deeplink or in the WebView;\n* Only Create Notifications when the app is in background or closed;\n\n---\n\nPlugin to monitor circular geofences using mobile devices. The purpose is to notify user if crossing the boundary of the monitored geofence.\n\n*Geofences persist after device reboot. You do not have to open your app first to monitor added geofences*\n\n\n## Installation\n\nFrom master\n```\ncordova plugin add https://github.com/OutSystems/cordova-plugin-geofence.git\n```\n\n## Removing the Plugin from project\n\nUsing cordova CLI\n\n```\ncordova plugin rm cordova-plugin-geofence\n```\n\n## Supported Platforms\n\n- Android\n- iOS \u003e=7.0\n- Windows Phone 8.1\n    - using Universal App (cordova windows platform)\n    - using Silverlight App (cordova wp8 platform retargeted to WP 8.1)\n\n# Using the plugin\n\nCordova initialize plugin to `window.geofence` object.\n\n## Methods\n\n- `window.geofence.initialize(onSuccess, onError)`\n- `window.geofence.addOrUpdate(geofences, onSuccess, onError)`\n- `window.geofence.remove(geofenceId, onSuccess, onError)`\n- `window.geofence.removeAll(onSuccess, onError)`\n- `window.geofence.getWatched(onSuccess, onError)`\n\nAll methods returning promises, but you can also use standard callback functions.\n\nFor listening of geofence transistion you can override onTransitionReceived method\n- `window.geofence.onTransitionReceived(geofences)`\n\n## Constants\n\n- `TransitionType.ENTER` = 1\n- `TransitionType.EXIT` = 2\n- `TransitionType.BOTH` = 3\n\n## Plugin initialization\n\nThe plugin is not available until `deviceready` event is fired.\n\n```javascript\ndocument.addEventListener('deviceready', function () {\n    // window.geofence is now available\n    window.geofence.initialize();\n}, false);\n```\n\n## Adding new geofence to monitor\n\n```javascript\nwindow.geofence.addOrUpdate({\n    id:             String, //A unique identifier of geofence\n    latitude:       Number, //Geo latitude of geofence\n    longitude:      Number, //Geo longitude of geofence\n    radius:         Number, //Radius of geofence in meters\n    transitionType: Number, //Type of transition 1 - Enter, 2 - Exit, 3 - Both\n    notification: {         //Notification object\n        id:             Number, //optional should be integer, id of notification\n        title:          String, //Title of notification\n        text:           String, //Text of notification\n        smallIcon:      String, //Small icon showed in notification area, only res URI\n        icon:           String, //icon showed in notification drawer\n        openAppOnClick: Boolean,//is main app activity should be opened after clicking on notification\n        vibration:      [Integer], //Optional vibration pattern - see description\n        data:           Object,  //Custom object associated with notification\n        dateStart:      Date, // Initial Date to start dispatch events of a Geofence - Optiona parameter\n        dateEnd:        Date, // End Date to stop dispatch events of a Geofence - Optiona parameter\n        happensOnce:    Boolean,  // only show a notification once - Default value false\n    }\n}).then(function () {\n    console.log('Geofence successfully added');\n}, function (reason) {\n    console.log('Adding geofence failed', reason);\n});\n```\nAdding more geofences at once\n```javascript\nwindow.geofence.addOrUpdate([geofence1, geofence2, geofence3]);\n```\n\nGeofence overrides the previously one with the same `id`.\n\n*All geofences are stored on the device and restored to monitor after device reboot.*\n\nNotification overrides the previously one with the same `notification.id`.\n\n## Notification vibrations\n\nYou can set vibration pattern for the notification or disable default vibrations.\n\nTo change vibration pattern set `vibrate` property of `notification` object in geofence.\n\n###Examples\n\n```\n//disable vibrations\nnotification: {\n    vibrate: [0]\n}\n```\n\n```\n//Vibrate for 1 sec\n//Wait for 0.5 sec\n//Vibrate for 2 sec\nnotification: {\n    vibrate: [1000, 500, 2000]\n}\n```\n\n###Platform quirks\n\nFully working only on Android.\n\nOn iOS vibration pattern doesn't work. Plugin only allow to vibrate with default system pattern.\n\nWindows Phone - current status is TODO\n\n## Notification icons\n\nTo set notification icons use `icon` and `smallIcon` property in `notification` object.\n\nAs a value you can enter:\n- name of native resource or your application resource e.g. `res://ic_menu_mylocation`, `res://icon`, `res://ic_menu_call`\n- relative path to file in `www` directory e.g. `file://img/ionic.png`\n\n`smallIcon` - supports only resources URI\n\n###Examples\n\n```\nnotification: {\n    smallIcon: 'res://my_location_icon',\n    icon: 'file://img/geofence.png'\n}\n```\n\n###Platform quirks\n\nWorks only on Android platform so far.\n\n## Removing\n\nRemoving single geofence\n```javascript\nwindow.geofence.remove(geofenceId)\n    .then(function () {\n        console.log('Geofence sucessfully removed');\n    }\n    , function (reason){\n        console.log('Removing geofence failed', reason);\n    });\n```\nRemoving more than one geofence at once.\n```javascript\nwindow.geofence.remove([geofenceId1, geofenceId2, geofenceId3]);\n```\n\n## Removing all geofences\n\n```javascript\nwindow.geofence.removeAll()\n    .then(function () {\n        console.log('All geofences successfully removed.');\n    }\n    , function (reason) {\n        console.log('Removing geofences failed', reason);\n    });\n```\n\n## Getting watched geofences from device\n\n```javascript\nwindow.geofence.getWatched().then(function (geofencesJson) {\n    var geofences = JSON.parse(geofencesJson);\n});\n```\n\n## Listening for geofence transitions\n\n```javascript\nwindow.geofence.onTransitionReceived = function (geofences) {\n    geofences.forEach(function (geofences) {\n        console.log('Geofence transition detected', geo);\n    });\n};\n```\n\n## When the app is opened via Notification click\n\nAndroid, iOS only\n\n`window.geofence.onTransitionReceived` callback will be called and, for each geofence the property `openedFromNotification` will be true.\n\n#Example usage\n\nAdding geofence to monitor entering Gliwice city center area of radius 3km\n\n```javascript\nwindow.geofence.addOrUpdate({\n    id:             \"69ca1b88-6fbe-4e80-a4d4-ff4d3748acdb\",\n    latitude:       50.2980049,\n    longitude:      18.6593152,\n    radius:         3000,\n    transitionType: TransitionType.ENTER,\n    notification: {\n        id:             1,\n        title:          \"Welcome in Gliwice\",\n        text:           \"You just arrived to Gliwice city center.\",\n        openAppOnClick: true\n    }\n}).then(function () {\n    console.log('Geofence successfully added');\n}, function (reason) {\n    console.log('Adding geofence failed', reason);\n})\n```\n\n# Platform specifics\n\n##Android\n\nThis plugin uses Google Play Services so you need to have it installed on your device.\nThis plugin uses GSON to do parse of the JSON, if you use the same library in your project you can have conflicts.\n\n##iOS\n\nPlugin is written in Swift. All xcode project options to enable swift support are set up automatically after plugin is installed.\nPlugin has a category to AppDelegate that assumes the name \"AppDelagate\" if you have a diferent name in your project you need replace the name in this category.\n\n##Windows phone 8.1\n\nPlugin can be used with both windows phone 8.1 type projects Univeral App, Silverlight App.\n\nIn order to use toast notifications you have to enable this feature in appxmanifest file either using UI in Visual Studio or edit file setting attribute **ToastCapable=\"true\"** in **m3:VisualElements** node under Package/Applications/Application.\n\nIf you are retargeting WP 8.0 to WP 8.1 you need to register background task to perform geofence notifications. Register it via UI in Visual Studio or add following code under Package/Applications/Application/Extensions\n\n```xml\n\u003cExtension Category=\"windows.backgroundTasks\" EntryPoint=\"GeofenceComponent.GeofenceTrigger\"\u003e\n    \u003cBackgroundTasks\u003e\n        \u003cm2:Task Type=\"location\" /\u003e\n    \u003c/BackgroundTasks\u003e\n\u003c/Extension\u003e\n```\n\n# Development\n\n##Installation\n\n- git clone https://github.com/OutSystems/cordova-plugin-geofence\n- change into the new directory\n- `npm install`\n\n---\n\n## Contributors\n- OutSystems - Mobility Experts\n    - João Gonçalves, \u003cjoao.goncalves@outsystems.com\u003e\n    - Rúben Gonçalves, \u003cruben.goncalves@outsystems.com\u003e\n    - Vitor Oliveira, \u003cvitor.oliveira@outsystems.com\u003e\n\n#### Document author\n- Vitor Oliveira, \u003cvitor.oliveira@outsystems.com\u003e\n\n###Copyright OutSystems, 2016\n\nOriginal Creator: [Cowbell-labs.]( https://github.com/cowbell)\n\n---\n\n##License\n\nThis software is released under the [Apache 2.0 License](http://opensource.org/licenses/Apache-2.0).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foutsystems%2Fcordova-plugin-geofence","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Foutsystems%2Fcordova-plugin-geofence","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foutsystems%2Fcordova-plugin-geofence/lists"}