How to check for network_provider and gps_provider in Xamarin forms?












0














I am using Xamarin.Forms and working with a project that will run in Android and Iphone. My project structure (if that information is useful?) are three projects "MyApp", "MyApp.Android" and "MyApp.iOS" inside the same solution.



Right now I am using different plugins such as Xam.Plugin.Geolocator and Plugin.Geofencing.Eddy in order to use Geofencing, but I am facing some problems (as stated in this other question Geofence for xamarin crossplatform).



Right now I want to check if the geofence will be able to work, checking if GPS_PROVIDER and NETWORK_PROVIDER are available, how could I achieve that? Right now I only can check if Location is enabled, but not which provider.



public bool IsLocationAvailable()
{
if (!CrossGeolocator.IsSupported)
return false;
if (!CrossGeolocator.Current.IsGeolocationEnabled)
return false;
if (!CrossGeolocator.Current.IsGeolocationAvailable)
return false;
if (!CrossGeofencing.IsSupported)
return false;
return true;
}


Right now if location provider is set to "GPS only" it throwns an error because of this, but I am not sure how to catch it and handle it. I have seen some other examples and questions but are exclusively for android and I am not sure how to implement those if I am already using those plugins and working mainly on the xamarin forms project (aka "MyApp") instead of the android one ("MyApp.Android")





Sorry for the big image, I am not sure how to resize it!










share|improve this question



























    0














    I am using Xamarin.Forms and working with a project that will run in Android and Iphone. My project structure (if that information is useful?) are three projects "MyApp", "MyApp.Android" and "MyApp.iOS" inside the same solution.



    Right now I am using different plugins such as Xam.Plugin.Geolocator and Plugin.Geofencing.Eddy in order to use Geofencing, but I am facing some problems (as stated in this other question Geofence for xamarin crossplatform).



    Right now I want to check if the geofence will be able to work, checking if GPS_PROVIDER and NETWORK_PROVIDER are available, how could I achieve that? Right now I only can check if Location is enabled, but not which provider.



    public bool IsLocationAvailable()
    {
    if (!CrossGeolocator.IsSupported)
    return false;
    if (!CrossGeolocator.Current.IsGeolocationEnabled)
    return false;
    if (!CrossGeolocator.Current.IsGeolocationAvailable)
    return false;
    if (!CrossGeofencing.IsSupported)
    return false;
    return true;
    }


    Right now if location provider is set to "GPS only" it throwns an error because of this, but I am not sure how to catch it and handle it. I have seen some other examples and questions but are exclusively for android and I am not sure how to implement those if I am already using those plugins and working mainly on the xamarin forms project (aka "MyApp") instead of the android one ("MyApp.Android")





    Sorry for the big image, I am not sure how to resize it!










    share|improve this question

























      0












      0








      0







      I am using Xamarin.Forms and working with a project that will run in Android and Iphone. My project structure (if that information is useful?) are three projects "MyApp", "MyApp.Android" and "MyApp.iOS" inside the same solution.



      Right now I am using different plugins such as Xam.Plugin.Geolocator and Plugin.Geofencing.Eddy in order to use Geofencing, but I am facing some problems (as stated in this other question Geofence for xamarin crossplatform).



      Right now I want to check if the geofence will be able to work, checking if GPS_PROVIDER and NETWORK_PROVIDER are available, how could I achieve that? Right now I only can check if Location is enabled, but not which provider.



      public bool IsLocationAvailable()
      {
      if (!CrossGeolocator.IsSupported)
      return false;
      if (!CrossGeolocator.Current.IsGeolocationEnabled)
      return false;
      if (!CrossGeolocator.Current.IsGeolocationAvailable)
      return false;
      if (!CrossGeofencing.IsSupported)
      return false;
      return true;
      }


      Right now if location provider is set to "GPS only" it throwns an error because of this, but I am not sure how to catch it and handle it. I have seen some other examples and questions but are exclusively for android and I am not sure how to implement those if I am already using those plugins and working mainly on the xamarin forms project (aka "MyApp") instead of the android one ("MyApp.Android")





      Sorry for the big image, I am not sure how to resize it!










      share|improve this question













      I am using Xamarin.Forms and working with a project that will run in Android and Iphone. My project structure (if that information is useful?) are three projects "MyApp", "MyApp.Android" and "MyApp.iOS" inside the same solution.



      Right now I am using different plugins such as Xam.Plugin.Geolocator and Plugin.Geofencing.Eddy in order to use Geofencing, but I am facing some problems (as stated in this other question Geofence for xamarin crossplatform).



      Right now I want to check if the geofence will be able to work, checking if GPS_PROVIDER and NETWORK_PROVIDER are available, how could I achieve that? Right now I only can check if Location is enabled, but not which provider.



      public bool IsLocationAvailable()
      {
      if (!CrossGeolocator.IsSupported)
      return false;
      if (!CrossGeolocator.Current.IsGeolocationEnabled)
      return false;
      if (!CrossGeolocator.Current.IsGeolocationAvailable)
      return false;
      if (!CrossGeofencing.IsSupported)
      return false;
      return true;
      }


      Right now if location provider is set to "GPS only" it throwns an error because of this, but I am not sure how to catch it and handle it. I have seen some other examples and questions but are exclusively for android and I am not sure how to implement those if I am already using those plugins and working mainly on the xamarin forms project (aka "MyApp") instead of the android one ("MyApp.Android")





      Sorry for the big image, I am not sure how to resize it!







      android xamarin xamarin.forms gps geofencing






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 12 '18 at 20:10









      ManzhaManzha

      25117




      25117
























          1 Answer
          1






          active

          oldest

          votes


















          1














          You can always run platform specific code in your shared project, "MyApp", using Xamarin.Forms Dependency Service.



          The basic idea is that you create an interface in your shared project, lets call it IGetLocationProvider:



          public interface IGetLocationProvider {
          string GetProvider ();
          }


          Then in the Android,"MyApp.Android", and/or iOS, "MyApp.iOS" app projects, you implement the interface in a class and add the Dependency attribute to the class. But first you will need access to the Android app context. The easiest way to have this available globally in the Android app project is to add a static variable to the MainActivity class and set it in OnCreate:



          public class MainActivity : global::Xamarin.Forms.Platform.Android.FormsAppCompatActivity
          {
          public static Context Context;
          ...
          protected override void OnCreate(Bundle savedInstanceState)
          {
          ...
          MainActivity.Context = this;

          }
          }


          Now here is the platform specific Dependency Service for Android that will return a string with comma separated available location providers:



          using System;
          using GetLP.Droid;
          using Xamarin.Forms;
          using Android.Locations;

          [assembly: Dependency(typeof(GetLocationProvider))]
          namespace GetLP.Droid
          {
          public class GetLocationProvider : IGetLocationProvider
          {
          public string GetProvider()
          {
          string returnString = "";

          LocationManager manager = (LocationManager)MainActivity.Context.GetSystemService(Android.Content.Context.LocationService);
          bool gpsProviderEnabled = manager.IsProviderEnabled(LocationManager.GpsProvider);
          bool networkProviderEnabled = manager.IsProviderEnabled(LocationManager.NetworkProvider);
          bool passiveProviderEnabled = manager.IsProviderEnabled(LocationManager.PassiveProvider);

          returnString += gpsProviderEnabled ? "GPS," : ",";
          returnString += networkProviderEnabled ? "Network," : ",";
          returnString += passiveProviderEnabled ? "Passive" : "";

          return returnString;
          }
          }
          }


          Now you can call GetProvider from your shared code:



          string providers = DependencyService.Get<IGetLocationProvider>().GetProvider();


          The variable providers will be a comma separated string of the available providers, e.g. if GSP and Passive are available the string will be "GPS,,Passive" and if Network and Passive are available the string will be ",Network,Passive". Of course you can change the GetProvider to return an array or List or whatever you want, just make sure it is something that is available on all platforms, i.e. don't return a LocationManager as that is Android specific type.



          For iOS, there is nothing similar. iOS decides what methods to use to get the location and what the OS uses is not available to an app developer when getting the location, so you only want to call this dependency service when running on Android.






          share|improve this answer





















          • In this case I could call GetProvider() in "MyApp" project and that would give me the result I want, but what about iOS which I don't want to get this code executed? I have been reading and would it be ok if I don't make an implementation in iOS of the interface and make the call in an if (Device.RuntimePlatform == Device.Android) ?
            – Manzha
            Nov 13 '18 at 17:37










          • yes, that is correct.
            – jgoldberger - MSFT
            Nov 13 '18 at 20:20










          • And if I answered your question, which it seems I did, please accept the answer, thanks!
            – jgoldberger - MSFT
            Nov 14 '18 at 6:05










          • Sorry! I was trying the answer and I can now say it just works perfectly! Before this i tried something similar but without the Dependency Service and it worked but just on android and got some compilation errors on iOS. Then I tried this answer and it just works as expected! Thanks a lot
            – Manzha
            Nov 14 '18 at 17:56











          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53269388%2fhow-to-check-for-network-provider-and-gps-provider-in-xamarin-forms%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          1














          You can always run platform specific code in your shared project, "MyApp", using Xamarin.Forms Dependency Service.



          The basic idea is that you create an interface in your shared project, lets call it IGetLocationProvider:



          public interface IGetLocationProvider {
          string GetProvider ();
          }


          Then in the Android,"MyApp.Android", and/or iOS, "MyApp.iOS" app projects, you implement the interface in a class and add the Dependency attribute to the class. But first you will need access to the Android app context. The easiest way to have this available globally in the Android app project is to add a static variable to the MainActivity class and set it in OnCreate:



          public class MainActivity : global::Xamarin.Forms.Platform.Android.FormsAppCompatActivity
          {
          public static Context Context;
          ...
          protected override void OnCreate(Bundle savedInstanceState)
          {
          ...
          MainActivity.Context = this;

          }
          }


          Now here is the platform specific Dependency Service for Android that will return a string with comma separated available location providers:



          using System;
          using GetLP.Droid;
          using Xamarin.Forms;
          using Android.Locations;

          [assembly: Dependency(typeof(GetLocationProvider))]
          namespace GetLP.Droid
          {
          public class GetLocationProvider : IGetLocationProvider
          {
          public string GetProvider()
          {
          string returnString = "";

          LocationManager manager = (LocationManager)MainActivity.Context.GetSystemService(Android.Content.Context.LocationService);
          bool gpsProviderEnabled = manager.IsProviderEnabled(LocationManager.GpsProvider);
          bool networkProviderEnabled = manager.IsProviderEnabled(LocationManager.NetworkProvider);
          bool passiveProviderEnabled = manager.IsProviderEnabled(LocationManager.PassiveProvider);

          returnString += gpsProviderEnabled ? "GPS," : ",";
          returnString += networkProviderEnabled ? "Network," : ",";
          returnString += passiveProviderEnabled ? "Passive" : "";

          return returnString;
          }
          }
          }


          Now you can call GetProvider from your shared code:



          string providers = DependencyService.Get<IGetLocationProvider>().GetProvider();


          The variable providers will be a comma separated string of the available providers, e.g. if GSP and Passive are available the string will be "GPS,,Passive" and if Network and Passive are available the string will be ",Network,Passive". Of course you can change the GetProvider to return an array or List or whatever you want, just make sure it is something that is available on all platforms, i.e. don't return a LocationManager as that is Android specific type.



          For iOS, there is nothing similar. iOS decides what methods to use to get the location and what the OS uses is not available to an app developer when getting the location, so you only want to call this dependency service when running on Android.






          share|improve this answer





















          • In this case I could call GetProvider() in "MyApp" project and that would give me the result I want, but what about iOS which I don't want to get this code executed? I have been reading and would it be ok if I don't make an implementation in iOS of the interface and make the call in an if (Device.RuntimePlatform == Device.Android) ?
            – Manzha
            Nov 13 '18 at 17:37










          • yes, that is correct.
            – jgoldberger - MSFT
            Nov 13 '18 at 20:20










          • And if I answered your question, which it seems I did, please accept the answer, thanks!
            – jgoldberger - MSFT
            Nov 14 '18 at 6:05










          • Sorry! I was trying the answer and I can now say it just works perfectly! Before this i tried something similar but without the Dependency Service and it worked but just on android and got some compilation errors on iOS. Then I tried this answer and it just works as expected! Thanks a lot
            – Manzha
            Nov 14 '18 at 17:56
















          1














          You can always run platform specific code in your shared project, "MyApp", using Xamarin.Forms Dependency Service.



          The basic idea is that you create an interface in your shared project, lets call it IGetLocationProvider:



          public interface IGetLocationProvider {
          string GetProvider ();
          }


          Then in the Android,"MyApp.Android", and/or iOS, "MyApp.iOS" app projects, you implement the interface in a class and add the Dependency attribute to the class. But first you will need access to the Android app context. The easiest way to have this available globally in the Android app project is to add a static variable to the MainActivity class and set it in OnCreate:



          public class MainActivity : global::Xamarin.Forms.Platform.Android.FormsAppCompatActivity
          {
          public static Context Context;
          ...
          protected override void OnCreate(Bundle savedInstanceState)
          {
          ...
          MainActivity.Context = this;

          }
          }


          Now here is the platform specific Dependency Service for Android that will return a string with comma separated available location providers:



          using System;
          using GetLP.Droid;
          using Xamarin.Forms;
          using Android.Locations;

          [assembly: Dependency(typeof(GetLocationProvider))]
          namespace GetLP.Droid
          {
          public class GetLocationProvider : IGetLocationProvider
          {
          public string GetProvider()
          {
          string returnString = "";

          LocationManager manager = (LocationManager)MainActivity.Context.GetSystemService(Android.Content.Context.LocationService);
          bool gpsProviderEnabled = manager.IsProviderEnabled(LocationManager.GpsProvider);
          bool networkProviderEnabled = manager.IsProviderEnabled(LocationManager.NetworkProvider);
          bool passiveProviderEnabled = manager.IsProviderEnabled(LocationManager.PassiveProvider);

          returnString += gpsProviderEnabled ? "GPS," : ",";
          returnString += networkProviderEnabled ? "Network," : ",";
          returnString += passiveProviderEnabled ? "Passive" : "";

          return returnString;
          }
          }
          }


          Now you can call GetProvider from your shared code:



          string providers = DependencyService.Get<IGetLocationProvider>().GetProvider();


          The variable providers will be a comma separated string of the available providers, e.g. if GSP and Passive are available the string will be "GPS,,Passive" and if Network and Passive are available the string will be ",Network,Passive". Of course you can change the GetProvider to return an array or List or whatever you want, just make sure it is something that is available on all platforms, i.e. don't return a LocationManager as that is Android specific type.



          For iOS, there is nothing similar. iOS decides what methods to use to get the location and what the OS uses is not available to an app developer when getting the location, so you only want to call this dependency service when running on Android.






          share|improve this answer





















          • In this case I could call GetProvider() in "MyApp" project and that would give me the result I want, but what about iOS which I don't want to get this code executed? I have been reading and would it be ok if I don't make an implementation in iOS of the interface and make the call in an if (Device.RuntimePlatform == Device.Android) ?
            – Manzha
            Nov 13 '18 at 17:37










          • yes, that is correct.
            – jgoldberger - MSFT
            Nov 13 '18 at 20:20










          • And if I answered your question, which it seems I did, please accept the answer, thanks!
            – jgoldberger - MSFT
            Nov 14 '18 at 6:05










          • Sorry! I was trying the answer and I can now say it just works perfectly! Before this i tried something similar but without the Dependency Service and it worked but just on android and got some compilation errors on iOS. Then I tried this answer and it just works as expected! Thanks a lot
            – Manzha
            Nov 14 '18 at 17:56














          1












          1








          1






          You can always run platform specific code in your shared project, "MyApp", using Xamarin.Forms Dependency Service.



          The basic idea is that you create an interface in your shared project, lets call it IGetLocationProvider:



          public interface IGetLocationProvider {
          string GetProvider ();
          }


          Then in the Android,"MyApp.Android", and/or iOS, "MyApp.iOS" app projects, you implement the interface in a class and add the Dependency attribute to the class. But first you will need access to the Android app context. The easiest way to have this available globally in the Android app project is to add a static variable to the MainActivity class and set it in OnCreate:



          public class MainActivity : global::Xamarin.Forms.Platform.Android.FormsAppCompatActivity
          {
          public static Context Context;
          ...
          protected override void OnCreate(Bundle savedInstanceState)
          {
          ...
          MainActivity.Context = this;

          }
          }


          Now here is the platform specific Dependency Service for Android that will return a string with comma separated available location providers:



          using System;
          using GetLP.Droid;
          using Xamarin.Forms;
          using Android.Locations;

          [assembly: Dependency(typeof(GetLocationProvider))]
          namespace GetLP.Droid
          {
          public class GetLocationProvider : IGetLocationProvider
          {
          public string GetProvider()
          {
          string returnString = "";

          LocationManager manager = (LocationManager)MainActivity.Context.GetSystemService(Android.Content.Context.LocationService);
          bool gpsProviderEnabled = manager.IsProviderEnabled(LocationManager.GpsProvider);
          bool networkProviderEnabled = manager.IsProviderEnabled(LocationManager.NetworkProvider);
          bool passiveProviderEnabled = manager.IsProviderEnabled(LocationManager.PassiveProvider);

          returnString += gpsProviderEnabled ? "GPS," : ",";
          returnString += networkProviderEnabled ? "Network," : ",";
          returnString += passiveProviderEnabled ? "Passive" : "";

          return returnString;
          }
          }
          }


          Now you can call GetProvider from your shared code:



          string providers = DependencyService.Get<IGetLocationProvider>().GetProvider();


          The variable providers will be a comma separated string of the available providers, e.g. if GSP and Passive are available the string will be "GPS,,Passive" and if Network and Passive are available the string will be ",Network,Passive". Of course you can change the GetProvider to return an array or List or whatever you want, just make sure it is something that is available on all platforms, i.e. don't return a LocationManager as that is Android specific type.



          For iOS, there is nothing similar. iOS decides what methods to use to get the location and what the OS uses is not available to an app developer when getting the location, so you only want to call this dependency service when running on Android.






          share|improve this answer












          You can always run platform specific code in your shared project, "MyApp", using Xamarin.Forms Dependency Service.



          The basic idea is that you create an interface in your shared project, lets call it IGetLocationProvider:



          public interface IGetLocationProvider {
          string GetProvider ();
          }


          Then in the Android,"MyApp.Android", and/or iOS, "MyApp.iOS" app projects, you implement the interface in a class and add the Dependency attribute to the class. But first you will need access to the Android app context. The easiest way to have this available globally in the Android app project is to add a static variable to the MainActivity class and set it in OnCreate:



          public class MainActivity : global::Xamarin.Forms.Platform.Android.FormsAppCompatActivity
          {
          public static Context Context;
          ...
          protected override void OnCreate(Bundle savedInstanceState)
          {
          ...
          MainActivity.Context = this;

          }
          }


          Now here is the platform specific Dependency Service for Android that will return a string with comma separated available location providers:



          using System;
          using GetLP.Droid;
          using Xamarin.Forms;
          using Android.Locations;

          [assembly: Dependency(typeof(GetLocationProvider))]
          namespace GetLP.Droid
          {
          public class GetLocationProvider : IGetLocationProvider
          {
          public string GetProvider()
          {
          string returnString = "";

          LocationManager manager = (LocationManager)MainActivity.Context.GetSystemService(Android.Content.Context.LocationService);
          bool gpsProviderEnabled = manager.IsProviderEnabled(LocationManager.GpsProvider);
          bool networkProviderEnabled = manager.IsProviderEnabled(LocationManager.NetworkProvider);
          bool passiveProviderEnabled = manager.IsProviderEnabled(LocationManager.PassiveProvider);

          returnString += gpsProviderEnabled ? "GPS," : ",";
          returnString += networkProviderEnabled ? "Network," : ",";
          returnString += passiveProviderEnabled ? "Passive" : "";

          return returnString;
          }
          }
          }


          Now you can call GetProvider from your shared code:



          string providers = DependencyService.Get<IGetLocationProvider>().GetProvider();


          The variable providers will be a comma separated string of the available providers, e.g. if GSP and Passive are available the string will be "GPS,,Passive" and if Network and Passive are available the string will be ",Network,Passive". Of course you can change the GetProvider to return an array or List or whatever you want, just make sure it is something that is available on all platforms, i.e. don't return a LocationManager as that is Android specific type.



          For iOS, there is nothing similar. iOS decides what methods to use to get the location and what the OS uses is not available to an app developer when getting the location, so you only want to call this dependency service when running on Android.







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 13 '18 at 2:26









          jgoldberger - MSFTjgoldberger - MSFT

          3,4831827




          3,4831827












          • In this case I could call GetProvider() in "MyApp" project and that would give me the result I want, but what about iOS which I don't want to get this code executed? I have been reading and would it be ok if I don't make an implementation in iOS of the interface and make the call in an if (Device.RuntimePlatform == Device.Android) ?
            – Manzha
            Nov 13 '18 at 17:37










          • yes, that is correct.
            – jgoldberger - MSFT
            Nov 13 '18 at 20:20










          • And if I answered your question, which it seems I did, please accept the answer, thanks!
            – jgoldberger - MSFT
            Nov 14 '18 at 6:05










          • Sorry! I was trying the answer and I can now say it just works perfectly! Before this i tried something similar but without the Dependency Service and it worked but just on android and got some compilation errors on iOS. Then I tried this answer and it just works as expected! Thanks a lot
            – Manzha
            Nov 14 '18 at 17:56


















          • In this case I could call GetProvider() in "MyApp" project and that would give me the result I want, but what about iOS which I don't want to get this code executed? I have been reading and would it be ok if I don't make an implementation in iOS of the interface and make the call in an if (Device.RuntimePlatform == Device.Android) ?
            – Manzha
            Nov 13 '18 at 17:37










          • yes, that is correct.
            – jgoldberger - MSFT
            Nov 13 '18 at 20:20










          • And if I answered your question, which it seems I did, please accept the answer, thanks!
            – jgoldberger - MSFT
            Nov 14 '18 at 6:05










          • Sorry! I was trying the answer and I can now say it just works perfectly! Before this i tried something similar but without the Dependency Service and it worked but just on android and got some compilation errors on iOS. Then I tried this answer and it just works as expected! Thanks a lot
            – Manzha
            Nov 14 '18 at 17:56
















          In this case I could call GetProvider() in "MyApp" project and that would give me the result I want, but what about iOS which I don't want to get this code executed? I have been reading and would it be ok if I don't make an implementation in iOS of the interface and make the call in an if (Device.RuntimePlatform == Device.Android) ?
          – Manzha
          Nov 13 '18 at 17:37




          In this case I could call GetProvider() in "MyApp" project and that would give me the result I want, but what about iOS which I don't want to get this code executed? I have been reading and would it be ok if I don't make an implementation in iOS of the interface and make the call in an if (Device.RuntimePlatform == Device.Android) ?
          – Manzha
          Nov 13 '18 at 17:37












          yes, that is correct.
          – jgoldberger - MSFT
          Nov 13 '18 at 20:20




          yes, that is correct.
          – jgoldberger - MSFT
          Nov 13 '18 at 20:20












          And if I answered your question, which it seems I did, please accept the answer, thanks!
          – jgoldberger - MSFT
          Nov 14 '18 at 6:05




          And if I answered your question, which it seems I did, please accept the answer, thanks!
          – jgoldberger - MSFT
          Nov 14 '18 at 6:05












          Sorry! I was trying the answer and I can now say it just works perfectly! Before this i tried something similar but without the Dependency Service and it worked but just on android and got some compilation errors on iOS. Then I tried this answer and it just works as expected! Thanks a lot
          – Manzha
          Nov 14 '18 at 17:56




          Sorry! I was trying the answer and I can now say it just works perfectly! Before this i tried something similar but without the Dependency Service and it worked but just on android and got some compilation errors on iOS. Then I tried this answer and it just works as expected! Thanks a lot
          – Manzha
          Nov 14 '18 at 17:56


















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.





          Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


          Please pay close attention to the following guidance:


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53269388%2fhow-to-check-for-network-provider-and-gps-provider-in-xamarin-forms%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Florida Star v. B. J. F.

          Danny Elfman

          Lugert, Oklahoma