{"action":"created","issue":{"url":"https://api.github.com/repos/petermetz/cordova-plugin-ibeacon/issues/259","repository_url":"https://api.github.com/repos/petermetz/cordova-plugin-ibeacon","labels_url":"https://api.github.com/repos/petermetz/cordova-plugin-ibeacon/issues/259/labels{/name}","comments_url":"https://api.github.com/repos/petermetz/cordova-plugin-ibeacon/issues/259/comments","events_url":"https://api.github.com/repos/petermetz/cordova-plugin-ibeacon/issues/259/events","html_url":"https://github.com/petermetz/cordova-plugin-ibeacon/issues/259","id":182863545,"number":259,"title":"Monitoring beacons with app closed - IOS ","user":{"login":"codingjam","id":19617155,"avatar_url":"https://avatars.githubusercontent.com/u/19617155?v=3","gravatar_id":"","url":"https://api.github.com/users/codingjam","html_url":"https://github.com/codingjam","followers_url":"https://api.github.com/users/codingjam/followers","following_url":"https://api.github.com/users/codingjam/following{/other_user}","gists_url":"https://api.github.com/users/codingjam/gists{/gist_id}","starred_url":"https://api.github.com/users/codingjam/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/codingjam/subscriptions","organizations_url":"https://api.github.com/users/codingjam/orgs","repos_url":"https://api.github.com/users/codingjam/repos","events_url":"https://api.github.com/users/codingjam/events{/privacy}","received_events_url":"https://api.github.com/users/codingjam/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2016-10-13T18:23:26Z","updated_at":"2016-11-28T16:27:19Z","closed_at":null,"body":"I have seen many questions here related to this topic, but I haven't found an answer. This is a great plugin, it works as expected in foreground and background, but I can't get it to Monitor when app is closed. According to the Apple documentation, Monitoring for beacons is allowed in background and when app is killed/closed. When you kill the app, the iOS monitors for beacon regions that your app created and wakes up your app for few seconds in background when you enter/exit the beacon region. I have seen this working fine on Xamarin and native apps that I built before, but I can't get it work using this plugin on Cordova. The plugins documentation also says \"Region Monitoring (or geo fencing), works in all app states.\" for IOS. I saw a couple of posts here where people said they were able to Monitor with app closed. \n\nI have all the right permissions requestWhenInUseAuthorization and requestAlwaysAuthorization, Background App Refresh is on. I am also using local-notifications plugin. I am using the 3.4.1 version of this plugin and running iOS 10.0.2,\n\nHere are other existing related issues I have looked into: #227 #224 #247 \n\nCan someone provide some direction on this? How can I get it to Monitor beacons with app closed on ios? \n"},"comment":{"url":"https://api.github.com/repos/petermetz/cordova-plugin-ibeacon/issues/comments/263318143","html_url":"https://github.com/petermetz/cordova-plugin-ibeacon/issues/259#issuecomment-263318143","issue_url":"https://api.github.com/repos/petermetz/cordova-plugin-ibeacon/issues/259","id":263318143,"user":{"login":"RikdeVos","id":1113040,"avatar_url":"https://avatars.githubusercontent.com/u/1113040?v=3","gravatar_id":"","url":"https://api.github.com/users/RikdeVos","html_url":"https://github.com/RikdeVos","followers_url":"https://api.github.com/users/RikdeVos/followers","following_url":"https://api.github.com/users/RikdeVos/following{/other_user}","gists_url":"https://api.github.com/users/RikdeVos/gists{/gist_id}","starred_url":"https://api.github.com/users/RikdeVos/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/RikdeVos/subscriptions","organizations_url":"https://api.github.com/users/RikdeVos/orgs","repos_url":"https://api.github.com/users/RikdeVos/repos","events_url":"https://api.github.com/users/RikdeVos/events{/privacy}","received_events_url":"https://api.github.com/users/RikdeVos/received_events","type":"User","site_admin":false},"created_at":"2016-11-28T16:27:19Z","updated_at":"2016-11-28T16:27:19Z","body":"Hi,\r\n\r\nI'm facing exactly the same issue. I set up an environment which simply makes an http call to my server on didEnterRegion and didExitRegion events and I turn my ibeacon on/off every few minutes. In background mode it works for a couple of minutes (5-10), after that it stops making requests to my server and logging the events. However, in some cases it continued to work for hours at a time!\r\n\r\nLike @codingjam I'm running requestWhenInUseAuthorization and requestAlwaysAuthorization, and I've got (most of) the Background Modes checked in Capabilities in XCode.\r\n\r\nHave you by any chance figured out what was causing iOS to stop calling the event handlers?\r\n\r\nThis is the code I am using:\r\n`document.addEventListener(\"deviceready\", function () {\r\n\r\n            function lan_log(name, obj) {\r\n                if(typeof(obj) == typeof(undefined)) {\r\n                    obj = {};\r\n                }\r\n                console.log(name, obj);\r\n                var obj_str = JSON.stringify(obj);\r\n                $http({\r\n                    method: 'POST',\r\n                    url: 'http://192.168.2.58:8888/log/log.php?name='+name+'&obj='+encodeURIComponent(obj_str),\r\n                    data: {\r\n                        name: name,\r\n                        obj: obj_str\r\n                    }\r\n                }).then(function() {\r\n                    console.log('logged success');\r\n                })\r\n            }\r\n\r\n            var delegate = new cordova.plugins.locationManager.Delegate();\r\n\r\n            delegate.didDetermineStateForRegion = function (pluginResult) {\r\n                lan_log('didDetermineStateForRegion: ', pluginResult);\r\n            };\r\n\r\n            delegate.didStartMonitoringForRegion = function (pluginResult) {\r\n                lan_log('didStartMonitoringForRegion:', pluginResult);\r\n            };\r\n\r\n            delegate.didRangeBeaconsInRegion = function (pluginResult) {\r\n                lan_log('didRangeBeaconsInRegion: ', pluginResult);\r\n            };\r\n\r\n            delegate.didEnterRegion = function(pluginResult) {\r\n                lan_log('Entered region: ', pluginResult);\r\n            };\r\n\r\n            delegate.didExitRegion = function(pluginResult) {\r\n                lan_log('Exited region: ', pluginResult);\r\n            };\r\n\r\n            var uuid = 'a546722b-c9e2-4a07-8763-d1c78d3b48f1';\r\n            var major = '2';\r\n            var minor = '1';\r\n            var identifier = 'test';\r\n            var beaconRegion = new cordova.plugins.locationManager.BeaconRegion(identifier, uuid, major, minor, true);\r\n\r\n            lan_log(\"Going to monitor region now...\");\r\n            cordova.plugins.locationManager.setDelegate(delegate);\r\n\r\n            // required in iOS 8+\r\n            cordova.plugins.locationManager.requestWhenInUseAuthorization();\r\n            cordova.plugins.locationManager.requestAlwaysAuthorization();\r\n            // or cordova.plugins.locationManager.requestAlwaysAuthorization()\r\n\r\n            cordova.plugins.locationManager.startMonitoringForRegion(beaconRegion)\r\n                .fail(function(e) { lan_log(\"Error while trying to start monitoring\",e); })\r\n                .done();\r\n        });`"}}
{"actor":{"display_login":"RikdeVos"}}