Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ios: I am not getting notify when exiting a region #36

Open
i25878427 opened this issue Mar 22, 2014 · 4 comments
Open

ios: I am not getting notify when exiting a region #36

i25878427 opened this issue Mar 22, 2014 · 4 comments

Comments

@i25878427
Copy link

Hello,

I am trying to create region monitor, I wrote the code below but it doesn't alert me when the region is being exit.

When I run my code, a "initmonitor" alert is popup (as it should) and after clicking on the "foo" button, I received "startmonitor" alert.
Then in my xcode simulator I change the simulation location to a different city, and I expected to get exit region alert but it doesn't popup.

*I am using phonegap 3.1.0-0.15.0

I will appreciate if you can help me.

Thanks,
Roy

        <button onclick="foo()">foo</button>
    </div>
          <script type="text/javascript" src="cordova.js"></script>
    <!--script type="text/javascript" src="js/index.js"></script-->
    <script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
    <script src="http://code.jquery.com/mobile/1.3.2/jquery.mobile-1.3.2.min.js"></script>
    <script type="text/javascript" src="lib/DGGeofencing.js"></script>

     <script type="text/javascript" src="cordova.ios.js"></script>

    <script type="text/javascript">
        document.addEventListener('deviceready', onDeviceReady, false);
        // deviceready Event Handler`
        function onDeviceReady() {
            DGGeofencing.initCallbackForRegionMonitoring(new Array(), processRegionMonitorCallback, function(error) {
                 console.log("init error");
             });
        }
    processRegionMonitorCallback = function(result) {
        alert(result.callbacktype)
    }
    function foo(){

     var location = new Object();
     location.id ="111";
     location.location = new Object();
     location.location.lat = "32.0833"
     location.location.lng = "34.8000"

     var params = [location.id, location.location.lat, location.location.lng, "10", "3"];
     DGGeofencing.startMonitoringRegion(params, function(result) {alert(result)}, function(error) {
            alert("failed to add region");
     });


    }
    </script>
@radshag
Copy link
Owner

radshag commented Mar 22, 2014

I would not recommend testing the app in this way. You should deploy the app to a device that supports geofencing and test from there

From: i25878427
Sent: ‎Saturday‎, ‎22‎ ‎March‎ ‎2014 ‎17‎:‎36
To: radshag/PhoneGap-Geofencing

Hello,

I am trying to create region monitor, I wrote the code below but it doesn't alert me when the region is being exit.

When I run my code, a "initmonitor" alert is popup (as it should) and after clicking on the "foo" button, I received "startmonitor" alert.
Then in my xcode simulator I change the simulation location to a different city, and I expected to get exit region alert but it doesn't popup.

I will appreciate if you can help me.

Thanks,
Roy

    <button onclick="foo()">foo</button>
</div>
      <script type="text/javascript" src="cordova.js"></script>
<!--script type="text/javascript" src="js/index.js"></script-->
<script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
<script src="http://code.jquery.com/mobile/1.3.2/jquery.mobile-1.3.2.min.js"></script>
<script type="text/javascript" src="lib/DGGeofencing.js"></script>

 <script type="text/javascript" src="cordova.ios.js"></script>

<script type="text/javascript">
    document.addEventListener('deviceready', onDeviceReady, false);
    // deviceready Event Handler`
    function onDeviceReady() {
        DGGeofencing.initCallbackForRegionMonitoring(new Array(), processRegionMonitorCallback, function(error) {
             console.log("init error");
         });
    }
processRegionMonitorCallback = function(result) {
    alert(result.callbacktype)
}
function foo(){

 var location = new Object();
 location.id ="111";
 location.location = new Object();
 location.location.lat = "32.0833"
 location.location.lng = "34.8000"

 var params = [location.id, location.location.lat, location.location.lng, "10", "3"];
 DGGeofencing.startMonitoringRegion(params, function(result) {alert(result)}, function(error) {
        alert("failed to add region");
 });


}
</script>


Reply to this email directly or view it on GitHub.

@i25878427
Copy link
Author

thanks for replying.
I tested it on my iphone 5 and it doesn't work.
When I am using the example provided with the plugin, the "exit region" alert does work on my xcode simulator and also on my iphone.

@radshag
Copy link
Owner

radshag commented Mar 22, 2014

Do you get an enter region event when entering.
On Mar 22, 2014 11:38 PM, "i25878427" [email protected] wrote:

thanks for replying.
I tested it on my iphone 5 and it doesn't work.
When I am using the example provided with the plugin, the "exit region"
alert does work on my xcode simulator and also on my iphone.

Reply to this email directly or view it on GitHubhttps://github.com//issues/36#issuecomment-38364961
.

@i25878427
Copy link
Author

Thanks for helping, I found out why it was not working.
the reason was that i hard coded the latitude and longitude- I attached the working example below.

    </div>
          <script type="text/javascript" src="cordova.js"></script>
    <!--script type="text/javascript" src="js/index.js"></script-->
    <script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
    <script src="http://code.jquery.com/mobile/1.3.2/jquery.mobile-1.3.2.min.js"></script>
    <script type="text/javascript" src="lib/DGGeofencing.js"></script>

     <script type="text/javascript" src="cordova.ios.js"></script>

    <script type="text/javascript">
        var latitude;
        var longitude;
        document.addEventListener('deviceready', onDeviceReady, false);
        // deviceready Event Handler`

        function onDeviceReady() {
            DGGeofencing.initCallbackForRegionMonitoring(new Array(), processRegionMonitorCallback, function(error) {
                 console.log("init error");
             });


             navigator.geolocation.getCurrentPosition(onGeoSuccess, onGeoError, { maximumAge: 600000, timeout: 5000, enableHighAccuracy: true });
         }
        processRegionMonitorCallback = function(result) {
            alert(result.callbacktype)
        }



    function onGeoSuccess(position){
        latitude = position.coords.latitude;
        longitude = position.coords.longitude;
        var location = new Object();
        location.id ="111";
        location.location = new Object();
        location.location.lat = latitude
        location.location.lng = longitude

        var params = [location.id, location.location.lat, location.location.lng, "10", "3"];
        DGGeofencing.startMonitoringRegion(params, function(result) {alert(result)}, function(error) {
                                           alert("failed to add region");
                                           });

    }
    function onGeoError(error){


    }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants