{"action":"created","issue":{"url":"https://api.github.com/repos/petermetz/cordova-plugin-ibeacon/issues/128","labels_url":"https://api.github.com/repos/petermetz/cordova-plugin-ibeacon/issues/128/labels{/name}","comments_url":"https://api.github.com/repos/petermetz/cordova-plugin-ibeacon/issues/128/comments","events_url":"https://api.github.com/repos/petermetz/cordova-plugin-ibeacon/issues/128/events","html_url":"https://github.com/petermetz/cordova-plugin-ibeacon/issues/128","id":58474560,"number":128,"title":"didEnterRegion does not work in BackgroundMode","user":{"login":"deantomasevic","id":2656987,"avatar_url":"https://avatars.githubusercontent.com/u/2656987?v=3","gravatar_id":"","url":"https://api.github.com/users/deantomasevic","html_url":"https://github.com/deantomasevic","followers_url":"https://api.github.com/users/deantomasevic/followers","following_url":"https://api.github.com/users/deantomasevic/following{/other_user}","gists_url":"https://api.github.com/users/deantomasevic/gists{/gist_id}","starred_url":"https://api.github.com/users/deantomasevic/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/deantomasevic/subscriptions","organizations_url":"https://api.github.com/users/deantomasevic/orgs","repos_url":"https://api.github.com/users/deantomasevic/repos","events_url":"https://api.github.com/users/deantomasevic/events{/privacy}","received_events_url":"https://api.github.com/users/deantomasevic/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":4,"created_at":"2015-02-21T20:55:15Z","updated_at":"2015-05-03T21:43:24Z","closed_at":null,"body":"Hello,\r\n\r\nthe delegate method didEnterRegion will be called fine if the app is open/active, but not if the app is closed (iOS => Press Homebutton).\r\n\r\nMy app structure is:\r\n* App starts run(..)\r\n* Start WelcomeCtrl\r\n* Start BeaconCtrl\r\n\r\nMy BeaconCtrl use a beaconService with the following content:\r\n\r\n```javascript\r\n    var service = {\r\n      searchForBeacons: function (userBeaconRegions) {\r\n        $ionicPlatform.ready(function() {\r\n          // Scan for Beacons after device is ready\r\n          window.locationManager = cordova.plugins.locationManager;\r\n\r\n          // Start tracking beacons!\r\n          startBeaconScan();\r\n          // Display refresh timer.\r\n          updateTimer = setInterval(displayBeaconList, 1000);\r\n\r\n          return $rootScope.beaconData;\r\n        });\r\n      }\r\n    };\r\n\r\n    return service;\r\n\r\n    function startBeaconScan() {\r\n      locationManager.requestAlwaysAuthorization();\r\n      var createLocalNotification = function (message) {\r\n        cordova.plugins.notification.local.schedule({\r\n          id:   1,\r\n          title: \"Welcome!\",\r\n          text: message,\r\n          sound: null,\r\n          autoCancel: true\r\n        });\r\n      };\r\n\r\n      var delegate = new locationManager.Delegate();\r\n\r\n      delegate.didRangeBeaconsInRegion = function(pluginResult) {\r\n        // console.log('didRangeBeaconsInRegion: ' + JSON.stringify(pluginResult))\r\n        for (var i in pluginResult.beacons)\r\n        {\r\n          // Insert beacon into table of found beacons.\r\n          var beacon = pluginResult.beacons[i];\r\n\r\n          beacon.timeStamp = Date.now();\r\n          var key = beacon.uuid + ':' + beacon.major + ':' + beacon.minor;\r\n          beacons[key] = beacon;\r\n        }\r\n      };\r\n\r\n      // Called when starting to monitor a region.\r\n      delegate.didStartMonitoringForRegion = function(pluginResult) {\r\n        console.log('didStartMonitoringForRegion:' + JSON.stringify(pluginResult))\r\n      };\r\n\r\n      // Called when monitoring and the state of a region changes.\r\n      delegate.didDetermineStateForRegion = function(pluginResult) {\r\n        console.log('didDetermineStateForRegion: ' + JSON.stringify(pluginResult))\r\n        if(pluginResult.state === \"CLRegionStateInside\"){\r\n          console.log(\"Inside Region.\");\r\n        } else if(pluginResult.state === \"CLRegionStateOutside\"){\r\n          console.log(\"Outside Region.\");\r\n        }\r\n      };\r\n\r\n      delegate.didExitRegion = function(pluginResult) {\r\n        console.log('didExitRegion: ' + JSON.stringify(pluginResult));\r\n      };\r\n\r\n      delegate.didEnterRegion = function(pluginResult) {\r\n        console.log('didEnterRegion: ' + JSON.stringify(pluginResult))\r\n        createLocalNotification('this is my local push notification.');\r\n      };\r\n\r\n      // Set the delegate object to use.\r\n      locationManager.setDelegate(delegate);\r\n\r\n      // Start monitoring and ranging beacons.\r\n      for (var i in userBeaconRegions) {\r\n        var notifyEntryStateOnDisplay = true;\r\n        var beaconRegion = new locationManager.BeaconRegion(\r\n          i + 1,\r\n          userBeaconRegions[i].uuid,\r\n          userBeaconRegions[i].major,\r\n          userBeaconRegions[i].minor,\r\n          notifyEntryStateOnDisplay\r\n        );\r\n\r\n        // Start ranging.\r\n        locationManager.startRangingBeaconsInRegion(beaconRegion)\r\n          .fail(\"+++ \" + console.error)\r\n          .done();\r\n\r\n        // Start monitoring.\r\n        // (Not used in this example, included as a reference.)\r\n        locationManager.startMonitoringForRegion(beaconRegion)\r\n          .fail(\"+++ \" + console.error)\r\n          .done();\r\n      }\r\n    }\r\n```\r\n\r\nAnybody know what is going wrong?\r\n\r\nThanks!"},"comment":{"url":"https://api.github.com/repos/petermetz/cordova-plugin-ibeacon/issues/comments/98547201","html_url":"https://github.com/petermetz/cordova-plugin-ibeacon/issues/128#issuecomment-98547201","issue_url":"https://api.github.com/repos/petermetz/cordova-plugin-ibeacon/issues/128","id":98547201,"user":{"login":"deantomasevic","id":2656987,"avatar_url":"https://avatars.githubusercontent.com/u/2656987?v=3","gravatar_id":"","url":"https://api.github.com/users/deantomasevic","html_url":"https://github.com/deantomasevic","followers_url":"https://api.github.com/users/deantomasevic/followers","following_url":"https://api.github.com/users/deantomasevic/following{/other_user}","gists_url":"https://api.github.com/users/deantomasevic/gists{/gist_id}","starred_url":"https://api.github.com/users/deantomasevic/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/deantomasevic/subscriptions","organizations_url":"https://api.github.com/users/deantomasevic/orgs","repos_url":"https://api.github.com/users/deantomasevic/repos","events_url":"https://api.github.com/users/deantomasevic/events{/privacy}","received_events_url":"https://api.github.com/users/deantomasevic/received_events","type":"User","site_admin":false},"created_at":"2015-05-03T21:43:24Z","updated_at":"2015-05-03T21:43:24Z","body":"Hello cvoisey,\r\n\r\nyes. I created a service which i start inside the run(..) function in app.js. "}}