Code Monkey home page Code Monkey logo

Comments (6)

florianbepunkt avatar florianbepunkt commented on August 20, 2024

I did some digging… I encounter this problem only when using Ionic. When I create an app with cordova create myproject and install the plugin, I can access the window.geofence object.

But with Ionic it says it is undefined… have somebody else encountered the same issue? Can somebody please help? Thanks

from cordova-plugin-geofence.

PaperMonster avatar PaperMonster commented on August 20, 2024

Did you run on device or browser? Cordova plugins always be undefined on browsers. If you're running on device, giving plugin version and other information from command ionic info would help pinpointing the problem faster.

from cordova-plugin-geofence.

florianbepunkt avatar florianbepunkt commented on August 20, 2024

Hey Papermonster,

I deleted my comment from before… it seems to work now. Thanks for the other issue you opened. Fixing this solved the problem + running it on the device.

One more thing, if you could help me out once more. Is there a way to specify options for this plugin, such as accuracy or the frequency how often the current location is checked?

I tested some geofences that are relatively close to each other (about 100 metres)… I registered them each with a radius of 10 but when I jumped between the coordinates for both I always got an enter event for both geofences. When I choose some geofences that are further part this does not occur.

Thanks,
Florian

from cordova-plugin-geofence.

PaperMonster avatar PaperMonster commented on August 20, 2024

I don't think you can specify accuracy or frequency unless modifying the plugin, as this plugin relies on standard iOS' region monitoring feature which is based on 'significant location change'. A discussion at Stackoverflow pointed out that the location mainly comes from surrounding Wi-Fi hotspots and cellular towers, not GPS. Also, region entrance/exit only triggers when crossing boundary by at least ~200m, as following quote from the documentation:

When testing your region monitoring code in iOS Simulator or on a device, realize that region events may not happen immediately after a region boundary is crossed. To prevent spurious notifications, iOS doesn’t deliver region notifications until certain threshold conditions are met. Specifically, the user’s location must cross the region boundary, move away from the boundary by a minimum distance, and remain at that minimum distance for at least 20 seconds before the notifications are reported.

The specific threshold distances are determined by the hardware and the location technologies that are currently available. For example, if Wi-Fi is disabled, region monitoring is significantly less accurate. However, for testing purposes, you can assume that the minimum distance is approximately 200 meters.

Therefore, regions smaller than 150m radius placed too close together are unlikely to be caught by region monitoring correctly.

If you really need high-accuracy region monitoring, you might consider modifying the plugin to utilize standard location (and/or background mode setup) which continuously track the location for the specified level of accuracy, at the cost of more battery draining.

from cordova-plugin-geofence.

florianbepunkt avatar florianbepunkt commented on August 20, 2024

@PaperMonster Thanks a lot for your help and the explanation.

from cordova-plugin-geofence.

StevenMapes avatar StevenMapes commented on August 20, 2024

I'm having this issue with geofence and phonegap.

I created a new phonegap project, installed the plugin, edit the config.xml as has been suggested else where

npm install -g phonegap
phonegap create geofenceTest com.test.geofence geofenceTest
phonegap plugin add cordova-plugin-add-swift-support
phonegap plugin add cordova-plugin-geofence

Edit config.xml to change the min version from 14 to 16
<preference name="android-minSdkVersion" value="16" />

Edit the index.html

    <script type="text/javascript">
        app.initialize();

        try {
            window.geofence.initialize(function(){console.log(1)}, function(){ console.log(2)}).then(function(){console.log(3)});
        } catch (e) {
            console.log(e)
        }
    </script>

When I then run the app (I'm using Webstorm with Phonegap/cordova plugin installed, running the serve command for android ) and I just receive this exception everytime

[phonegap] [console.log] TypeError: Cannot read property 'initialize' of undefined

from cordova-plugin-geofence.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.