locked
Geofence Plugin for Xamarin Released RRS feed

  • Question

  • User24682 posted

    Hi guys

    Just released a plugin that supports geofence monitoring for iOS and Android Platform. Windows support coming soon. Try it and let me know if helps any one. Also have a list of TODOs if anyone would like to collaborate in this project that would be awesome!

    Geofence NuGet PCL

    Geofence Plugin Github repository

    Thanks.

    Friday, April 10, 2015 4:50 PM

All replies

  • User2148 posted

    @RendyDelRosario well done, good work.

    Friday, April 10, 2015 7:24 PM
  • User24682 posted

    Thanks @AlessandroCaliaro. Tested it already?

    I will upload a sample app maybe tomorrow. To be easier to see how it works.

    Friday, April 10, 2015 7:33 PM
  • Wednesday, April 15, 2015 1:56 PM
  • Wednesday, April 15, 2015 3:28 PM
  • User76199 posted

    Hi,

    I have to fire local notification from based on geofencing result . It worked when app in online and bagrounded but it is not working when the app is offline. Please advice is it possible using this Nugget ? Please share some samples incase it is possible.

    Regards Mohanlal

    Tuesday, July 14, 2015 9:32 AM
  • User24682 posted

    Geofence NuGet PCL : https://www.nuget.org/packages/Xam.Plugin.Geofence/

    Sample here: https://github.com/domaven/xamarin-plugins/tree/master/Samples/Geofence

    Wednesday, July 15, 2015 2:18 AM
  • User123425 posted

    @RendyDelRosario is there any method on your plugin to get the current location? I need to get the current location of the device before starting with the monitoring, can this current location be retrieved with your plugin?

    Friday, July 24, 2015 5:39 PM
  • User24682 posted

    There's a property you can use:

    GeofenceLocation LastKnownLocation { get; }

    CrossGeofence.Current.LastKnownLocation;

    Friday, July 24, 2015 8:56 PM
  • User37316 posted

    @RendyDelRosario Hello again. I'm having issues with the plugin I start monitoring a region I get the OnMonitoringStarted event and OnError is not fired so I assumed is monitoring. However I never get OnRegionStateChanged event Any ideas?

    Wednesday, August 19, 2015 4:18 PM
  • User37316 posted

    Ok the OnStay is the only event that is not firing now.

    Wednesday, August 19, 2015 6:52 PM
  • User24682 posted

    @AlejandroForonda did you set NotifyOnStay to true? When started monitoring the region?

    Thursday, August 20, 2015 11:32 AM
  • User37316 posted

    @RendyDelRosario Yes. Is set to true

    Thursday, August 20, 2015 11:38 AM
  • User24682 posted

    Are you testing on Android or iOS?

    Friday, August 21, 2015 2:54 PM
  • User75759 posted

    Hello @RendyDelRosario ! Thanks for this nice plugin! I'm having an issue on iOS devices though.

    In my AppDelegate I call: CrossGeofence.Initialize<GeofenceListener>();

    Then, in the OnStart override of my Forms application, I call: ``` var region = new GeofenceCircularRegion("Region name", lat, long, range) { NotifyOnEntry = true, NotifyOnExit = true };

    var crossGeofenceInstance = CrossGeofence.Current; crossGeofenceInstance.StartMonitoring(region); ```

    On Android and an iOS 9.1 simulator, this works flawlessly, and I get notified when entering or leaving my region On a real iOS 9.1 device though, I get an exception while fetching CrossGeofence.Current: ``` Unhandled Exception:

    System.InvalidCastException: Specified cast is not valid.

    2015-12-09 14:14:47.720 BeaconsPrototypeiOS[2189:1301181] Unhandled Exception: System.InvalidCastException: Specified cast is not valid. at Geofence.Plugin.GeofenceImplementation..ctor () [0x001a7] in :0 at Geofence.Plugin.CrossGeofence.CreateGeofence () [0x00000] in :0 at Geofence.Plugin.CrossGeofence.<.cctor>b__0 () [0x00000] in :0 at System.Lazy1[T].CreateValue () <0x1000b7c00 + 0x0017b> in <filename unknown>:0 2015-12-09 14:14:47.721 BeaconsPrototypeiOS[2189:1301181] Unhandled managed exception: Specified cast is not valid. (System.InvalidCastException) at Geofence.Plugin.GeofenceImplementation..ctor () [0x001a7] in <filename unknown>:0 at Geofence.Plugin.CrossGeofence.CreateGeofence () [0x00000] in <filename unknown>:0 at Geofence.Plugin.CrossGeofence.<.cctor>b__0 () [0x00000] in <filename unknown>:0 at System.Lazy1[T].CreateValue () <0x1000b7c00 + 0x0017b> in :0 2015-12-09 14:14:47.722 BeaconsPrototypeiOS[2189:1301181] critical: Stacktrace:

    2015-12-09 14:14:47.722 BeaconsPrototypeiOS[2189:1301181] critical: Native stacktrace: 2015-12-09 14:14:47.966 BeaconsPrototypeiOS[2189:1301181] critical: 0 BeaconsPrototypeiOS 0x00000001012865e8 monohandlenativesigsegv + 260 2015-12-09 14:14:47.966 BeaconsPrototypeiOS[2189:1301181] critical: 1 libsystemplatform.dylib 0x000000019897d94c sigtramp + 68 2015-12-09 14:14:47.966 BeaconsPrototypeiOS[2189:1301181] critical: 2 libsystempthread.dylib 0x0000000198984ef8 pthreadkill + 112 2015-12-09 14:14:47.966 BeaconsPrototypeiOS[2189:1301181] critical: 3 libsystemc.dylib 0x000000019882eb78 abort + 140 2015-12-09 14:14:47.966 BeaconsPrototypeiOS[2189:1301181] critical: 4 BeaconsPrototypeiOS 0x0000000101353104 ZL15printexceptionP10MonoObjectbP15NSMutableString + 0 2015-12-09 14:14:47.966 BeaconsPrototypeiOS[2189:1301181] critical: 5 BeaconsPrototypeiOS 0x0000000101286cb4 monoinvokeunhandledexceptionhook + 96 2015-12-09 14:14:47.966 BeaconsPrototypeiOS[2189:1301181] critical: 6 BeaconsPrototypeiOS 0x00000001012863fc monohandleexceptioninternal + 4228 2015-12-09 14:14:47.966 BeaconsPrototypeiOS[2189:1301181] critical: 7
    BeaconsPrototypeiOS 0x000000010128536c mono
    handleexception + 40 2015-12-09 14:14:47.966 BeaconsPrototypeiOS[2189:1301181] critical: 8 BeaconsPrototypeiOS 0x000000010127f30c monoarmthrowexception + 200 2015-12-09 14:14:47.966 BeaconsPrototypeiOS[2189:1301181] critical: 9 BeaconsPrototypeiOS 0x0000000100329188 rethrowexception + 168 2015-12-09 14:14:47.967 BeaconsPrototypeiOS[2189:1301181] critical: 10 BeaconsPrototypeiOS 0x00000001000b7e14 SystemLazy1TREFCreateValue + 532 2015-12-09 14:14:47.967 BeaconsPrototypeiOS[2189:1301181] critical: 11 BeaconsPrototypeiOS 0x00000001000b7918 SystemLazy1TREFLazyInitValue + 104 2015-12-09 14:14:47.967 BeaconsPrototypeiOS[2189:1301181] critical: 12 BeaconsPrototypeiOS 0x00000001000b7890 SystemLazy1TREFgetValue + 208 2015-12-09 14:14:47.967 BeaconsPrototypeiOS[2189:1301181] critical: 13 BeaconsPrototypeiOS 0x0000000100f61cb8 Geofe ncePluginCrossGeofencegetCurrent + 216 2015-12-09 14:14:47.967 BeaconsPrototypeiOS[2189:1301181] critical: 14 BeaconsPrototypeiOS 0x0000000100ec3c44 BeaconsPrototypeAppStartGeofenceTest + 436 2015-12-09 14:14:47.967 BeaconsPrototypeiOS[2189:1301181] critical: 15 BeaconsPrototypeiOS 0x0000000100ec3a50 BeaconsPrototypeAppOnStart + 144 2015-12-09 14:14:47.967 BeaconsPrototypeiOS[2189:1301181] critical: 16 BeaconsPrototypeiOS 0x0000000100a35c18 XamarinFormsApplicationSendStart + 104 2015-12-09 14:14:47.967 BeaconsPrototypeiOS[2189:1301181] critical: 17 BeaconsPrototypeiOS 0x000000010091dea0 XamarinFormsPlatformiOSFormsApplicationDelegateFinishedLaunchingUIKitUIApplicationFoundationNSDictionary + 448 2015-12-09 14:14:47.967 BeaconsPrototypeiOS[2189:1301181] critical: 18 BeaconsPrototypeiOS 0x0000000100094aec BeaconsPrototypeiOSAppDelegateFinishedLaunchingUIKitUIApplicationFoundationNSDictionary + 60 4 2015-12-09 14:14:47.967 BeaconsPrototypeiOS[2189:1301181] critical: 19 BeaconsPrototypeiOS 0x00000001002f6bc4 wrapperruntimeinvokeobjectruntimeinvokedynamicintptrintptrintptrintptr + 244 2015-12-09 14:14:47.968 BeaconsPrototypeiOS[2189:1301181] critical: 20 BeaconsPrototypeiOS 0x0000000101290810 monojitruntimeinvoke + 1280 2015-12-09 14:14:47.968 BeaconsPrototypeiOS[2189:1301181] critical: 21 BeaconsPrototypeiOS 0x00000001012e5474 monoruntimeinvoke + 124 2015-12-09 14:14:47.968 BeaconsPrototypeiOS[2189:1301181] critical: 22 BeaconsPrototypeiOS 0x0000000101243438 _ZL30nativetomanagedtrampoline4P11objcobjectP13objcselectorPP11MonoMethodS0S0PKcS7S7S7_ + 640 2015-12-09 14:14:47.969 BeaconsPrototypeiOS[2189:1301181] critical: 23 BeaconsPrototypeiOS 0x0000000101243944 -[AppDelegate application:didFinishLaunchingWithOptions:] + 96 2015-12-09 14:14:47.969 BeaconsPrototypeiOS[2189:1301181] critical: 2 4 UIKit 0x0000000188711324 + 400 2015-12-09 14:14:47.969 BeaconsPrototypeiOS[2189:1301181] critical: 25 UIKit 0x000000018893facc + 2904 2015-12-09 14:14:47.969 BeaconsPrototypeiOS[2189:1301181] critical: 26 UIKit 0x0000000188943e0c + 1656 2015-12-09 14:14:47.969 BeaconsPrototypeiOS[2189:1301181] critical: 27 UIKit 0x0000000188940f50 + 168 2015-12-09 14:14:47.969 BeaconsPrototypeiOS[2189:1301181] critical: 28 FrontBoardServices 0x000000018cd7f7c4 + 184 2015-12-09 14:14:47.970 BeaconsPrototypeiOS[2189:1301181] critical: 29 FrontBoardServices 0x000000018cd7fb44 + 56 2015-12-09 14:14:47.970 BeaconsPrototypeiOS[2189:1301181] critical: 30 CoreFoundation 0x00000001830c0544 + 24 2015-12-09 14:14:47.970 BeaconsPrototypeiOS[2189:1301181] critical: 31 CoreFo undation 0x00000001830bffd8 + 540 2015-12-09 14:14:47.970 BeaconsPrototypeiOS[2189:1301181] critical: 32 CoreFoundation 0x00000001830bdcd8 + 724 2015-12-09 14:14:47.970 BeaconsPrototypeiOS[2189:1301181] critical: 33 CoreFoundation 0x0000000182fecca0 CFRunLoopRunSpecific + 384 2015-12-09 14:14:47.970 BeaconsPrototypeiOS[2189:1301181] critical: 34 UIKit 0x000000018870a1c8 + 460 2015-12-09 14:14:47.970 BeaconsPrototypeiOS[2189:1301181] critical: 35 UIKit 0x0000000188704ffc UIApplicationMain + 204 2015-12-09 14:14:47.970 BeaconsPrototypeiOS[2189:1301181] critical: 36 BeaconsPrototypeiOS 0x00000001008e3e54 wrappermanagedtonativeUIKitUIApplicationUIApplicationMainintstring_intptrintptr + 324 2015-12-09 14:14:47.970 BeaconsPrototypeiOS[2189:1301181] critical: 37 BeaconsPrototypeiOS 0x000000010085d64c UIKitUI ```

    Do you have any idea how I could fix this?

    Best regards,

    David

    Wednesday, December 9, 2015 1:19 PM
  • User24682 posted

    Hi

    @DavidCatteuw Are you still having the issue?

    Do you have a sample repo that reproduce this situation to test?

    Thursday, December 10, 2015 4:54 PM
  • User75759 posted

    @RendyDelRosario said: Hi

    @DavidCatteuw Are you still having the issue?

    Do you have a sample repo that reproduce this situation to test?

    Hello Rendy,

    The iOS version of my prototype has been put on hold for the moment, so I can't really dedicate any time to it right now. I'll get back to you when this gets started up again.

    Thanks again for the nice library!

    Best regards,

    David

    Monday, December 14, 2015 11:10 AM
  • User93714 posted

    I've tested this out with iOS (will be testing android in the near future), it works very well for me. Nice job OP!

    Friday, January 15, 2016 6:54 PM
  • User106601 posted

    Hi, Just added the plug in to my app - Xamain.Android. I get this exception when trying to add geofence:

               var gf = new GeofenceCircularRegion(geofenceData.Title, geofenceData.Latitude, geofenceData.Longitude, geofenceData.Radius);
    
                CrossGeofence.Current.StartMonitoring(gf);
    

    System.TypeLoadException: Could not load type 'Android.Gms.Common.GoogleApiAvailability' from assembly 'Xamarin.GooglePlayServices.Basement, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'. 01-29 09:32:18.249 I/mono-stdout(27865): System.TypeLoadException: Could not load type 'Android.Gms.Common.GoogleApiAvailability' from assembly 'Xamarin.GooglePlayServices.Basement, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'. 01-29 09:32:18.250 I/mono-stdout(27865): at Geofence.Plugin.GeofenceImplementation.IsLocationEnabled (System.Action1 returnAction) [0x0000d] in C:\Users\rendy\Maven\xamarin-plugins\Geofence\Geofence\Geofence.Plugin.Android\GeofenceImplementation.cs:133 at Geofence.Plugin.GeofenceImplementation.IsLocationEnabled (System.Action1 returnAction) [0x0000d] in C:\Users\rendy\Maven\xamarin-plugins\Geofence\Geofence\Geofence.Plugin.Android\GeofenceImplementation.cs:133 at Geofence.Plugin.GeofenceImplementation..ctor () [0x00021] in C:\Users\rendy\Maven\xamarin-plugins\Geofence\Geofence\Geofence.Plugin.Android\GeofenceImplementation.cs:112 01-29 09:32:18.250 I/mono-stdout(27865): at Geofence.Plugin.GeofenceImplementation..ctor () [0x00021] in C:\Users\rendy\Maven\xamarin-plugins\Geofence\Geofence\Geofence.Plugin.Android\GeofenceImplementation.cs:112 01-29 09:32:18.250 I/mono-stdout(27865): at Geofence.Plugin.CrossGeofence.CreateGeofence () [0x00000] in C:\Users\rendy\Maven\xamarin-plugins\Geofence\Geofence\Geofence.Plugin\CrossGeofence.cs:128 01-29 09:32:18.251 I/mono-stdout(27865): at Geofence.Plugin.CrossGeofence+<>c.<.cctor>b__55_0 () [0x00000] in C:\Users\rendy\Maven\xamarin-plugins\Geofence\Geofence\Geofence.Plugin\CrossGeofence.cs:14 at Geofence.Plugin.CrossGeofence.CreateGeofence () [0x00000] in C:\Users\rendy\Maven\xamarin-plugins\Geofence\Geofence\Geofence.Plugin\CrossGeofence.cs:128 at Geofence.Plugin.CrossGeofence+<>c.<.cctor>b__55_0 () [0x00000] in C:\Users\rendy\Maven\xamarin-plugins\Geofence\Geofence\Geofence.Plugin\CrossGeofence.cs:14

    My package config:

    <package id="Xam.Plugin.Geofence" version="1.0.9" targetFramework="monoandroid44" developmentDependency="true" /> <package id="Xamarin.Android.Support.v4" version="23.1.1.0" targetFramework="monoandroid44" /> <package id="Xamarin.Android.Support.v7.AppCompat" version="22.2.0.0" targetFramework="monoandroid44" /> <package id="Xamarin.Android.Support.v7.CardView" version="22.1.1.1" targetFramework="monoandroid44" /> <package id="Xamarin.GooglePlayServices.Auth" version="29.0.0-beta1" targetFramework="monoandroid44" /> <package id="Xamarin.GooglePlayServices.Base" version="29.0.0-beta1" targetFramework="monoandroid44" /> <package id="Xamarin.GooglePlayServices.Basement" version="29.0.0-beta1" targetFramework="monoandroid44" /> <package id="Xamarin.GooglePlayServices.Gcm" version="29.0.0-beta1" targetFramework="monoandroid44" /> <package id="Xamarin.GooglePlayServices.Location" version="29.0.0-beta1" targetFramework="monoandroid44" /> <package id="Xamarin.GooglePlayServices.Maps" version="29.0.0-beta1" targetFramework="monoandroid44" /> <package id="Xamarin.GooglePlayServices.Measurement" version="29.0.0-beta1" targetFramework="monoandroid44" /> <package id="Xamarin.GooglePlayServices.Plus" version="29.0.0-beta1" targetFramework="monoandroid44" />

    Friday, January 29, 2016 9:39 AM
  • User106601 posted

    Packages issue as it turns out I'm using 29.0.0-beta1 and plugin uses 27.0.0.0 currently. Downgraded to 27 and all worked fine.

    Friday, January 29, 2016 1:41 PM
  • User24682 posted

    Right @MilenPavlov.0879 We are not supporting 29 beta yet, just stable versions

    Friday, January 29, 2016 3:08 PM
  • User106601 posted

    @RendyDelRosario btw works just fine with 29 beta too :)

    Sunday, January 31, 2016 5:36 PM
  • User157736 posted

    Hi @RendyDelRosario, thanks for doing this!

    Does this Nuget also support updates even when the app is terminated? As in a background service that will get notified when there is a Geofence change?

    Wednesday, February 3, 2016 5:35 AM
  • User24682 posted

    @SpencerSmith yes

    Friday, February 5, 2016 7:15 PM
  • User197589 posted

    Hi, i cannot make geofence work when app is closed. i have created service and started but i don't receive notification for geofence :(

    Sunday, February 21, 2016 10:46 AM
  • User201534 posted

    Hi @RendyDelRosario, thanks for your plugin.

    I encounter one problem when using the latest version. That is the Exit event will be invoked twice. It means that Enter the region occur one time, however the Exited the region occur 2 times. I have try the sample which use the 1.0.4 without this problem. However I update the plugin to 1.1.1, the problem occurred again in the Sample. I think it is a bug maybe.

    Test Case: Using iOS Emulator

    Set the location as the custom location:
    
    La: 51.625742
    Lo: -0.7424
    
    Open the Sample App
    
    Add the fence at current location and radius is 10 
    
    Then choose the City Run in the Location emulator.
    
    There will be two notifications for Exited geofence region.
    
    Monday, April 25, 2016 3:51 PM
  • User201534 posted

    @RendyDelRosario

    Could I ask one question for this Plugin?

    I have tried the sample code, it worked and I found even I close the app (swipe it out after double click home button),it still can monitor the region change.

    However, I want to implement this function too. I have try it in my code, I found except I put the StartMonitoring in the OnAppStart function, the monitor can not valid after I close the app. I compare the code with the sample, and I cannot find any different except the sample code use Xamarin.FormMaps. Is this the reason why the sample code can run even the app close?

    If not Could you give me some suggestion how to enable the region monitor running background after the app close?

    Wednesday, April 27, 2016 12:38 PM
  • User201534 posted

    @xinmeng said: @RendyDelRosario

    Could I ask one question for this Plugin?

    I have tried the sample code, it worked and I found even I close the app (swipe it out after double click home button),it still can monitor the region change.

    However, I want to implement this function too. I have try it in my code, I found except I put the StartMonitoring in the OnAppStart function, the monitor can not valid after I close the app. I compare the code with the sample, and I cannot find any different except the sample code use Xamarin.FormMaps. Is this the reason why the sample code can run even the app close?

    If not Could you give me some suggestion how to enable the region monitor running background after the app close?

    @xinmeng said: @RendyDelRosario

    Could I ask one question for this Plugin?

    I have tried the sample code, it worked and I found even I close the app (swipe it out after double click home button),it still can monitor the region change.

    However, I want to implement this function too. I have try it in my code, I found except I put the StartMonitoring in the OnAppStart function, the monitor can not valid after I close the app. I compare the code with the sample, and I cannot find any different except the sample code use Xamarin.FormMaps. Is this the reason why the sample code can run even the app close?

    If not Could you give me some suggestion how to enable the region monitor running background after the app close?

    Quick update this problem:

    I just add a single debug line in the AppDelegate.cs, the background task monitor worked! Strange

    [Register ("AppDelegate")]
        public partial class AppDelegate : global::Xamarin.Forms.Platform.iOS.FormsApplicationDelegate
        {
            public override bool FinishedLaunching (UIApplication app, NSDictionary options)
            {
                global::Xamarin.Forms.Forms.Init ();
    
                CrossGeofence.Initialize<CrossGeofenceListener> ();
    //          Console.WriteLine ("===============================");
                Console.WriteLine ("IS MONITOR? " + CrossGeofence.Current.IsMonitoring.ToString ());
    //          Console.WriteLine ("Region Sum? " + CrossGeofence.Current.Regions.Count.ToString());
                CrossGeofence.GeofenceListener.OnAppStarted();
                LoadApplication (new App ());
    //          CrossGeofence.GeofenceListener.OnAppStarted();
                return base.FinishedLaunching (app, options);
            }
        }
    
    Wednesday, April 27, 2016 3:21 PM
  • User201534 posted

    Update the problem and solution when I use this plugin

    1. version problem

    the sample code is based on 1.0.4, as far as I know that I encountered twice exited notification issue by version 1.1.1. So I choose the 1.0.4.

    1. the Google play service.

    The old version is based on deprecated Google play service, ( I think 1.0.6 update it to new package which include 4 packages). so care about the package reference.

    <package id="Xamarin.GooglePlayServices" version="22.0.0.2" targetFramework="MonoAndroid50" />
    
    Thursday, April 28, 2016 10:31 AM
  • User15654 posted

    After last update Xamarin Forms 2.2.0.31 that finally fixed the Xamarin.Android.Support update issue, I'm now getting an error from this plugin I have no idea how to fix.

    Error: Error executing task LinkAssemblies: error XA2006: Reference to metadata item 'Android.Gms.Common.GoogleApiAvailability Android.Gms.Common.GoogleApiAvailability::get_Instance()' (defined in 'Geofence.Plugin, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null') from 'Geofence.Plugin, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' could not be resolved.

    Any help is appreciated.

    Sunday, May 1, 2016 4:11 AM
  • User15654 posted

    Figured it out, I removed all the GooglePlayServices and Xam.Plugin.Geofence then re-installed Geofence and let it get the dependancies. A few of the GooglePlayServices were .1 version too high.

    Monday, May 2, 2016 10:10 PM
  • User157751 posted

    I'm getting the same error for RELEASE and PRODUCTION builds:

    Error: Error executing task LinkAssemblies: error XA2006: Reference to metadata item 'Android.Gms.Common.GoogleApiAvailability Android.Gms.Common.GoogleApiAvailability::get_Instance()' (defined in 'Geofence.Plugin, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null') from 'Geofence.Plugin, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' could not be resolved.

    Tried removing the Google play services packages and geofence, and re-adding geofence nuget package. But still seeing the error.

    Any ideas?

    thanks, Dennis

    Saturday, May 21, 2016 12:08 AM
  • User64909 posted

    @RendyDelRosario I am not getting any error.

    Able to test successfully in IOS, but in android not getting notified on any event event though tried with highest accuracy.

    I have conducted test using AVD & actual device also.

    Can you suggest on this, am I missing anything?

    Tuesday, May 24, 2016 2:07 AM
  • User99715 posted

    I having the same problem as @Dennis.Stringify

    /Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.targets: Error: Error executing task LinkAssemblies: error XA2006: Reference to metadata item 'Android.Gms.Common.GoogleApiAvailability Android.Gms.Common.GoogleApiAvailability::get_Instance()' (defined in 'Geofence.Plugin, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null') from 'Geofence.Plugin, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' could not be resolved.

    I was only able to deploy a release version only with "Don't Link Assemblies" in the Linker settings. But the package gets too big.

    Any suggestion @RendyDelRosario ?

    Monday, June 6, 2016 10:34 PM
  • User226521 posted

    Hi , How can I Add routes and traffic to this sample? I tested the sample and it surprises me that it does not crash with the data/4G turned off. that's very good and stable.

    Thursday, June 9, 2016 4:58 PM
  • User39613 posted

    Thanks for your awesome plugin, great job and it definitely is a time saver!

    Unfortunately, the current Xamarin.Forms.Maps references Play Services 29.0.0.1, which mismatches with the version referenced by the Geofence plugin (which is 27.0.0.0...). That creates problems as reported by @jzeferino or, in my case, something like:

    System.TypeLoadException: Could not load type 'Android.Gms.Common.GoogleApiAvailability' from assembly 'Xamarin.GooglePlayServices.Basement, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'.

    You might want to upgrade the plugin to 29.0.0.1 to fix this... :)

    Friday, June 17, 2016 2:30 PM
  • User99715 posted

    @CyrilCathala how did you managed to bypass that error? downgrading to 27.0.0.0? I donwgrade it but still the same error.

    Saturday, June 18, 2016 6:56 PM
  • User39613 posted

    I've downloaded the source code, changed the reference to the Play Services (to target 29.0.0.1), got the dll and referenced then directly. Just make sure you clean you bin + obj folders before you build your project, otherwise it works perfectly!

    Sunday, June 19, 2016 10:23 AM
  • User101259 posted

    Why would this be necessary, or even address the issue? The plugin requires 27.0.0.0 or greater .

    Monday, June 20, 2016 12:05 AM
  • User99715 posted

    It requires 27.0.0.0 but won't work if you update to 29.0.0.0. @CyrilCathala i don't want to have to reference the .dll. Its kinda bad because if they update the library i will need to refactor the dependency. I will try to make a PR for the repository.

    Monday, June 20, 2016 9:05 AM
  • User39613 posted

    Yes I know, I don't like it either but I couldn't wait, I have to ship my app pretty soon :/ I hope it'll be temporary (thanks to your PR maybe :smile: ).

    Monday, June 20, 2016 11:29 AM
  • User103165 posted

    Too late ;)

    https://github.com/domaven/xamarin-plugins/pull/15

    Saturday, July 2, 2016 2:04 PM
  • User239903 posted

    I am still having this error even after I updated the packages to the latest version:

    Error executing task LinkAssemblies: error XA2006: Reference to metadata item 'Android.Gms.Common.GoogleApiAvailability Android.Gms.Common.GoogleApiAvailability::get_Instance()' (defined in 'Geofence.Plugin, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null') from 'Geofence.Plugin, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' could not be resolved

    Wednesday, July 6, 2016 4:17 PM
  • User239903 posted

    @CyrilCathala Can you please tell how you fixed the problem in details (like step by step) if you can. It would be very helpful. I am new to android/Xamarin.

    Wednesday, July 6, 2016 5:01 PM
  • User39613 posted

    Well the pull request from Gerald has been merged so you can retrieve the source code from the master branch, build it and reference the dll directly within your project. It should work that way...

    Wednesday, July 6, 2016 9:03 PM
  • User239903 posted

    @CyrilCathala

    Thank You for replying. What do you mean by referencing the dll directly in my project. Do you mean copy the dll files to my project. (If yes, what folders do I copy it to?). And what dll files should I reference? Just the one with "Geofence.Plugin.dll"?

    Thanks in Advance.

    Wednesday, July 6, 2016 11:06 PM
  • User39613 posted

    You can put the dlls within an "Assemblies" folder in your solution, or whatever you like. Then you can mimic the same folder hierarchy as the NuGet one, putting the dlls you have built in the same place. Then you reference the dll you need per project, just note what NuGet do and try to do the same.

    Or you can wait a bit, the pull request was merged so it should be a matter of days before the new version is pushed to NuGet.

    Thursday, July 7, 2016 8:37 AM
  • User24682 posted

    Package is updated now

    Thursday, July 7, 2016 5:44 PM
  • User239903 posted

    Thankyou @RendyDelRosario, @CyrilCathala

    Sunday, July 10, 2016 4:49 AM
  • User243004 posted

    Hi, The plugin doesn't work on IOS (9.3) I'm having the same issue where CrossGeofence.Current is throwing System.InvalidCastException: Specified cast is not valid. It seems this plugin doesn't work on IOS. You can reproduce it by doing the following: 1. In Visual studio, create a new PCL and a new blank IOS app 2. Add the Geofence plugin from nuget to both projects 3. Create an implementation of IGeofenceListener in the library and reference the library in the IOS project 4. Initialize the listener as said in the doc in the App delegate: CrossGeofence.Initialize(); At this point try to access CrossGeofence.Current. You'll get the same exception. It's such a basic scenario, has no one else seen this?

    @RendyDelRosario said: Hi

    @DavidCatteuw Are you still having the issue?

    Do you have a sample repo that reproduce this situation to test?

    Tuesday, July 19, 2016 12:38 AM
  • User243004 posted

    Actually I found the problem: locationManager.MonitoredRegions includes all CLCircularRegion and CLBeaconRegions which are monitored. If you're monitoring beacons within the app, they will be in the MonitoredRegions collection. Since this component only focusses on geolocations, it makes sense to cast as follows:

    NSSet monitoredRegions = locationManager.MonitoredRegions;

                foreach (var mRegion in monitoredRegions)
                {
                    var region = mRegion as CLCircularRegion;
                    if (region == null)
                    {
                        continue; 
                    }
                    //If not on regions remove on startup since that region was set not persistent
                    if (!Regions.ContainsKey(region.Identifier))
                    {
                        locationManager.StopMonitoring(region);
                    }
                    else
                    {
                        locationManager.RequestState(region);
                    }
    
                }
    

    This occurs in the constructor as well as LocationsUpdated().
    Hopefully this change can go in for the next update.

    @kwackmaster said: Hi, The plugin doesn't work on IOS (9.3) I'm having the same issue where CrossGeofence.Current is throwing System.InvalidCastException: Specified cast is not valid. It seems this plugin doesn't work on IOS. You can reproduce it by doing the following: 1. In Visual studio, create a new PCL and a new blank IOS app 2. Add the Geofence plugin from nuget to both projects 3. Create an implementation of IGeofenceListener in the library and reference the library in the IOS project 4. Initialize the listener as said in the doc in the App delegate: CrossGeofence.Initialize(); At this point try to access CrossGeofence.Current. You'll get the same exception. It's such a basic scenario, has no one else seen this?

    @RendyDelRosario said: Hi

    @DavidCatteuw Are you still having the issue?

    Do you have a sample repo that reproduce this situation to test?

    Tuesday, July 19, 2016 2:11 AM
  • User157751 posted

    Hi, thanks very much for the plugin and the fixes.

    I have a question related to the CrossGeofence.Initialize method for Android. Is the boolean parameter, requestLocationPermission doing anything when the app is built against and targeting API level 23? I am not seeing any permission to use location when I set this flag. I would normally do this myself, but I am experiencing a very strange problem where the app will switch to a black screen and then crash whenever I try and call ContextCompat.CheckSelfPermission or RequestPermissions, so was hoping that this was going to work in CrossGeofence.

    thanks, Dennis

    Monday, August 22, 2016 6:35 PM
  • User157751 posted

    Fixed my issues when I discovered there was a plug in for permissions. Still unclear why I was having issues, very weird, but it's now working fine.

    Monday, August 22, 2016 7:36 PM
  • User237580 posted

    im getting the following exception. When I installed the v1.1.1 System.TypeLoadException: Could not load type 'Android.Gms.Common.GoogleApiAvailability' from assembly 'Xamarin.GooglePlayServices.Basement, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'. @RendyDelRosario Any fix for this. I'm not able to use the latest update beacuse I'm not able to update my Xamarin.GooglePlayservices.Base to 29.0.0.2

    Monday, September 26, 2016 12:04 PM
  • User237580 posted

    Is there any property to know that I have entered a Region,because I have to store the entry time to the server. I'll use that property to make server calls. @RendyDelRosario

    Tuesday, September 27, 2016 9:35 AM
  • User265752 posted

    Great plugin @RendyDelRosario! I created a sample app and everything worked fine.

    Couple questions I haven't seen answered wholly:

    1) Are you still actively developing this?

    2) Can this plugin monitor location while the app is terminated? (not in background) How does that work on iOs and Android?

    3) What provides the information to the Current.LastKnownLocation? I intend to check this whenever location changed event is triggered. Will it be consistent and accurate information from the GPS?

    Thank you!

    Friday, October 14, 2016 4:56 PM
  • User154141 posted

    @DharumaRaj did you were able to fix the TypeLoadException using the v1.1.1 ?

    thanks

    Friday, January 6, 2017 5:33 AM
  • User154141 posted

    Hi @GeraldVersluis do you know if there's a way to use this library along TK.CustomMap which I have already on a project however due dependencies issues I'm not being able to do it, the closest I'am on this is:

    adding this Geofence plugin v 1.1.1, along with

    Xamarin.GooglePlayServices.Base 29.0.0.1 Xamarin.GooglePlayServices.Basement 29.0.0.1 Xamarin.GooglePlayServices.Location 29.0.0.1 Xamarin.GooglePlayServices.Maps 29.0.0.1

    Xamarin.Forms.Maps 2.3.2.127

    TK.CustomMap 1.5.0

    the packages are added correctly, but when I try to Build, I get the message

    Error: Error executing task LinkAssemblies: error XA2006: Reference to metadata item 'Android.Gms.Common.GoogleApiAvailability Android.Gms.Common.GoogleApiAvailability::get_Instance()' (defined in 'Geofence.Plugin, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null') from 'Geofence.Plugin, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' could not be resolved.

    I'm actually trying with Acr.Geofencing, but the OnRegionStatusChanged is not being called properly, so I want to try this plugin since seems very complete,

    I appreciate it a lot,

    regards

    Friday, January 6, 2017 6:23 AM
  • User103165 posted

    Hi @MCvel I think this is not going to work without updating the Acr.Geofencing dependencies or at least synchronising the dependencies for them to work together.

    Friday, January 6, 2017 7:52 AM
  • User154141 posted

    @GeraldVersluis said: Hi @MCvel I think this is not going to work without updating the Acr.Geofencing dependencies or at least synchronising the dependencies for them to work together.

    Thanks mate!

    Saturday, January 7, 2017 11:33 PM
  • User228187 posted

    I am not able to install Xamarin.Forms.Maps after installing this plugin on Android.. Does that mean Forms Map functionality will not work if we want Geofencing in android??

    Monday, January 16, 2017 6:49 PM
  • User228187 posted

    @MCvel said: @DharumaRaj did you were able to fix the TypeLoadException using the v1.1.1 ?

    thanks

    I am getting the similar exception using 1.1.1.. Any Ideas??

    Tuesday, January 17, 2017 6:33 AM
  • User286549 posted

    Can anyone give me a vaild nugit package none of the is woking they all demand android mono v 7

    Wednesday, February 15, 2017 9:12 AM
  • User247369 posted

    This plugin does not work anymore after updating google play service.

    Wednesday, March 8, 2017 11:33 PM
  • User211610 posted

    I am running the sample app which I have downloaded from https://github.com/domaven/xamarin-plugins

    Unfortunately I am getting below 2 errors * When application load it throws below error from MapPage.xaml.cs/onAppearing but still app is running without crashing

        mapView.MoveToRegion (
                    MapSpan.FromCenterAndRadius (
                        new Xamarin.Forms.Maps.Position (lat, lon), Distance.FromMiles (1)).WithZoom (20));
    
    • When adding geofence radious and press OK, from below code snippet it throws exception saying 'System.NullReferenceException: Object reference not set to an instance of an object' and it continuously displaying 'loading' icon

      CrossGeofence.Current.StartMonitoring(new GeofenceCircularRegion (place.Name,place.Latitude,place.Longitude,place.Radius) {
      
                      NotifyOnStay=true,
                      StayedInThresholdDuration=TimeSpan.FromMinutes(5)
      
                  });
      
    Tuesday, March 21, 2017 9:18 PM
  • User307323 posted

    @RendyDelRosario I'm getting this error when trying to use Maps in my Xamarin.Android app. Not sure which update caused it but restoring the older versions won't help:

    -Using- Xamarin Google Play Services Version 42.1021.1 (Basement 10.2.1)

    C:\Users\rendy\Maven\xamarin-plugins\Geofence\Geofence\Geofence.Plugin.Android\GeofenceImplementation.cs: Error XA4204: Unable to resolve interface type 'Android.Gms.Common.Apis.GoogleApiClient/IConnectionCallbacks'. Are you missing an assembly reference? (XA4204)

    Monday, June 12, 2017 11:55 PM
  • User134955 posted

    @RendyDelRosario will the compatibility issue between Xamarin Google Play Services and your plugin on Android be resolved soon or should we look for another plugin?

    Thanks!

    Tuesday, June 20, 2017 4:53 PM
  • User24682 posted

    Hey I'm planning on working on this in a few weeks.

    Wednesday, June 21, 2017 8:39 PM
  • User336378 posted

    @RendyDelRosario Hi, i'm working on tracking pet location app and using geofence, when we can expect this compatibility issue is going to be fixed?

    Thursday, July 13, 2017 12:27 PM
  • User170628 posted

    OnRegionStateChanged event does not work....

    public void OnRegionStateChanged(GeofenceResult result) { if (result.Transition == GeofenceTransition.Exited || result.Transition == GeofenceTransition.Entered) { MessagingCenter.Send(result, "region"); } }

    Saturday, August 26, 2017 10:03 AM
  • User114618 posted

    I'm not getting Notifications at all. OnMonitoringStarted and OnLocationChanged are triggering but not OnRegionStateChanged. What might be the issue?

    CrossGeofence.Current.StartMonitoring(new GeofenceCircularRegion(branchcode, 6.940474, 79.878434, 5) { StayedInThresholdDuration = TimeSpan.FromMilliseconds(1000), NotifyOnEntry = true, NotifyOnExit = true, NotifyOnStay = true, ShowNotification = true, NotificationStayMessage = "In", ShowEntryNotification = true, ShowExitNotification = true, ShowStayNotification = true });

    Tuesday, August 29, 2017 12:15 PM
  • User114618 posted

    Sorry. It is working. but it is bit slow to trigger the OnRegionStateChanged.

    Tuesday, August 29, 2017 1:38 PM
  • User307323 posted

    @RendyDelRosario Hi Rendy, are you planning to work on this issue? (Google Play Services compatibility)

    Wednesday, September 13, 2017 11:39 PM
  • User257861 posted

    Hi guys! Has anyone here solved this problem?

    Severity Code Description Project File Line Suppression State Error Unable to resolve interface type 'Android.Gms.Common.Apis.GoogleApiClient/IConnectionCallbacks'. Are you missing an assembly reference? Base.Droid C:\Users\rendy\Maven\xamarin-plugins\Geofence\Geofence\Geofence.Plugin.Android\GeofenceImplementation.cs

    Wednesday, October 4, 2017 10:35 PM
  • User88992 posted

    @RendyDelRosario Thanks for this plugin! I saw support is coming for Region expiration time support. What is the ETA on this? Thanks.

    Friday, November 10, 2017 1:00 AM
  • User241022 posted

    @joaobp7 said: Hi guys! Has anyone here solved this problem?

    Severity Code Description Project File Line Suppression State Error Unable to resolve interface type 'Android.Gms.Common.Apis.GoogleApiClient/IConnectionCallbacks'. Are you missing an assembly reference? Base.Droid C:\Users\rendy\Maven\xamarin-plugins\Geofence\Geofence\Geofence.Plugin.Android\GeofenceImplementation.cs

    I am experiencing this same problem Running: GooglePlayServices.Base 42.1001.0 GooglePlayServices.Basement 42.1001.0 GooglePlayServices.Location 42.1001.0 GooglePlayServices.Maps 42.1001.0 GooglePlayServices.Tasks 42.1001.0

    The problem does not seem to occur with the 29.0.0.2 series of Google Play Services Libraries.

    Monday, November 13, 2017 4:49 PM
  • User263663 posted

    I am using GeoFence plugin but while exit from the defined geofence radius "OnRegionStateChanged" is triggering twice for Exit transition. Can Any one help me with this why for exit it's triggering twice. It's working fine in case of stay or entry transitions.

    Wednesday, February 7, 2018 11:36 AM
  • User51635 posted

    I also noticed this.

    Anyone?

    Thursday, February 22, 2018 9:56 AM
  • User369961 posted

    Hello Everyone,

    I have started using this plugin and have an issue I cannot resolve. I setup the GeoFence and GeoFence listener and the a few regions to monitor. I can see that the plugin starts monitoring my regions after I add them. I also can see that the plugin is correctly monitoring my location and through OnLocationChanged(). But it does not ever fire the OnRegionStateChanged() event in the my CrossGeoFenceListener. I am baffled on how everything seems to be working correctly except for the OnRegionStateChanged. Does anyone have any idea of what might be causing this problem and how to resolve it.

    Thanks!

    Tuesday, June 19, 2018 4:42 PM
  • User372098 posted

    @jzeferino said: It requires 27.0.0.0 but won't work if you update to 29.0.0.0. @CyrilCathala i don't want to have to reference the .dll. Its kinda bad because if they update the library i will need to refactor the dependency. I will try to make a PR for the repository.

    PLease can anyone tell me which package version they are talking about.. i am getting exception of System.InvalidCastException: Specified cast is not valid. I am using Plugin.Geofence by CrossGeeks

    Friday, August 10, 2018 1:06 PM
  • User211610 posted

    My application is suddenly returning the below error message and I am no longer getting any notification, appreciate if you can help me on this.

    CrossGeofence - Priority set to: Balanced Power CrossGeofence - You need to enabled Location Services [0:] CrossGeofence - Error: CrossGeofence - You need to enabled Location Services

    Please note even I have enabled the location service still I am getting above messages

    Sunday, August 12, 2018 9:44 AM
  • User24682 posted

    We released the newer version of this package as a new NuGet package here:

    https://www.nuget.org/packages/Plugin.Geofence/

    Tuesday, August 14, 2018 3:00 PM