Code Monkey home page Code Monkey logo

cordova-plugin-geofence's Introduction

Cordova Geofence Plugin

version

Plugin to monitor circular geofences using mobile devices. The purpose is to notify user if crossing the boundary of the monitored geofence.

Geofences persist after device reboot. You do not have to open your app first to monitor added geofences

Example applications

Check out our example applications:

Installation

From master

cordova plugin add https://github.com/cowbell/cordova-plugin-geofence

Latest stable version

cordova plugin add cordova-plugin-geofence

Removing the Plugin from project

Using cordova CLI

cordova plugin rm cordova-plugin-geofence

Supported Platforms

  • Android
  • iOS >=7.0
  • Windows Phone 8.1
    • using Universal App (cordova windows platform)
    • using Silverlight App (cordova wp8 platform retargeted to WP 8.1)

Known Limitations

This plugin is a wrapper on devices' native APIs which mean it comes with limitations of those APIs.

Geofence Limit

There are certain limits of geofences that you can set in your application depends on the platform of use.

  • iOS - 20 geofences
  • Android - 100 geofences

Javascript background execution

This is known limitation. When in background your app may/will be suspended to not use system resources. Therefore, any javascript code won't run, only background services can run in the background. Local notification when user crosses a geofence region will still work, but any custom javascript code won't. If you want to perform a custom action on geofence crossing, try to write it in native code.

Platform specifics

Android

This plugin uses Google Play Services so you need to have it installed on your device.

iOS

Plugin is written in Swift. All xcode project options to enable swift support are set up automatically after plugin is installed thanks to cordova-plugin-add-swift-support.

⚠️ Swift 3 is not supported at the moment, the following preference has to be added in your project :

For Cordova projects

<preference name="UseLegacySwiftLanguageVersion" value="true" />

For PhoneGap projects

<preference name="swift-version" value="2.3" />

iOS Quirks

Since iOS 10 it's mandatory to add a NSLocationAlwaysUsageDescription and NSLocationWhenInUseUsageDescription entries in the info.plist.

NSLocationWhenInUseUsageDescription describes the reason that the app accesses the user's location. NSLocationAlwaysUsageDescription describes the reason that the app accesses the user's location when not in use (in the background).

When the system prompts the user to allow access, this string is displayed as part of the dialog box. To add this entry you can pass the variable GEOFENCE_IN_USE_USAGE_DESCRIPTION and GEOFENCE_ALWAYS_USAGE_DESCRIPTION on plugin install.

Example: cordova plugin add cordova-plugin-geofence --variable GEOFENCE_IN_USE_USAGE_DESCRIPTION="your usage message" --variable GEOFENCE_ALWAYS_USAGE_DESCRIPTION="your usage message"

If you don't pass the variable, the plugin will add a default string as value.

Windows phone 8.1

Plugin can be used with both windows phone 8.1 type projects Univeral App, Silverlight App.

In 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.

If 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

<Extension Category="windows.backgroundTasks" EntryPoint="GeofenceComponent.GeofenceTrigger">
    <BackgroundTasks>
        <m2:Task Type="location" />
    </BackgroundTasks>
</Extension>

Using the plugin

Cordova initialize plugin to window.geofence object.

Methods

All methods returning promises, but you can also use standard callback functions.

  • window.geofence.initialize(onSuccess, onError)
  • window.geofence.addOrUpdate(geofences, onSuccess, onError)
  • window.geofence.remove(geofenceId, onSuccess, onError)
  • window.geofence.removeAll(onSuccess, onError)
  • window.geofence.getWatched(onSuccess, onError)

For listening of geofence transistion you can override onTransitionReceived method

  • window.geofence.onTransitionReceived(geofences)

Constants

  • TransitionType.ENTER = 1
  • TransitionType.EXIT = 2
  • TransitionType.BOTH = 3

Error Codes

Both onError function handler and promise rejection take error object as an argument.

error: {
    code: String,
    message: String
}

Error codes:

  • UNKNOWN
  • PERMISSION_DENIED
  • GEOFENCE_NOT_AVAILABLE
  • GEOFENCE_LIMIT_EXCEEDED

Plugin initialization

The plugin is not available until deviceready event is fired.

document.addEventListener('deviceready', function () {
    // window.geofence is now available
    window.geofence.initialize().then(function () {
        console.log("Successful initialization");
    }, function (error) {
        console.log("Error", error);
    });
}, false);

Initialization process is responsible for requesting neccessary permissions. If required permissions are not granted then initialization fails with error message.

Adding new geofence to monitor

window.geofence.addOrUpdate({
    id:             String, //A unique identifier of geofence
    latitude:       Number, //Geo latitude of geofence
    longitude:      Number, //Geo longitude of geofence
    radius:         Number, //Radius of geofence in meters
    transitionType: Number, //Type of transition 1 - Enter, 2 - Exit, 3 - Both
    notification: {         //Notification object
        id:             Number, //optional should be integer, id of notification
        title:          String, //Title of notification
        text:           String, //Text of notification
        smallIcon:      String, //Small icon showed in notification area, only res URI
        icon:           String, //icon showed in notification drawer
        openAppOnClick: Boolean,//is main app activity should be opened after clicking on notification
        vibration:      [Integer], //Optional vibration pattern - see description
        data:           Object  //Custom object associated with notification
    }
}).then(function () {
    console.log('Geofence successfully added');
}, function (error) {
    console.log('Adding geofence failed', error);
});

Adding more geofences at once

window.geofence.addOrUpdate([geofence1, geofence2, geofence3]);

Geofence overrides the previously one with the same id.

All geofences are stored on the device and restored to monitor after device reboot.

Notification overrides the previously one with the same notification.id.

Notification vibrations

You can set vibration pattern for the notification or disable default vibrations.

To change vibration pattern set vibrate property of notification object in geofence.

Examples

//disable vibrations
notification: {
    vibrate: [0]
}
//Vibrate for 1 sec
//Wait for 0.5 sec
//Vibrate for 2 sec
notification: {
    vibrate: [1000, 500, 2000]
}

Platform quirks

Fully working only on Android.

On iOS vibration pattern doesn't work. Plugin only allow to vibrate with default system pattern.

Windows Phone - current status is TODO

Notification icons

To set notification icons use icon and smallIcon property in notification object.

As a value you can enter:

  • name of native resource or your application resource e.g. res://ic_menu_mylocation, res://icon, res://ic_menu_call
  • relative path to file in www directory e.g. file://img/ionic.png

smallIcon - supports only resources URI

Examples

notification: {
    smallIcon: 'res://my_location_icon',
    icon: 'file://img/geofence.png'
}

Platform quirks

Works only on Android platform so far.

Removing

Removing single geofence

window.geofence.remove(geofenceId)
    .then(function () {
        console.log('Geofence sucessfully removed');
    }
    , function (error){
        console.log('Removing geofence failed', error);
    });

Removing more than one geofence at once.

window.geofence.remove([geofenceId1, geofenceId2, geofenceId3]);

Removing all geofences

window.geofence.removeAll()
    .then(function () {
        console.log('All geofences successfully removed.');
    }
    , function (error) {
        console.log('Removing geofences failed', error);
    });

Getting watched geofences from device

window.geofence.getWatched().then(function (geofencesJson) {
    var geofences = JSON.parse(geofencesJson);
});

Listening for geofence transitions

window.geofence.onTransitionReceived = function (geofences) {
    geofences.forEach(function (geo) {
        console.log('Geofence transition detected', geo);
    });
};

Listening for geofence transitions in native code

Android

For android plugin broadcasting intent com.cowbell.cordova.geofence.TRANSITION. You can implement your own BroadcastReceiver and start listening for this intent.

Register receiver in AndroidManifest.xml

<receiver android:name="YOUR_APP_PACKAGE_NAME.TransitionReceiver">
    <intent-filter>
        <action android:name="com.cowbell.cordova.geofence.TRANSITION" />
    </intent-filter>
</receiver>

Example TransitionReceiver.java code

......
import com.cowbell.cordova.geofence.Gson;
import com.cowbell.cordova.geofence.GeoNotification;

public class TransitionReceiver extends BroadcastReceiver {

    @Override
    public void onReceive(Context context, Intent intent) {
        String error = intent.getStringExtra("error");

        if (error != null) {
            //handle error
            Log.println(Log.ERROR, "YourAppTAG", error);
        } else {
            String geofencesJson = intent.getStringExtra("transitionData");
            GeoNotification[] geoNotifications = Gson.get().fromJson(geofencesJson, GeoNotification[].class);
            //handle geoNotifications objects
        }
    }
}

When the app is opened via Notification click

Android, iOS only

window.geofence.onNotificationClicked = function (notificationData) {
    console.log('App opened from Geo Notification!', notificationData);
};

Example usage

Adding geofence to monitor entering Gliwice city center area of radius 3km

window.geofence.addOrUpdate({
    id:             "69ca1b88-6fbe-4e80-a4d4-ff4d3748acdb",
    latitude:       50.2980049,
    longitude:      18.6593152,
    radius:         3000,
    transitionType: TransitionType.ENTER,
    notification: {
        id:             1,
        title:          "Welcome in Gliwice",
        text:           "You just arrived to Gliwice city center.",
        openAppOnClick: true
    }
}).then(function () {
    console.log('Geofence successfully added');
}, function (reason) {
    console.log('Adding geofence failed', reason);
})

Development

Installation

Running tests

  • Start emulator
  • cordova-paramedic --platform android --plugin .

Testing on iOS

Before you run cordova-paramedic install npm install -g ios-sim

Troubleshooting

Add --verbose at the end of cordova-paramedic command.

License

This software is released under the Apache 2.0 License.

© 2014-2017 Cowbell-labs. All rights reserved

cordova-plugin-geofence's People

Contributors

andicr avatar archee avatar byrning avatar cherez avatar keithmattix avatar lcoling avatar matimenich avatar mitko-kerezov avatar n9986 avatar petcarerx avatar phyr0s avatar rlataguerra avatar robertherhold avatar sondreb avatar tsubik avatar vziukas avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

cordova-plugin-geofence's Issues

Errors.

Errors after importing in eclipse
err

geofence plugin no longer compiles on ios

Hi, with the recent update of the core apple system that happened last night, it appears to me this plugin is no longer compatible. I'm getting build compile errors in Swift. Would love to help out but at present have no time so I'm passing this along. Please fix as soon as possible! :)

What I did to test this:

  1. downloaded fresh ionic-geofence example app from github
  2. have correct cli when running npm install
  3. ran npm install
  4. added ios platform (all plugins carried over from the output)
  5. ran in emulate: 5 swift compile errors
  6. ran in xcode: 19 swift compile errors

These errors are found in:
Plugins/json.swift
Plugins/SwiftData.swift
And your plugin, I replaced "as" to "as!" which fixes your issues apparently but it appears you are using libraries that are no longer compatible.

Thanks!

Can't Identify Which Transition Type Occurred When Using TransitionType = 3

When using TransitionType = 3 there is not way to identify if it was an 'entered' or 'exited' event that triggered the event. Could the 'geo' object be modified in some way to identify if it was an Enter or Exit transition that triggered the current transition call?

The only way to currently detect this is to create separate Enter and Exit geofences, which on iOS uses up 2 of the 20 allowed fences (instead of just 1).

ios support

Hi There,
More of a question than an issue. Any idea when you might be adding ios support?
thanks.

Hangs on 'Obtaining current location...' loader screen when deploying to Android device

I cloned this repo and deployed it to my android device.

When I click the (+) to add a geofence, the Obtaining current location... screen pops up and it just hangs.

I have tried different settings combinations between the wifi and location services and none of them cause it to not hang.

It works fine when I run in the browser, but not on my android device.

screenshot_2015-06-16-21-06-22

iOS failing to build on Phonegap Build

hello again, I have been testing this on Android for a few weeks now and it works perfectly.

but iOS is failing to build on Phonegap Build. I included in my config.xml to not do iOS6 (preference name="deployment-target" value="7.0") but it still fails to compile. error:

cordova-plugin-geofence/GeofencePlugin.swift:20:49: error: use of undeclared type 'CDVPlugin'

full build log here: https://www.dropbox.com/s/v6codigjsxgfe16/build.txt?dl=0

ps - I am using the npm version (https://www.npmjs.com/package/cordova-plugin-geofence)

iOS 20+ geofences

@tsubik technical question.

When I am adding bulk geofences they all get added to the database but in iOS only the first 20 are monitored. 20 is the iOS limit.

Question is , is there a way of changing which ones are monitored without having to remove them all and only add in 20?

Say I have 40 locations added to the database but I only want to monitor the closest 20.

IOS: GeofencePluginWebview is nil

I try to use the plugin with a IOS. Everything works except the receiveTransition callback.

Somehow the geofencepluginWebview is nil so the receiveTransition function in cordova never gets called. Any hints?

At this point, it always goes for the else branch

class func fireReceiveTransition(geoNotification: JSON) {
log("FIRE RECEIVE-TRANSIITON! ");
var mustBeArray = JSON
mustBeArray.append(geoNotification)
let js = "setTimeout('geofence.receiveTransition(" + mustBeArray.description + ")',0)";
if (GeofencePluginWebView != nil) {
GeofencePluginWebView!.stringByEvaluatingJavaScriptFromString(js);
log("Callback is called now ");

    }
    else {
        log("GeofencePluginWebview is nil!");
    }
}

on iOS, I cannot add geofence dynamically without the app freezing

Hi there,

I first tested adding a static geofence and it worked fine.
I then worked off a list of location.
I calculate the distance from the device location to each lat/long referenced in the list and get the 20 closest distance to me.

Once I have an array of 20 objects, I loop through each of them to add them as geofence but it doesn't work. I tried 1, 3, 5, 10. Any number makes the app freeze.

I took a step back and started thinking maybe my location array is wrong so I hardcoded basic lat/long following the static example that worked but no luck.

One question is:
Can I loop through geofence.addOrUpdate indefinitely passing new objects or can I only create one per geofenceService? I'm really confused as to why it is not working.

Error is :
screen shot 2015-05-16 at 1 50 17 am
screen shot 2015-05-16 at 1 51 28 am
screen shot 2015-05-16 at 1 51 40 am

Any help or advice would be greatly appreciated.

Cheers

EXC_BAD_INSTRUCTION (code=EXC_i386_INVOP, subcode=0x0)

Hi Tsubik,

On line 178 in GeofencePlugin.swift file geoNotification data set to .asDouble! creates this exception. If I comment out and force a literal double, it breaks somewhere else. This is happening trying to add or update a geofence.

screen shot 2015-04-30 at 11 29 53 am
screen shot 2015-04-30 at 11 30 01 am

Can you verify that this is also happening on your end?

Thanks,

Opening hours

Possibility to define date-time periods when the monitoring geofence should be active.

region persistence between relaunches

Hey Tomasz,
thanks for the cool plugin. I was wondering if regions persist between relaunches as described here:
https://developer.apple.com/library/mac/documentation/CoreLocation/Reference/CLLocationManager_Class/index.html

"In this case, the options dictionary passed to the application:didFinishLaunchingWithOptions: method of your app delegate contains the key UIApplicationLaunchOptionsLocationKey to indicate that your app was launched because of a location-related event."

thanks a lot,
max

Crosswalk issue

I've added crosswalk to my cordova app to boost performance. But this plugin seems to be incompatible with crosswalk. I always get these errors:
crosswalk

How to fix this?

ios background notification

@tsubik I've got the plugin working while the app is on in iOS7 & iOS8 but if the app is not open on iOS7 it doesn't get notifications when entering geofences. (haven't tested in 8).
Any thoughts?

Build fail on phonegap build

When using this plugin with Phonegap Build, it fails during the compilation.

The following build commands failed:
    CompileSwift normal arm64 /project/PGProject/Plugins/com.cowbell.cordova.geofence/GeofencePlugin.swift
    CompileSwift normal arm64 /project/PGProject/Plugins/com.cowbell.cordova.geofence/SwiftData.swift
    CompileSwiftSources normal arm64 com.apple.xcode.tools.swift.compiler

Full stack trace

I have absolutely no knowledge of Swift. @tsubik could you help me please ?

Google Play services resources were not found

Hi there!
I have recognized an error, when this plugin is installed.

E/GooglePlayServicesUtil﹕ The Google Play services resources were not found. Check your project configuration to ensure that the resources are included.

Is there a way to get rid of that error?

ios App rejected

Hi all,
today our app has been rejected. They were complaining about the "App registers for location updates" in the required background modes in the info.plist. We have replied that we need that key for the geofence and they said: geo-fencing does not require persistent background location tracking.
This answer is a bit weird. Anyone has some ideas or has the same issue???

Thank you

Build on iOS failed

Hi, I've been trying to build my Cordova (+Ionic) project using this plugin on Android and iOS. Building and running on Android went smoothly, but failed on iOS. Here is what I've done so far:

  1. Add the plugin using cordova plugin add https://github.com/cowbell/cordova-plugin-geofence
  2. Add iOS platform ionic platform add ios
  3. Run on iOS simulator
ionic emulate ios

The error occured:

    Check dependencies
    Swift is unavailable on iOS earlier than 7.0; please set IPHONEOS_DEPLOYMENT_TARGET to 7.0 or later (currently it is '6.0').

    ** BUILD FAILED **


    The following build commands failed:
        Check dependencies
    (1 failure)
    Error: /Users/rasita.sa/Documents/myPhonegap/myProject/platforms/ios/cordova/run: Command failed with exit code 65
        at ChildProcess.whenDone (/usr/local/lib/node_modules/cordova/node_modules/cordova-lib/src/cordova/superspawn.js:135:23)
        at ChildProcess.emit (events.js:98:17)
        at maybeClose (child_process.js:756:16)
        at Process.ChildProcess._handle.onexit (child_process.js:823:5)
  1. Open the Xcode project in platforms/ios and change the project's and target's iOS Deployment Target from 6.0 to 7.0. After hitting Run button I found another error:
    screen shot 2015-01-28 at 12 09 33 pm

I also try adding and building iOS platform in the sample application, got the same result.

Cordova version: 3.6.3-0.2.13
Ionic version: 1.0.0-beta.13

Did I do something wrong?

Can't build project after adding plugin

I have this error when building my project:

UNEXPECTED TOP-LEVEL EXCEPTION:
com.android.dex.DexException: Multiple dex files define Landroid/support/v4/accessibilityservice/AccessibilityServiceInfoCompat$AccessibilityServiceInfoVersionImpl;
at com.android.dx.merge.DexMerger.readSortableTypes(DexMerger.java:596)
at com.android.dx.merge.DexMerger.getSortedTypes(DexMerger.java:554)
at com.android.dx.merge.DexMerger.mergeClassDefs(DexMerger.java:535)
at com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:171)
at com.android.dx.merge.DexMerger.merge(DexMerger.java:189)
at com.android.dx.command.dexer.Main.mergeLibraryDexBuffers(Main.java:454)
at com.android.dx.command.dexer.Main.runMonoDex(Main.java:303)
at com.android.dx.command.dexer.Main.run(Main.java:246)
at com.android.dx.command.dexer.Main.main(Main.java:215)
at com.android.dx.command.Main.main(Main.java:106)

This is my plugin list:

android.support.v4 21.0.1 "Android Support v4"
com.google.playservices 21.0.0 "Google Play Services for Android"
com.ionic.keyboard 1.0.4 "Keyboard"
com.phonegap.plugins.PushPlugin 2.4.0 "PushPlugin"
com.vladstirbu.cordova.promise 1.0.0 "Promise"
cordova-plugin-camera 1.1.0 "Camera"
cordova-plugin-crosswalk-webview 1.0.1-dev "Crosswalk WebView Engine"
cordova-plugin-file 2.0.0 "File"
cordova-plugin-file-transfer 1.1.0 "File Transfer"
cordova-plugin-geofence 0.4.0 "geofence"
cordova-plugin-geolocation 1.0.0 "Geolocation"
cordova-plugin-splashscreen 2.0.0 "Splashscreen"
cordova-plugin-whitelist 1.0.0 "Whitelist"
nl.x-services.plugins.socialsharing 4.3.19-dev "SocialSharing"
org.crosswalk.engine 0.0.1-dev "Crosswalk Engine"

I also use Ionic CLI for building.

Customize vibration pattern for notification

Should be possible to change vibration pattern for the notification. The best option will be a few predefined patterns and if it is possible setting custom pattern e.g. (1000 1000 1000) - vibrate 3 times each 1 sec long.

window.geofence is undefined

Hey,

I created a new ionic app and then added the cordova-plugin-geofence.
In my app.js inside my $ionicPlatform.ready(function() function I want to initialize geofence with
window.geofence.initialize();

But in my console it always says window.geofence is undefined. Can someone help me what I'm doing wrong. The plugin installation went without any errors.

Thanks

Execute code on enter/exit fence?

Is it possible to run some code when a user enters or exists a fence? For example I want to call a REST method which lets the server know what has happened. This can then be used for really cool things such as sending a push message to the user, etc etc.

For example:

window.geofence.addOrUpdate({
    id: "69ca1b88-6fbe-4e80-a4d4-ff4d3748acdb",
    latitude: 50.2980049,
    longitude: 18.6593152,
    radius: 3000,
    transitionType: TransitionType.ENTER,
    notification: {
        id: 1,
        title: "Welcome in Gliwice",
        text: "You just arrived to Gliwice city center.",
        openAppOnClick: true
    },
    action: function(id, transitionType) {
        // perform some code such as as calling a REST web service
    }
}).then(function() {
    console.log('Geofence successfully added');
}, function(reason) {
    console.log('Adding geofence failed', reason);
})

Android 'Webview is null' onTransitionReceived

Hi,

I'm having a problem on Android when a transition is received when the app is not already running in the background. If the app is running it's fine. The app process starts (Task Manager shows it has a 5MB footprint) but doesn't appear to load the CordovaWebView. Here's the log output:

D/GeofencePlugin(29512): ReceiveTransitionsIntentService - onHandleIntent
D/GeofencePlugin(29512): Geofence transition detected
D/GeofencePlugin(29512): Webview is null

I'm not sure if this is an issue with the plugin or the way I'm using it but I've tried fiddling with a number of things and haven't got any closer. It's working on iOS, so any tips on the Android side would be gratefully received.

Regards,
Tom

Geofence expiration option

Would be nice to have an option, which removes active geofences automatically by setting an expiration time (e.g. minutes or timestamp).

So far, I have to loop several times through active geofences.

How do you keep your geofences up to date and save as much ressources as possible?

Does not compile - vibration issues

    [javac] Compiling 21 source files to Z:\temp\myApp2\platforms\android\ant-bu
ild\classes
    [javac] Z:\temp\myApp2\platforms\android\src\com\cowbell\cordova\geofence\Ge
oNotificationNotifier.java:33: error: ')' expected
    [javac]                 .setContentText(notification.getText());
    [javac]                                                        ^
    [javac] Z:\temp\myApp2\platforms\android\src\com\cowbell\cordova\geofence\No
tification.java:67: error: ';' expected
    [javac]         return new long[] {0}, vibrate);
    [javac]                              ^
    [javac] Z:\temp\myApp2\platforms\android\src\com\cowbell\cordova\geofence\No
tification.java:67: error: not a statement
    [javac]         return new long[] {0}, vibrate);
    [javac]                                ^
    [javac] Z:\temp\myApp2\platforms\android\src\com\cowbell\cordova\geofence\No
tification.java:67: error: ';' expected
    [javac]         return new long[] {0}, vibrate);
    [javac]                                       ^
    [javac] 4 errors

Incorrect dependency IDs and Android permission declarations

In one of your recent commits of the plugin.xml file, you changed the ID of Android specific libraries to invalid IDs that do not exist in the plugin repository. Also, there is an issue with the declared uses-permission tags not being included in the compiled AndroidManifest.xml, resulting in the plugin not being able to use the Android location services as well as the "boot completed" broadcast.

iOS: Suggested app on iOS 8 lock screen

Thank you for your useful plugin. My goal is to display my app as a suggested app on the iOS 8 lock screen. Is it somehow possible to achieve this using your plugin? It should be possible with a geofence.

onNotificationClick event

It would be nice if there were an event or callback for when the app is opened through the notification. 'onNotificationClick' or something like that.

Custom icon for notification

Possibility to add custom icon for notification

Resource icon

notification: { icon: "res://ic_launcher" }

Loading local icon

notification: { icon: "file://img/image.png" }

Firing receiveTransition if the app is started within a fence

Hi,

I noticed that when I start my app inside a fence, the receiveTransition is not fired for that fence. I suppose there are some valid arguments for this behaviour, since there is no real transition happening. However, there are cases where it is desirable to notify the app when it is inside a fence on startup.

For iOS, I found this thread. I'm proposing the approach where a check on initialization is implemented. We could provide an argument to the initialize method to toggle this behaviour. Let me know what you think.

Since I am only testing on iOS for now, I am not really aware of the behaviour on Android. I came accross the GEOFENCE_TRANSITION_DWELL transition type, but I am not entirely sure if that is what we are looking for. Anyone who knows more about this for Android or who is willing to test?

Please share your thoughts on this.

Android: run at startup

greetings,

for Android, if geofences are registered with the OS then why do you need the permission "run at startup"?

Make notification optional

Hi,

I'd like to know if it'd be possible to not display a notification on received transitions.
If I don't pass a notification object to the geofence, it breaks on this line on iOS (I guess it does the same on other devices).
I'd like to ping a route when a transition occur, without the user being notified.

Also, is the callback executed when the app is closed/killed ?

Thanks in advance

Background geo-location

hi,

Firstly thanks a ton for this useful plugin. I think I can put this to good use in one of the Apps. But me being new to Android / Java, have this quick question. I may also be needing to do a background geolocation update. So I was thinking that instead of having another service or plugin do a background geolocation update, can I use this plugin to update a remote server with it's location co-ordinates? If yes where exactly do you think I should fit in the code to post the latitude / longitude data.

And also does this run as as service? I mean even after a reboot will it start up automatically?

Thanks a ton,
M&M

Crashes on consecutive geofence transitions on Android

After entering and exiting geofences for several times consecutively (around 10+ times), my app crashes with the following error:

08-13 11:36:21.507: E/AndroidRuntime(6849): FATAL EXCEPTION: IntentService[ReceiveTransitionsIntentService]
08-13 11:36:21.507: E/AndroidRuntime(6849): Process: com.myapp.geofenceapp, PID: 6849
08-13 11:36:21.507: E/AndroidRuntime(6849): java.lang.RuntimeException: Init failed
08-13 11:36:21.507: E/AndroidRuntime(6849):     at android.media.ToneGenerator.native_setup(Native Method)
08-13 11:36:21.507: E/AndroidRuntime(6849):     at android.media.ToneGenerator.<init>(ToneGenerator.java:746)
08-13 11:36:21.507: E/AndroidRuntime(6849):     at com.cowbell.cordova.geofence.BeepHelper.<init>(BeepHelper.java:10)
08-13 11:36:21.507: E/AndroidRuntime(6849):     at com.cowbell.cordova.geofence.GeoNotificationNotifier.<init>(GeoNotificationNotifier.java:23)
08-13 11:36:21.507: E/AndroidRuntime(6849):     at com.cowbell.cordova.geofence.ReceiveTransitionsIntentService.onHandleIntent(ReceiveTransitionsIntentService.java:56)
08-13 11:36:21.507: E/AndroidRuntime(6849):     at android.app.IntentService$ServiceHandler.handleMessage(IntentService.java:65)
08-13 11:36:21.507: E/AndroidRuntime(6849):     at android.os.Handler.dispatchMessage(Handler.java:102)
08-13 11:36:21.507: E/AndroidRuntime(6849):     at android.os.Looper.loop(Looper.java:135)
08-13 11:36:21.507: E/AndroidRuntime(6849):     at android.os.HandlerThread.run(HandlerThread.java:61)

I tested this with Nexus 5 running Lockito app (location simulation app) which simulated driving along a street with 8 geofences on the side. I set transition type to both enter and exit. The first trip went smooth, but when I run the simulation again the app crashed in the background.

The issue is likely to be related to ToneGenerator being used repeatedly in the app without releasing media player resources.

Problem on android 5.0

Running on android 5.0 the function initialize unresponsive success or error and consequently does not work for me.
What could be wrong?
A small and simple part of my code:

function onDeviceReady(){
window.geofence.receiveTransition = function (geofences) {
geofences.forEach(function (geo) {
console.log('Geofence transition detected', geo);
$(document).find('.status').html('Geofence transition detected');
alert('Geofence transition detected' + geo.id);
});
};

try {
    window.geofence.initialize(onSucessInit, onErrorInit);
}
catch(err) {
    alert('Erro try ---' + err.message);
}
startAPP();

}

function onSucessInit(){
alert('OK init');
}

function onErrorInit(){
alert('Error init');
}

Cordova build on iOS fails

Hi,

Perhaps somewhat related to this issue, since I have to configure the IPHONEOS_DEPLOYMENT_TARGET manually (cordova version 4.2.0).

Anyway, after I manually set the parameter, the build is still failing. My impression is that some dependencies are missing for SQLITE. I did not install anything else than this plugin, but if I understood the documentation correctly it should work out of the box.

screen shot 2015-03-03 at 11 16 44

What am I missing? If some dependencies are needed, could this be added to the documentation?
Perhaps this should be set up as part of the hooked script, which is not executed correctly. How can I fix that?

Thanks

Improve accuracy and response time of geofencing

Great library man. However, relying in pure android geofencing seems inaccurate for radius less than 1000m (http://stackoverflow.com/questions/23708655/how-to-make-geo-fencing-alert-more-accurate-in-android).

In order to improve the accuracy and response time, I think the plugin can benefit from using hardware GPS reading as suggested on stackoverflow discussion above. I tested by creating other app - which is just an app containing a button to read GPS position. Before I pushed the button on this other app, the notification when I exit a geofence is not displayed. But after I activated the button and got reading, the plugin works and send notification.

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.