Skip to content
This repository was archived by the owner on Jan 22, 2021. It is now read-only.

Commit af43c7a

Browse files
committed
Replace connectivity plugin with Xamarin.Essentials
1 parent 93a1d5a commit af43c7a

File tree

3 files changed

+6
-16
lines changed

3 files changed

+6
-16
lines changed

MyShop.UWP/project.lock.json

-7
Original file line numberDiff line numberDiff line change
@@ -902,7 +902,6 @@
902902
"Refractored.MvvmHelpers": "1.3.0",
903903
"SQLitePCLRaw.bundle_green": "1.1.9",
904904
"SQLitePCLRaw.core": "1.1.9",
905-
"Xam.Plugin.Connectivity": "3.1.1",
906905
"Xam.Plugin.EmbeddedResource": "1.0.1",
907906
"Xam.Plugin.ExternalMaps": "4.0.1",
908907
"Xam.Plugins.Forms.ImageCircle": "2.0.2",
@@ -2090,7 +2089,6 @@
20902089
"Refractored.MvvmHelpers": "1.3.0",
20912090
"SQLitePCLRaw.bundle_green": "1.1.9",
20922091
"SQLitePCLRaw.core": "1.1.9",
2093-
"Xam.Plugin.Connectivity": "3.1.1",
20942092
"Xam.Plugin.EmbeddedResource": "1.0.1",
20952093
"Xam.Plugin.ExternalMaps": "4.0.1",
20962094
"Xam.Plugins.Forms.ImageCircle": "2.0.2",
@@ -3334,7 +3332,6 @@
33343332
"Refractored.MvvmHelpers": "1.3.0",
33353333
"SQLitePCLRaw.bundle_green": "1.1.9",
33363334
"SQLitePCLRaw.core": "1.1.9",
3337-
"Xam.Plugin.Connectivity": "3.1.1",
33383335
"Xam.Plugin.EmbeddedResource": "1.0.1",
33393336
"Xam.Plugin.ExternalMaps": "4.0.1",
33403337
"Xam.Plugins.Forms.ImageCircle": "2.0.2",
@@ -4522,7 +4519,6 @@
45224519
"Refractored.MvvmHelpers": "1.3.0",
45234520
"SQLitePCLRaw.bundle_green": "1.1.9",
45244521
"SQLitePCLRaw.core": "1.1.9",
4525-
"Xam.Plugin.Connectivity": "3.1.1",
45264522
"Xam.Plugin.EmbeddedResource": "1.0.1",
45274523
"Xam.Plugin.ExternalMaps": "4.0.1",
45284524
"Xam.Plugins.Forms.ImageCircle": "2.0.2",
@@ -5766,7 +5762,6 @@
57665762
"Refractored.MvvmHelpers": "1.3.0",
57675763
"SQLitePCLRaw.bundle_green": "1.1.9",
57685764
"SQLitePCLRaw.core": "1.1.9",
5769-
"Xam.Plugin.Connectivity": "3.1.1",
57705765
"Xam.Plugin.EmbeddedResource": "1.0.1",
57715766
"Xam.Plugin.ExternalMaps": "4.0.1",
57725767
"Xam.Plugins.Forms.ImageCircle": "2.0.2",
@@ -6954,7 +6949,6 @@
69546949
"Refractored.MvvmHelpers": "1.3.0",
69556950
"SQLitePCLRaw.bundle_green": "1.1.9",
69566951
"SQLitePCLRaw.core": "1.1.9",
6957-
"Xam.Plugin.Connectivity": "3.1.1",
69586952
"Xam.Plugin.EmbeddedResource": "1.0.1",
69596953
"Xam.Plugin.ExternalMaps": "4.0.1",
69606954
"Xam.Plugins.Forms.ImageCircle": "2.0.2",
@@ -8198,7 +8192,6 @@
81988192
"Refractored.MvvmHelpers": "1.3.0",
81998193
"SQLitePCLRaw.bundle_green": "1.1.9",
82008194
"SQLitePCLRaw.core": "1.1.9",
8201-
"Xam.Plugin.Connectivity": "3.1.1",
82028195
"Xam.Plugin.EmbeddedResource": "1.0.1",
82038196
"Xam.Plugin.ExternalMaps": "4.0.1",
82048197
"Xam.Plugins.Forms.ImageCircle": "2.0.2",

MyShop/MyShop.csproj

-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
<PackageReference Include="Refractored.MvvmHelpers" Version="1.3.0" />
2020
<PackageReference Include="SQLitePCLRaw.bundle_green" Version="1.1.9" />
2121
<PackageReference Include="SQLitePCLRaw.core" Version="1.1.9" />
22-
<PackageReference Include="Xam.Plugin.Connectivity" Version="3.1.1" />
2322
<PackageReference Include="Xam.Plugin.EmbeddedResource" Version="1.0.1.0" />
2423
<PackageReference Include="Xam.Plugin.ExternalMaps" Version="4.0.1" />
2524
<PackageReference Include="Xam.Plugins.Forms.ImageCircle" Version="2.0.2" />

MyShop/Services/AzureDataStore.cs

+6-8
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,13 @@
22
using System.Collections.Generic;
33
using System.Threading.Tasks;
44
using Microsoft.WindowsAzure.MobileServices;
5-
using System.Linq;
65
using Microsoft.WindowsAzure.MobileServices.SQLiteStore;
76
using Microsoft.WindowsAzure.MobileServices.Sync;
87
using System.Diagnostics;
98
using System;
10-
using Xamarin.Forms;
119

1210
//Comment back in to use azure
13-
using MyShop;
14-
using Plugin.Connectivity;
11+
using Xamarin.Essentials;
1512

1613
//[assembly: Dependency(typeof(AzureDataStore))]
1714
namespace MyShop
@@ -119,8 +116,8 @@ public async Task<IEnumerable<Store>> GetStoresAsync()
119116
public async Task SyncStoresAsync()
120117
{
121118
try
122-
{
123-
if (!CrossConnectivity.Current.IsConnected || !Settings.NeedsSync)
119+
{
120+
if (!IsInternetAvailable || !Settings.NeedsSync)
124121
return;
125122

126123
await storeTable.PullAsync("allStores", storeTable.CreateQuery());
@@ -138,10 +135,9 @@ public async Task SyncFeedbacksAsync()
138135
try
139136
{
140137
Settings.NeedSyncFeedback = true;
141-
if (!CrossConnectivity.Current.IsConnected)
138+
if (!IsInternetAvailable)
142139
return;
143140

144-
145141
await MobileService.SyncContext.PushAsync();
146142
Settings.NeedSyncFeedback = false;
147143
}
@@ -151,6 +147,8 @@ public async Task SyncFeedbacksAsync()
151147
}
152148
}
153149

150+
bool IsInternetAvailable => Connectivity.NetworkAccess == NetworkAccess.Internet;
151+
154152
static readonly AzureDataStore instance = new AzureDataStore();
155153
/// <summary>
156154
/// Gets the instance of the Azure Web Service

0 commit comments

Comments
 (0)