├── .editorconfig ├── .gitattributes ├── .github ├── FUNDING.yml ├── ISSUE_TEMPLATE.md └── PULL_REQUEST_TEMPLATE.md ├── .gitignore ├── CHANGELOG.md ├── LICENSE ├── README.md ├── appveyor.yml ├── art └── icon.png ├── build.cake ├── build.ps1 ├── build.sh ├── cake.packages.config ├── component ├── ConnectivityPlugin_128x128.png ├── ConnectivityPlugin_512x512.png ├── Details.md ├── GettingStarted.md ├── License.md └── component.template.yaml ├── docs ├── Architecture.md ├── CheckingConnectivity.md ├── ConnectivityChanges.md ├── GettingStarted.md ├── PingaHost.md ├── README.md └── _config.yml ├── install-android-sdk.ps1 ├── nuget └── Plugin.nuspec ├── samples ├── ConnectivitySample.sln └── ConnectivitySample │ ├── ConnectivitySample.Droid │ ├── Assets │ │ └── AboutAssets.txt │ ├── ConnectivitySample.Droid.csproj │ ├── ConnectivitySample.Droid.csproj.bak │ ├── MainActivity.cs │ ├── Properties │ │ ├── AndroidManifest.xml │ │ └── AssemblyInfo.cs │ ├── Resources │ │ ├── AboutResources.txt │ │ ├── Resource.Designer.cs │ │ ├── drawable-hdpi │ │ │ └── icon.png │ │ ├── drawable-xhdpi │ │ │ └── icon.png │ │ ├── drawable-xxhdpi │ │ │ └── icon.png │ │ └── drawable │ │ │ └── icon.png │ └── packages.config │ ├── ConnectivitySample.WinPhone │ ├── App.xaml │ ├── App.xaml.cs │ ├── Assets │ │ ├── AlignmentGrid.png │ │ ├── ApplicationIcon.png │ │ └── Tiles │ │ │ ├── FlipCycleTileLarge.png │ │ │ ├── FlipCycleTileMedium.png │ │ │ ├── FlipCycleTileSmall.png │ │ │ ├── IconicTileMediumLarge.png │ │ │ └── IconicTileSmall.png │ ├── ConnectivitySample.WinPhone.csproj │ ├── LocalizedStrings.cs │ ├── MainPage.xaml │ ├── MainPage.xaml.cs │ ├── Properties │ │ ├── AppManifest.xml │ │ ├── AssemblyInfo.cs │ │ └── WMAppManifest.xml │ ├── README_FIRST.txt │ ├── Resources │ │ ├── AppResources.Designer.cs │ │ └── AppResources.resx │ ├── SplashScreenImage.jpg │ ├── Toolkit.Content │ │ ├── ApplicationBar.Add.png │ │ ├── ApplicationBar.Cancel.png │ │ ├── ApplicationBar.Check.png │ │ ├── ApplicationBar.Delete.png │ │ └── ApplicationBar.Select.png │ └── packages.config │ ├── ConnectivitySample.iOS │ ├── AppDelegate.cs │ ├── ConnectivitySample.iOS.csproj │ ├── Entitlements.plist │ ├── Info.plist │ ├── Main.cs │ ├── Properties │ │ └── AssemblyInfo.cs │ ├── Resources │ │ ├── Default-568h@2x.png │ │ ├── Default-Portrait.png │ │ ├── Default-Portrait@2x.png │ │ ├── Default.png │ │ ├── Default@2x.png │ │ ├── Icon-60@2x.png │ │ ├── Icon-60@3x.png │ │ ├── Icon-76.png │ │ ├── Icon-76@2x.png │ │ ├── Icon-Small-40.png │ │ ├── Icon-Small-40@2x.png │ │ ├── Icon-Small-40@3x.png │ │ ├── Icon-Small.png │ │ ├── Icon-Small@2x.png │ │ ├── Icon-Small@3x.png │ │ └── LaunchScreen.storyboard │ ├── iTunesArtwork │ ├── iTunesArtwork@2x │ └── packages.config │ └── ConnectivitySample │ ├── App.cs │ ├── ConnectivitySample.csproj │ ├── Properties │ └── AssemblyInfo.cs │ └── packages.config ├── src ├── Connectivity.Plugin.Abstractions │ ├── BaseConnectivity.cs │ ├── ConnectionType.cs │ ├── Connectivity.Plugin.Abstractions.csproj │ └── IConnectivity.cs ├── Connectivity.Plugin.Android │ ├── Connectivity.Plugin.Android.csproj │ ├── ConnectivityChangeBroadcastReceiver.cs │ ├── ConnectivityImplementation.cs │ ├── Properties │ │ └── AssemblyInfo.cs │ └── Resources │ │ ├── AboutResources.txt │ │ └── Resource.Designer.cs ├── Connectivity.Plugin.Mac │ ├── Connectivity.Plugin.Mac.csproj │ └── Properties │ │ └── AssemblyInfo.cs ├── Connectivity.Plugin.Net45 │ ├── Connectivity.Plugin.Net45.csproj │ ├── ConnectivityImplementation.cs │ └── Properties │ │ └── AssemblyInfo.cs ├── Connectivity.Plugin.NetCore │ └── Connectivity.Plugin.NetCore.csproj ├── Connectivity.Plugin.Shared.Apple │ ├── Connectivity.Plugin.Shared.Apple.projitems │ ├── Connectivity.Plugin.Shared.Apple.shproj │ ├── ConnectivityImplementation.cs │ └── Reachability.cs ├── Connectivity.Plugin.Tizen │ ├── Connectivity.Plugin.Tizen.csproj │ └── ConnectivityImplementation.cs ├── Connectivity.Plugin.UWP │ ├── Connectivity.Plugin.UWP.csproj │ ├── ConnectivityImplementation.cs │ ├── Properties │ │ ├── AssemblyInfo.cs │ │ └── Plugin.Connectivity.rd.xml │ └── project.json ├── Connectivity.Plugin.iOS │ ├── Connectivity.Plugin.iOS.csproj │ └── Properties │ │ └── AssemblyInfo.cs ├── Connectivity.Plugin.tvOS │ ├── Connectivity.Plugin.tvOS.csproj │ └── Properties │ │ └── AssemblyInfo.cs ├── Connectivity.Plugin.watchOS │ ├── Connectivity.Plugin.watchOS.csproj │ └── Properties │ │ └── AssemblyInfo.cs ├── Connectivity.Plugin │ ├── Connectivity.Plugin.csproj │ └── CrossConnectivity.cs └── Connectivity.sln └── tests ├── Connectivity.Plugin.Tests.iOS ├── AppDelegate.cs ├── Connectivity.Plugin.Tests.iOS.csproj ├── Entitlements.plist ├── Info.plist ├── Main.cs ├── Properties │ └── AssemblyInfo.cs └── Resources │ ├── Default-568h@2x.png │ ├── Default.png │ └── Default@2x.png ├── Connectivity.Tests.Android ├── Assets │ └── AboutAssets.txt ├── Configuration.props ├── Connectivity.Tests.Android.csproj ├── Connectivity.Tests.Android.csproj.bak ├── MainActivity.cs ├── NUnit.projitems ├── Properties │ ├── AndroidManifest.xml │ └── AssemblyInfo.cs ├── Resources │ ├── AboutResources.txt │ ├── Resource.Designer.cs │ ├── drawable │ │ └── Icon.png │ └── values │ │ └── Strings.xml ├── RunUnitTests.target ├── TestInstrumentation.cs ├── TestSample.cs └── lib │ ├── Xamarin.Android.Tools.AndroidSdk.dll │ ├── Xamarin.Android.Tools.BootstrapTasks.dll │ └── xa-prep-tasks.dll ├── Connectivity.Tests.Tizen ├── Connectivity.Tests.Tizen.csproj ├── Connectivity.Tests.Tizen_App.cs ├── shared │ └── res │ │ └── Connectivity.Tests.Tizen.png └── tizen-manifest.xml ├── Connectivity.Tests.iOS ├── AppDelegate.cs ├── Connectivity.Tests.iOS.csproj ├── Entitlements.plist ├── Info.plist ├── Main.cs ├── Makefile ├── Properties │ └── AssemblyInfo.cs ├── Resources │ ├── Default-568h@2x.png │ ├── Default.png │ └── Default@2x.png └── run-unittests.sh ├── Connectivity.Tests ├── Class1.cs ├── Connectivity.Tests.csproj └── Properties │ └── AssemblyInfo.cs ├── ConnectivityTest.UWP ├── App.xaml ├── App.xaml.cs ├── Assets │ ├── LockScreenLogo.scale-200.png │ ├── SplashScreen.scale-200.png │ ├── Square150x150Logo.scale-200.png │ ├── Square44x44Logo.scale-200.png │ ├── Square44x44Logo.targetsize-24_altform-unplated.png │ ├── StoreLogo.png │ └── Wide310x150Logo.scale-200.png ├── ConnectivityTest.UWP.csproj ├── MainPage.xaml ├── MainPage.xaml.cs ├── Package.appxmanifest ├── Properties │ ├── AssemblyInfo.cs │ └── Default.rd.xml └── project.json ├── ConnectivityTests.sln ├── ConnectivyTest.Net45 ├── App.config ├── ConnectivyTest.Net45.csproj ├── Program.cs └── Properties │ └── AssemblyInfo.cs └── app ├── ConnectivityTest ├── App.xaml ├── App.xaml.cs ├── ConnectivityTest.csproj ├── ConnectivityTestPage.xaml ├── ConnectivityTestPage.xaml.cs ├── Properties │ └── AssemblyInfo.cs └── packages.config ├── Droid ├── Assets │ └── AboutAssets.txt ├── ConnectivityTest.Droid.csproj ├── MainActivity.cs ├── Properties │ ├── AndroidManifest.xml │ └── AssemblyInfo.cs ├── Resources │ ├── AboutResources.txt │ ├── Resource.designer.cs │ ├── drawable-hdpi │ │ └── icon.png │ ├── drawable-xhdpi │ │ └── icon.png │ ├── drawable-xxhdpi │ │ └── icon.png │ ├── drawable │ │ └── icon.png │ ├── layout │ │ ├── Tabbar.axml │ │ └── Toolbar.axml │ └── values │ │ └── styles.xml └── packages.config └── iOS ├── AppDelegate.cs ├── Assets.xcassets ├── AppIcon.appiconset │ └── Contents.json └── Contents.json ├── ConnectivityTest.iOS.csproj ├── ConnectivityTest.iOS.csproj.bak ├── Entitlements.plist ├── Info.plist ├── LaunchScreen.storyboard ├── Main.cs └── packages.config /.gitattributes: -------------------------------------------------------------------------------- 1 | ############################################################################### 2 | # Set default behavior to automatically normalize line endings. 3 | ############################################################################### 4 | * text=auto 5 | 6 | ############################################################################### 7 | # Set default behavior for command prompt diff. 8 | # 9 | # This is need for earlier builds of msysgit that does not have it on by 10 | # default for csharp files. 11 | # Note: This is only used by command line 12 | ############################################################################### 13 | #*.cs diff=csharp 14 | 15 | ############################################################################### 16 | # Set the merge driver for project and solution files 17 | # 18 | # Merging from the command prompt will add diff markers to the files if there 19 | # are conflicts (Merging from VS is not affected by the settings below, in VS 20 | # the diff markers are never inserted). Diff markers may cause the following 21 | # file extensions to fail to load in VS. An alternative would be to treat 22 | # these files as binary and thus will always conflict and require user 23 | # intervention with every merge. To do so, just uncomment the entries below 24 | ############################################################################### 25 | #*.sln merge=binary 26 | #*.csproj merge=binary 27 | #*.vbproj merge=binary 28 | #*.vcxproj merge=binary 29 | #*.vcproj merge=binary 30 | #*.dbproj merge=binary 31 | #*.fsproj merge=binary 32 | #*.lsproj merge=binary 33 | #*.wixproj merge=binary 34 | #*.modelproj merge=binary 35 | #*.sqlproj merge=binary 36 | #*.wwaproj merge=binary 37 | 38 | ############################################################################### 39 | # behavior for image files 40 | # 41 | # image files are treated as binary by default. 42 | ############################################################################### 43 | #*.jpg binary 44 | #*.png binary 45 | #*.gif binary 46 | 47 | ############################################################################### 48 | # diff behavior for common document formats 49 | # 50 | # Convert binary document formats to text before diffing them. This feature 51 | # is only available from the command line. Turn it on by uncommenting the 52 | # entries below. 53 | ############################################################################### 54 | #*.doc diff=astextplain 55 | #*.DOC diff=astextplain 56 | #*.docx diff=astextplain 57 | #*.DOCX diff=astextplain 58 | #*.dot diff=astextplain 59 | #*.DOT diff=astextplain 60 | #*.pdf diff=astextplain 61 | #*.PDF diff=astextplain 62 | #*.rtf diff=astextplain 63 | #*.RTF diff=astextplain 64 | -------------------------------------------------------------------------------- /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | github: jamesmontemagno 2 | patreon: mergeconflictfm 3 | custom: https://www.buymeacoffee.com/jamesmontemagno 4 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | If you are creating an issue for a BUG please fill out this information. If you are asking a question or requesting a feature you can delete the sections below. 2 | 3 | **Failure to fill out this information will result in this issue being closed.** If you post a full stack trace in a bug it will be closed, please post it to http://gist.github.com and then post the link here. 4 | 5 | ## Bug Information 6 | 7 | Version Number of Plugin: 8 | Device Tested On: 9 | Simulator Tested On: 10 | Version of VS: 11 | Version of Xamarin: 12 | Versions of other things you are using: 13 | 14 | ### Steps to reproduce the Behavior 15 | 16 | ### Expected Behavior 17 | 18 | ### Actual Behavior 19 | 20 | ### Code snippet 21 | 22 | ### Screenshots 23 | 24 | 25 | -------------------------------------------------------------------------------- /.github/PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | Please take a moment to fill out the following: 2 | 3 | Fixes issue # 4 | 5 | Changes Proposed in this pull request: 6 | - 7 | - 8 | 9 | 10 | ### PR Checklist ### 11 | 12 | - [ ] Has tests (if omitted, state reason in description) 13 | - [ ] Rebased on top of master at time of PR 14 | - [ ] Consolidate commits as makes sense -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | ### 3.2.0 2 | * [Android] Fixes for Android #133, #142, #134 around API 23+ Validated check 3 | * [Android] Fixes for Android #143 for ensuring connectivity changed fires on multiple changes 4 | 5 | ### 3.1.0 6 | * [Android] Bandwidth as bits per second instead of mbps 7 | * [Android] No longer show connection types that aren't available 8 | * [Android] Only return active connection types 9 | * [iOS] Fix for connection type always returning WiFi even when on cellular 10 | * [Windows] Improve timeout when checking connections 11 | * Add .NET Core 2.0 Support 12 | 13 | ### 3.0.1 14 | * WPF/.NET 4.5 Support 15 | * macOS Support 16 | * tvOS Support 17 | * Move to .NET Standard 18 | * Removal of Windows Phone/Store 8/8.1 19 | 20 | ### 2.3.0 21 | * Add bluetooth connection type 22 | * Add ConnectivityTypeChanged event 23 | * Fixed #3 (Ensure connectivity manager is never null) 24 | * Fixed #6 (Android returns all connection types) 25 | * iOS 10 optimizations 26 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2017 James Montemagno 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## Connectivity Plugin for Xamarin and Windows 2 | 3 | Simple cross platform plugin to check connection status of mobile device, gather connection type, bandwidths, and more. 4 | 5 | ## Documentation 6 | Get started by reading through the [Connectivity Plugin documentation](https://jamesmontemagno.github.io/ConnectivityPlugin/). 7 | 8 | ## NuGet 9 | * Available on NuGet: [Xam.Plugin.Connectivity](http://www.nuget.org/packages/Xam.Plugin.Connectivity) [![NuGet](https://img.shields.io/nuget/v/Xam.Plugin.Connectivity.svg?label=NuGet)](https://www.nuget.org/packages/Xam.Plugin.Connectivity/) 10 | 11 | ## Build: 12 | * [![Build status](https://ci.appveyor.com/api/projects/status/k6l4x6ovp5ysfbar?svg=true)](https://ci.appveyor.com/project/JamesMontemagno/connectivityplugin) 13 | * CI NuGet Feed: https://ci.appveyor.com/nuget/connectivityplugin 14 | 15 | ### Migrate to: [Xamarin.Essentials](https://docs.microsoft.com/xamarin/essentials/index?WT.mc_id=friends-0000-jamont) or [.NET MAUI](https://learn.microsoft.com/dotnet/maui/platform-integration/?WT.mc_id=friends-0000-jamont) 16 | 17 | I have been working on Plugins for Xamarin for a long time now. Through the years I have always wanted to create a single, optimized, and official package from the Xamarin team at Microsoft that could easily be consumed by any application. The time is now with [Xamarin.Essentials](https://docs.microsoft.com/xamarin/essentials/index?WT.mc_id=friends-0000-jamont), which offers over 50 cross-platform native APIs in a single optimized package. I worked on this new library with an amazing team of developers and I highly highly highly recommend you check it out. 18 | 19 | Additionally, Xamarin.Essentials is now included in & [.NET MAUI](https://learn.microsoft.com/dotnet/maui/platform-integration/?WT.mc_id=friends-0000-jamont). 20 | 21 | Due to the functionality being included "in the box" I have decided to officially archive this repo. 22 | 23 | ## Platform Support 24 | 25 | |Platform|Version| 26 | | ------------------- | :------------------: | 27 | |Xamarin.iOS|iOS 6+| 28 | |tvOS - Apple TV|All| 29 | |Xamarin.Android|API 10+| 30 | |Windows 10 UWP|10+| 31 | |Xamarin.Mac|All| 32 | |.NET 4.5/WPF|All| 33 | |.NET Core|2.0+| 34 | |Tizen|4.0+| 35 | 36 | ### Created By: [@JamesMontemagno](http://twitter.com/jamesmontemagno) 37 | * Twitter: [@JamesMontemagno](http://twitter.com/jamesmontemagno) 38 | * Blog: [MotzCod.es](http://motzcod.es), [Micro Blog](http://motz.micro.blog) 39 | * Podcasts: [Merge Conflict](http://mergeconflict.fm), [Coffeehouse Blunders](http://blunders.fm), [The Xamarin Podcast](http://xamarinpodcast.com) 40 | * Video: [The Xamarin Show on Channel 9](http://xamarinshow.com), [YouTube Channel](https://www.youtube.com/jamesmontemagno) 41 | # Contribution 42 | 43 | Thank you for your interest in contributing to the Connectivity plugin! In this section we'll outline what you need to know about contributing and how to get started. 44 | 45 | ### Bug Fixes 46 | Please browse open issues, if you're looking to fix something, it's possible that someone already reported it. Additionally you select any `up-for-grabs` items 47 | 48 | ### Pull requests 49 | Please fill out the pull request template when you send one. 50 | Run tests to make sure your changes don't break any unit tests. Follow these instructions to run tests - 51 | 52 | **iOS** 53 | - Navigate to _tests/Connectivity.Tests.iOS_ 54 | - Execute `make run-simulator-tests` 55 | 56 | **Android** 57 | 58 | Execute `./build.sh --target RunDroidTests` from the project root 59 | ## License 60 | The MIT License (MIT) see [License file](LICENSE) 61 | 62 | ### Want To Support This Project? 63 | All I have ever asked is to be active by submitting bugs, features, and sending those pull requests down! Want to go further? Make sure to subscribe to my weekly development podcast [Merge Conflict](http://mergeconflict.fm), where I talk all about awesome Xamarin goodies and you can optionally support the show by becoming a [supporter on Patreon](https://www.patreon.com/mergeconflictfm). 64 | -------------------------------------------------------------------------------- /appveyor.yml: -------------------------------------------------------------------------------- 1 | version: 3.2.0.{build}-beta 2 | image: Visual Studio 2017 3 | configuration: Release 4 | assembly_info: 5 | patch: true 6 | file: '**\AssemblyInfo.*' 7 | assembly_version: '{version}' 8 | assembly_file_version: '{version}' 9 | assembly_informational_version: '{version}' 10 | install: 11 | - echo y | "C:\Program Files (x86)\Android\android-sdk\tools\android.bat" update sdk -u -a -t tools 12 | - echo y | "C:\Program Files (x86)\Android\android-sdk\tools\android.bat" update sdk -u -a -t platform-tools 13 | - echo y | "C:\Program Files (x86)\Android\android-sdk\tools\android.bat" update sdk -u -a -t build-tools-25.0.6 14 | - echo y | "C:\Program Files (x86)\Android\android-sdk\tools\android.bat" update sdk -u -a -t android-25 15 | - echo y | "C:\Program Files (x86)\Android\android-sdk\tools\android.bat" update sdk -u -a -t android-15 16 | build_script: 17 | - cmd: >- 18 | powershell .\build.ps1 -Target Default -Verbosity diagnostic 19 | artifacts: 20 | - path: ./Build/nuget/*.nupkg 21 | name: NuGet 22 | -------------------------------------------------------------------------------- /art/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jamesmontemagno/ConnectivityPlugin/393fabe87fd41b3fcd622308da1b6d28b34dee3f/art/icon.png -------------------------------------------------------------------------------- /build.cake: -------------------------------------------------------------------------------- 1 | var TARGET = Argument ("target", Argument ("t", "Default")); 2 | var VERSION = EnvironmentVariable ("APPVEYOR_BUILD_VERSION") ?? Argument("version", "0.0.9999"); 3 | var CONFIG = Argument("configuration", EnvironmentVariable ("CONFIGURATION") ?? "Release"); 4 | var SLN = "./src/Connectivity.sln"; 5 | var NUNIT_RESULT_PARSER = "./nunit-summary.exe"; 6 | 7 | Task("Libraries").Does(()=> 8 | { 9 | NuGetRestore (SLN); 10 | MSBuild (SLN, c => { 11 | c.Configuration = CONFIG; 12 | c.MSBuildPlatform = Cake.Common.Tools.MSBuild.MSBuildPlatform.x86; 13 | }); 14 | }); 15 | 16 | Task ("NuGet") 17 | .IsDependentOn ("Libraries") 18 | .Does (() => 19 | { 20 | if(!DirectoryExists("./Build/nuget/")) 21 | CreateDirectory("./Build/nuget"); 22 | 23 | NuGetPack ("./nuget/Plugin.nuspec", new NuGetPackSettings { 24 | Version = VERSION, 25 | OutputDirectory = "./Build/nuget/", 26 | BasePath = "./" 27 | }); 28 | }); 29 | 30 | //Build the component, which build samples, nugets, and libraries 31 | Task ("Default").IsDependentOn("NuGet"); 32 | 33 | Task ("RunDroidTests") 34 | .IsDependentOn("DownloadUnitTestTools") 35 | .Does(()=> 36 | { 37 | var outputPath = MakeAbsolute(Directory("./tests/Connectivity.Tests.Android/bin/Debug")); 38 | MSBuild("./tests/Connectivity.Tests.Android/Connectivity.Tests.Android.csproj", 39 | new MSBuildSettings() 40 | .WithProperty("MyBuildOutputPath", outputPath.ToString()) 41 | .WithTarget("SignAndroidPackage") 42 | .WithTarget("RunUnitTests")); 43 | var exe = MakeAbsolute(File(NUNIT_RESULT_PARSER)); 44 | StartProcess(exe.ToString(), outputPath.CombineWithFilePath("test-results-Debug.xml").ToString()); 45 | }); 46 | 47 | Task("DownloadUnitTestTools") 48 | .Does(()=>{ 49 | var exe = MakeAbsolute(File(NUNIT_RESULT_PARSER)); 50 | if(!FileExists(exe.ToString())) 51 | DownloadFile("https://github.com/prashantvc/nunit-summary/releases/download/0.4/nunit-summary.exe","nunit-summary.exe"); 52 | else 53 | Information("nunit-summary.exe exists"); 54 | 55 | }); 56 | 57 | Task ("Clean").Does (() => 58 | { 59 | CleanDirectory ("./component/tools/"); 60 | CleanDirectories ("./Build/"); 61 | CleanDirectories ("./**/bin"); 62 | CleanDirectories ("./**/obj"); 63 | }); 64 | 65 | RunTarget (TARGET); 66 | -------------------------------------------------------------------------------- /build.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | ########################################################################## 4 | # This is the Cake bootstrapper script for Linux and OS X. 5 | # This file was downloaded from https://github.com/cake-build/resources 6 | # Feel free to change this file to fit your needs. 7 | ########################################################################## 8 | 9 | # Define directories. 10 | SCRIPT_DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd ) 11 | TOOLS_DIR=$SCRIPT_DIR/tools 12 | NUGET_EXE=$TOOLS_DIR/nuget.exe 13 | CAKE_EXE=$TOOLS_DIR/Cake/Cake.exe 14 | PACKAGES_CONFIG=$TOOLS_DIR/packages.config 15 | PACKAGES_CONFIG_MD5=$TOOLS_DIR/packages.config.md5sum 16 | 17 | # Define md5sum or md5 depending on Linux/OSX 18 | MD5_EXE= 19 | if [[ "$(uname -s)" == "Darwin" ]]; then 20 | MD5_EXE="md5 -r" 21 | else 22 | MD5_EXE="md5sum" 23 | fi 24 | 25 | # Define default arguments. 26 | SCRIPT="build.cake" 27 | TARGET="Default" 28 | CONFIGURATION="Release" 29 | VERBOSITY="verbose" 30 | DRYRUN= 31 | SHOW_VERSION=false 32 | SCRIPT_ARGUMENTS=() 33 | 34 | # Parse arguments. 35 | for i in "$@"; do 36 | case $1 in 37 | -s|--script) SCRIPT="$2"; shift ;; 38 | -t|--target) TARGET="$2"; shift ;; 39 | -c|--configuration) CONFIGURATION="$2"; shift ;; 40 | -v|--verbosity) VERBOSITY="$2"; shift ;; 41 | -d|--dryrun) DRYRUN="-dryrun" ;; 42 | --version) SHOW_VERSION=true ;; 43 | --) shift; SCRIPT_ARGUMENTS+=("$@"); break ;; 44 | *) SCRIPT_ARGUMENTS+=("$1") ;; 45 | esac 46 | shift 47 | done 48 | 49 | # Make sure the tools folder exist. 50 | if [ ! -d "$TOOLS_DIR" ]; then 51 | mkdir "$TOOLS_DIR" 52 | fi 53 | 54 | # Make sure that packages.config exist. 55 | if [ ! -f "$TOOLS_DIR/packages.config" ]; then 56 | echo "Downloading packages.config..." 57 | curl -Lsfo "$TOOLS_DIR/packages.config" http://cakebuild.net/download/bootstrapper/packages 58 | if [ $? -ne 0 ]; then 59 | echo "An error occured while downloading packages.config." 60 | exit 1 61 | fi 62 | fi 63 | 64 | # Download NuGet if it does not exist. 65 | if [ ! -f "$NUGET_EXE" ]; then 66 | echo "Downloading NuGet..." 67 | curl -Lsfo "$NUGET_EXE" https://dist.nuget.org/win-x86-commandline/latest/nuget.exe 68 | if [ $? -ne 0 ]; then 69 | echo "An error occured while downloading nuget.exe." 70 | exit 1 71 | fi 72 | fi 73 | 74 | # Restore tools from NuGet. 75 | pushd "$TOOLS_DIR" >/dev/null 76 | if [ ! -f $PACKAGES_CONFIG_MD5 ] || [ "$( cat $PACKAGES_CONFIG_MD5 | sed 's/\r$//' )" != "$( $MD5_EXE $PACKAGES_CONFIG | awk '{ print $1 }' )" ]; then 77 | find . -type d ! -name . | xargs rm -rf 78 | fi 79 | 80 | mono "$NUGET_EXE" install -ExcludeVersion 81 | if [ $? -ne 0 ]; then 82 | echo "Could not restore NuGet packages." 83 | exit 1 84 | fi 85 | 86 | $MD5_EXE $PACKAGES_CONFIG | awk '{ print $1 }' >| $PACKAGES_CONFIG_MD5 87 | 88 | popd >/dev/null 89 | 90 | # Make sure that Cake has been installed. 91 | if [ ! -f "$CAKE_EXE" ]; then 92 | echo "Could not find Cake.exe at '$CAKE_EXE'." 93 | exit 1 94 | fi 95 | 96 | # Start Cake 97 | if $SHOW_VERSION; then 98 | exec mono "$CAKE_EXE" -version 99 | else 100 | exec mono "$CAKE_EXE" $SCRIPT -verbosity=$VERBOSITY -configuration=$CONFIGURATION -target=$TARGET $DRYRUN "${SCRIPT_ARGUMENTS[@]}" 101 | fi -------------------------------------------------------------------------------- /cake.packages.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /component/ConnectivityPlugin_128x128.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jamesmontemagno/ConnectivityPlugin/393fabe87fd41b3fcd622308da1b6d28b34dee3f/component/ConnectivityPlugin_128x128.png -------------------------------------------------------------------------------- /component/ConnectivityPlugin_512x512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jamesmontemagno/ConnectivityPlugin/393fabe87fd41b3fcd622308da1b6d28b34dee3f/component/ConnectivityPlugin_512x512.png -------------------------------------------------------------------------------- /component/Details.md: -------------------------------------------------------------------------------- 1 | # Connectivity Plugin Details 2 | 3 | Cross platform plugin to check connection status of mobile device from a single API from Xamarin.iOS, Xamarin.Android, Windows Phone, and Windows. 4 | 5 | ### Features: 6 | * Check Connection 7 | * Bandwidth speeds 8 | * Connection Types 9 | * Check if host is reachable 10 | * Subscribe to connectivity change events 11 | 12 | Works completely from shared code or PCL projects. -------------------------------------------------------------------------------- /component/GettingStarted.md: -------------------------------------------------------------------------------- 1 | # Getting Started with Connectivity Plugin 2 | 3 | 4 | 5 | 6 | ### API Usage 7 | 8 | Call **CrossConnectivity.Current** from any project or PCL to gain access to APIs. 9 | 10 | 11 | **IsConnected** 12 | ``` 13 | /// 14 | /// Gets if there is an active internet connection 15 | /// 16 | bool IsConnected { get; } 17 | ``` 18 | 19 | **ConnectionTypes** 20 | ``` 21 | /// 22 | /// Gets the list of all active connection types. 23 | /// 24 | IEnumerable ConnectionTypes { get; } 25 | ``` 26 | 27 | **Bandwidths** 28 | ``` 29 | /// 30 | /// Retrieves a list of available bandwidths for the platform. 31 | /// Only active connections. 32 | /// 33 | IEnumerable Bandwidths { get; } 34 | ``` 35 | 36 | #### Pinging Hosts 37 | 38 | **IsReachable** 39 | ``` 40 | /// 41 | /// Tests if a host name is pingable 42 | /// 43 | /// The host name can either be a machine name, such as "java.sun.com", or a textual representation of its IP address (127.0.0.1) 44 | /// Timeout in milliseconds 45 | /// 46 | Task IsReachable(string host, int msTimeout = 5000); 47 | ``` 48 | 49 | **IsRemoteReachable** 50 | ``` 51 | /// 52 | /// Tests if a remote host name is reachable 53 | /// 54 | /// Host name can be a remote IP or URL of website 55 | /// Port to attempt to check is reachable. 56 | /// Timeout in milliseconds. 57 | /// 58 | Task IsRemoteReachable(string host, int port = 80, int msTimeout = 5000); 59 | ``` 60 | 61 | #### Changes in Connectivity 62 | When any network connectivity is gained, changed, or loss you can register for an event to fire: 63 | ``` 64 | /// 65 | /// Event handler when connection changes 66 | /// 67 | event ConnectivityChangedEventHandler ConnectivityChanged; 68 | ``` 69 | 70 | You will get a ConnectivityChangeEventArgs with the status if you are connected or not: 71 | ``` 72 | public class ConnectivityChangedEventArgs : EventArgs 73 | { 74 | public bool IsConnected { get; set; } 75 | } 76 | 77 | public delegate void ConnectivityChangedEventHandler(object sender, ConnectivityChangedEventArgs e); 78 | ``` 79 | 80 | Usage sample from Xamarin.Forms: 81 | ``` 82 | CrossConnectivity.Current.ConnectivityChanged += (sender, args) => 83 | { 84 | page.DisplayAlert("Connectivity Changed", "IsConnected: " + args.IsConnected.ToString(), "OK"); 85 | }; 86 | ``` 87 | 88 | 89 | ### **IMPORTANT** 90 | Android: 91 | You must request ACCESS_NETWORK_STATE permission to get the network state 92 | You must request ACCESS_WIFI_STATE to get speeds 93 | 94 | iOS: 95 | Bandwidths is not supported and will always return an empty list. 96 | 97 | Windows 8.1 & Windows Phone 8.1 RT: 98 | RT apps can not perform loopback, so you can not use IsReachable to query the states of a local IP. 99 | 100 | Permissions to think about: 101 | The Private Networks (Client & Server) capability is represented by the Capability name = "privateNetworkClientServer" tag in the app manifest. 102 | The Internet (Client & Server) capability is represented by the Capability name = "internetClientServer" tag in the app manifest. 103 | -------------------------------------------------------------------------------- /component/License.md: -------------------------------------------------------------------------------- 1 | # ConnectivityPlugin license 2 | 3 | The MIT License (MIT) 4 | 5 | Copyright (c) 2014 James Montemagno / Refractored LLC 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining a copy of 8 | this software and associated documentation files (the "Software"), to deal in 9 | the Software without restriction, including without limitation the rights to 10 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 11 | the Software, and to permit persons to whom the Software is furnished to do so, 12 | subject to the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be included in all 15 | copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 19 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 20 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 21 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 22 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -------------------------------------------------------------------------------- /component/component.template.yaml: -------------------------------------------------------------------------------- 1 | %YAML 1.2 2 | --- 3 | version: {VERSION} 4 | name: Connectivity Plugin 5 | id: ConnectivityPlugin 6 | publisher: James Montemagno 7 | license: License.md 8 | skip_docs: true 9 | icons: 10 | - ConnectivityPlugin_128x128.png 11 | - ConnectivityPlugin_512x512.png 12 | publisher-url: http://www.github.com/jamesmontemagno/ConnectivityPlugin 13 | is_shell: true 14 | packages: 15 | ios: Xam.Plugin.Connectivity, Version={VERSION} 16 | ios-unified: Xam.Plugin.Connectivity, Version={VERSION} 17 | android: Xam.Plugin.Connectivity, Version={VERSION} 18 | winphone-8.0: Xam.Plugin.Connectivity, Version={VERSION} 19 | winphone-8.1: Xam.Plugin.Connectivity, Version={VERSION} 20 | winuniversal-10.0: Xam.Plugin.Connectivity, Version={VERSION} 21 | summary: Check connection status of mobile device, gather connection type, bandwidths, and more. 22 | details: Details.md 23 | getting-started: GettingStarted.md 24 | samples: 25 | - name: Connectivity Samples (iOS, Android, and Windows) 26 | path: "../Samples/ConnectivitySample.sln" 27 | removeProjects: 28 | - Connectivity.Plugin 29 | - Connectivity.Plugin.Abstractions 30 | - Connectivity.Plugin.Android 31 | - Connectivity.Plugin.iOSUnified 32 | - Connectivity.Plugin.WinPhone 33 | installNuGets: 34 | - project: ConnectivitySample 35 | packages: 36 | - Xam.Plugin.Connectivity 37 | - project: ConnectivitySample.iOS 38 | packages: 39 | - Xam.Plugin.Connectivity 40 | - project: ConnectivitySample.Droid 41 | packages: 42 | - Xam.Plugin.Connectivity 43 | - project: ConnectivitySample.WinPhone 44 | packages: 45 | - Xam.Plugin.Connectivity 46 | no_build: true 47 | skip_docs: true 48 | local-nuget-repo: ../Build/nuget 49 | no_build: true 50 | ... 51 | -------------------------------------------------------------------------------- /docs/Architecture.md: -------------------------------------------------------------------------------- 1 | 2 | ## Architecture 3 | 4 | I get a lot of questions about architecture and how to unit tests plugins. So here are some things to be aware of for any plugin that I publish. 5 | 6 | ### What's with this .Current Global Variable? Why can't I use $FAVORITE_IOC_LIBRARY 7 | You totally can! Every plugin I create is based on an interface. The static singleton just gives you a super simple way of gaining access to the platform implementation. Realize that the implementation of the plugin lives in your iOS, Android, Windows, etc. This means you will need to register it there by instantiating a `Cross___Implementation` from the platform specific projects. 8 | 9 | If you are using a ViewModel/IOC approach your code may look like: 10 | 11 | ```csharp 12 | public MyViewModel() 13 | { 14 | readonly IPLUGIN plugin; 15 | public MyViewModel(IPLUGIN plugin) 16 | { 17 | this.plugin = plugin; 18 | } 19 | } 20 | ``` 21 | 22 | ### What About Unit Testing? 23 | To learn about unit testing strategies be sure to read my blog: [Unit Testing Plugins for Xamarin](http://motzcod.es/post/159267241302/unit-testing-plugins-for-xamarin) 24 | 25 | 26 | <= Back to [Table of Contents](README.md) -------------------------------------------------------------------------------- /docs/CheckingConnectivity.md: -------------------------------------------------------------------------------- 1 | ## Checking Connectivity 2 | There are a few properties that can be used to easily check connection information using the plugin. 3 | 4 | ### Check Connectivity 5 | `IsConnected`: The easiest and most common use case of simply checking if there is internet access: 6 | 7 | ```csharp 8 | /// 9 | /// Gets if there is an active internet connection 10 | /// 11 | bool IsConnected { get; } 12 | ``` 13 | 14 | Example: 15 | ```csharp 16 | public async Task MakeWebRequest() 17 | { 18 | if(!CrossConnectivity.Current.IsConnected) 19 | { 20 | //You are offline, notify the user 21 | return null; 22 | } 23 | 24 | //Make web request here 25 | } 26 | ``` 27 | 28 | ### Check Type of Connection 29 | Easily check what type of internet connection is currently active. 30 | 31 | ```csharp 32 | /// 33 | /// Gets the list of all active connection types. 34 | /// 35 | IEnumerable ConnectionTypes { get; } 36 | ``` 37 | 38 | Example: 39 | ```csharp 40 | public async Task MakeWebRequestWifiOnly() 41 | { 42 | var wifi = Plugin.Connectivity.Abstractions.ConnectionType.WiFi; 43 | var connectionTypes = CrossConnectivity.Current.ConnectionTypes; 44 | if(!connectionTypes.Contains(wifi)) 45 | { 46 | //You do not have wifi 47 | return null; 48 | } 49 | 50 | //Make web request here 51 | } 52 | ``` 53 | 54 | ### Speed of Connection 55 | 56 | You can query all bandwidths of the active connections in Bits Per Second. 57 | 58 | ```csharp 59 | /// 60 | /// Retrieves a list of available bandwidths for the platform. 61 | /// Only active connections. 62 | /// 63 | IEnumerable Bandwidths { get; } 64 | ``` 65 | 66 | Example: 67 | ```csharp 68 | public async Task MakeWebRequestOneMeg() 69 | { 70 | var optimalSpeed = 1000000; //1Mbps 71 | var speeds = CrossConnectivity.Current.Bandwidths; 72 | 73 | //If on iOS or none were returned 74 | if(speeds.Length == 0) 75 | return null; 76 | 77 | if(!connectionTypes.Any(speed => speed > optimalSpeed)) 78 | { 79 | //You do not have wifi 80 | return null; 81 | } 82 | 83 | //Make web request here 84 | } 85 | ``` 86 | 87 | **Platform Tweaks**: 88 | * Apple Platforms: Bandwidths are not supported and will always return an empty list. 89 | * Android: In releases earlier than 3.0.2 this was returned as Mbps. 90 | * Android: Only returns bandwidth of WiFi connections. For all others you can check the 91 | 92 | <= Back to [Table of Contents](README.md) 93 | 94 | -------------------------------------------------------------------------------- /docs/ConnectivityChanges.md: -------------------------------------------------------------------------------- 1 | ## Detecting Connectivity Changes 2 | Often you may need to notify your user or respond based on network changes. You can do this by subscribing several different events. 3 | 4 | #### Changes in Connectivity 5 | When any network connectivity is gained, changed, or loss you can register for an event to fire: 6 | ```csharp 7 | /// 8 | /// Event handler when connection changes 9 | /// 10 | event ConnectivityChangedEventHandler ConnectivityChanged; 11 | ``` 12 | 13 | You will get a ConnectivityChangeEventArgs with the status if you are connected or not: 14 | ```csharp 15 | public class ConnectivityChangedEventArgs : EventArgs 16 | { 17 | public bool IsConnected { get; set; } 18 | } 19 | 20 | public delegate void ConnectivityChangedEventHandler(object sender, ConnectivityChangedEventArgs e); 21 | ``` 22 | 23 | ```csharp 24 | CrossConnectivity.Current.ConnectivityChanged += async (sender, args) => 25 | { 26 | Debug.WriteLine($"Connectivity changed to {args.IsConnected}"); 27 | }; 28 | ``` 29 | 30 | 31 | ### Changes in Connectivity Type 32 | When any network connectivity type is changed this event is triggered. Often it also is accompanied by a `ConnectivityChanged` event. 33 | 34 | ```csharp 35 | /// 36 | /// Event handler when connection type changes 37 | /// 38 | event ConnectivityTypeChangedEventHandler ConnectivityTypeChanged; 39 | ``` 40 | 41 | When this occurs an event will be triggered with EventArgs that have the most recent information: 42 | 43 | ```csharp 44 | public class ConnectivityTypeChangedEventArgs : EventArgs 45 | { 46 | public bool IsConnected { get; set; } 47 | public IEnumerable ConnectionTypes { get; set; } 48 | } 49 | public delegate void ConnectivityTypeChangedEventHandler(object sender, ConnectivityTypeChangedEventArgs e); 50 | ``` 51 | 52 | Example: 53 | ```csharp 54 | CrossConnectivity.Current.ConnectivityTypeChanged += async (sender, args) => 55 | { 56 | Debug.WriteLine($"Connectivity changed to {args.IsConnected}"); 57 | foreach(var t in args.ConnectionTypes) 58 | Debug.WriteLine($"Connection Type {t}"); 59 | }; 60 | ``` 61 | 62 | <= Back to [Table of Contents](README.md) -------------------------------------------------------------------------------- /docs/GettingStarted.md: -------------------------------------------------------------------------------- 1 | # Getting Started 2 | 3 | ## Setup 4 | * NuGet: [Xam.Plugin.Connectivity](http://www.nuget.org/packages/Xam.Plugin.Connectivity) [![NuGet](https://img.shields.io/nuget/v/Xam.Plugin.Connectivity.svg?label=NuGet)](https://www.nuget.org/packages/Xam.Plugin.Connectivity/) 5 | * `PM> Install-Package Xam.Plugin.Connectivity` 6 | * Install into ALL of your projects, include client projects. 7 | * namespace: `using Plugin.Connectivity;` 8 | 9 | 10 | ## Using Connectivity APIs 11 | It is drop dead simple to gain access to the Connectivity APIs in any project. All you need to do is get a reference to the current instance of IConnectivity via `CrossConnectivity.Current`: 12 | 13 | ```csharp 14 | public bool DoIHaveInternet() 15 | { 16 | return CrossConnectivity.Current.IsConnected; 17 | } 18 | ``` 19 | 20 | There may be instances where you install a plugin into a platform that it isn't supported yet. This means you will have access to the interface, but no implementation exists. You can make a simple check before calling any API to see if it is supported on the platform where the code is running. This if nifty when unit testing: 21 | 22 | ```csharp 23 | public bool DoIHaveInternet() 24 | { 25 | if(!CrossConnectivity.IsSupported) 26 | return true; 27 | 28 | return CrossConnectivity.Current.IsConnected; 29 | } 30 | ``` 31 | 32 | ## Disposing of Connectivity Plugin 33 | This plugin also implements IDisposable on all implementations. This ensure that all events are unregistered from the platform. Only dispose when you need to and are no longer listening to events. The next time you gain access to the `CrossConnectivity.Current` a new instance will be created. 34 | 35 | ```csharp 36 | public bool DoIHaveInternet() 37 | { 38 | if(!CrossConnectivity.IsSupported) 39 | return true; 40 | 41 | //Do this only if you need to and aren't listening to any other events as they will not fire. 42 | var connectivity = CrossConnectivity.Current; 43 | 44 | try 45 | { 46 | return connectivity.IsConnected; 47 | } 48 | finally 49 | { 50 | CrossConnectivity.Dispose(); 51 | } 52 | 53 | } 54 | ``` 55 | 56 | 57 | ## Permissions & Additional Setup Considerations 58 | 59 | ### Android: 60 | The `ACCESS_NETWORK_STATE` and `ACCESS_WIFI_STATE` permissions are required and are automatically added to your Android Manifest when you compile. No need to add them manually! 61 | 62 | By adding these permissions [Google Play will automatically filter out devices](http://developer.android.com/guide/topics/manifest/uses-feature-element.html#permissions-features) without specific hardware. You can get around this by adding the following to your AssemblyInfo.cs file in your Android project: 63 | 64 | ```csharp 65 | [assembly: UsesFeature("android.hardware.wifi", Required = false)] 66 | ``` 67 | 68 | 69 | <= Back to [Table of Contents](README.md) 70 | -------------------------------------------------------------------------------- /docs/PingaHost.md: -------------------------------------------------------------------------------- 1 | ## Ping a Host 2 | 3 | On occassion you may want to check not only if the device has internet, but also if an end point is available as well. 4 | 5 | 6 | #### Ping Remote Server 7 | The most common use case is to ping a remote server or remote IP address to see if it up and running. 8 | 9 | ```csharp 10 | /// 11 | /// Tests if a remote host name is reachable (no http:// or www.) 12 | /// 13 | /// Host name can be a remote IP or URL of website 14 | /// Port to attempt to check is reachable. 15 | /// Timeout in milliseconds. 16 | /// 17 | Task IsRemoteReachable(string host, int port = 80, int msTimeout = 5000); 18 | ``` 19 | 20 | Example: 21 | ```csharp 22 | public async Task IsBlogReachableAndRunning() 23 | { 24 | var connectivity = CrossConnectivity.Current; 25 | if(!connectivity.IsConnected) 26 | return false; 27 | 28 | var reachable = await connectivity.IsRemoteReachable("motzcod.es"); 29 | 30 | return reachable; 31 | } 32 | 33 | ``` 34 | 35 | ## Ping Internal Host 36 | On rarer occassions a local machine or local IP on the network may need to be pinged. 37 | 38 | ```csharp 39 | /// 40 | /// Tests if a host name is pingable 41 | /// 42 | /// The host name can either be a machine name, such as "java.sun.com", or a textual representation of its IP address (127.0.0.1) 43 | /// Timeout in milliseconds 44 | /// 45 | Task IsReachable(string host, int msTimeout = 5000); 46 | ``` 47 | 48 | <= Back to [Table of Contents](README.md) -------------------------------------------------------------------------------- /docs/README.md: -------------------------------------------------------------------------------- 1 | ## Documentation 2 | 3 | Here you will find detailed documentation on setting up and using the Connectivity Plugin for Xamarin and Windows 4 | 5 | ### Table of Contents 6 | * [Getting Started](GettingStarted.md) 7 | * [Checking Connectivity](CheckingConnectivity.md) 8 | * [Connectivity Changes](ConnectivityChanges.md) 9 | * [Ping a Host](PingaHost.md) 10 | * [Architecture](Architecture.md) -------------------------------------------------------------------------------- /docs/_config.yml: -------------------------------------------------------------------------------- 1 | theme: jekyll-theme-midnight -------------------------------------------------------------------------------- /install-android-sdk.ps1: -------------------------------------------------------------------------------- 1 | $AndroidToolPath = "${env:ProgramFiles(x86)}\Android\android-sdk\tools\android" 2 | #$AndroidToolPath = "$env:localappdata\Android\android-sdk\tools\android" 3 | 4 | Function Get-AndroidSDKs() { 5 | $output = & $AndroidToolPath list sdk --all 6 | $sdks = $output |% { 7 | if ($_ -match '(?\d+)- (?.+), revision (?[\d\.]+)') { 8 | $sdk = New-Object PSObject 9 | Add-Member -InputObject $sdk -MemberType NoteProperty -Name Index -Value $Matches.index 10 | Add-Member -InputObject $sdk -MemberType NoteProperty -Name Name -Value $Matches.sdk 11 | Add-Member -InputObject $sdk -MemberType NoteProperty -Name Revision -Value $Matches.revision 12 | $sdk 13 | } 14 | } 15 | $sdks 16 | } 17 | 18 | Function Install-AndroidSDK() { 19 | [CmdletBinding()] 20 | Param( 21 | [Parameter(Mandatory=$true, Position=0)] 22 | [PSObject[]]$sdks 23 | ) 24 | 25 | $sdkIndexes = $sdks |% { $_.Index } 26 | $sdkIndexArgument = [string]::Join(',', $sdkIndexes) 27 | Echo 'y' | & $AndroidToolPath update sdk -u -a -t $sdkIndexArgument 28 | } 29 | 30 | $sdks = Get-AndroidSDKs |? { $_.name -like 'sdk platform*API 15*' -or $_.name -like 'google apis*api 15' } 31 | Install-AndroidSDK -sdks $sdks -------------------------------------------------------------------------------- /samples/ConnectivitySample/ConnectivitySample.Droid/Assets/AboutAssets.txt: -------------------------------------------------------------------------------- 1 | Any raw assets you want to be deployed with your application can be placed in 2 | this directory (and child directories) and given a Build Action of "AndroidAsset". 3 | 4 | These files will be deployed with you package and will be accessible using Android's 5 | AssetManager, like this: 6 | 7 | public class ReadAsset : Activity 8 | { 9 | protected override void OnCreate (Bundle bundle) 10 | { 11 | base.OnCreate (bundle); 12 | 13 | InputStream input = Assets.Open ("my_asset.txt"); 14 | } 15 | } 16 | 17 | Additionally, some Android functions will automatically load asset files: 18 | 19 | Typeface tf = Typeface.CreateFromAsset (Context.Assets, "fonts/samplefont.ttf"); 20 | -------------------------------------------------------------------------------- /samples/ConnectivitySample/ConnectivitySample.Droid/MainActivity.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | using Android.App; 4 | using Android.Content.PM; 5 | using Android.Runtime; 6 | using Android.Views; 7 | using Android.Widget; 8 | using Android.OS; 9 | 10 | namespace ConnectivitySample.Droid 11 | { 12 | [Activity(Label = "ConnectivitySample", Icon = "@drawable/icon", MainLauncher = true, ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation)] 13 | public class MainActivity : global::Xamarin.Forms.Platform.Android.FormsApplicationActivity 14 | { 15 | protected override void OnCreate(Bundle bundle) 16 | { 17 | base.OnCreate(bundle); 18 | 19 | global::Xamarin.Forms.Forms.Init(this, bundle); 20 | LoadApplication(new App()); 21 | } 22 | } 23 | } 24 | 25 | -------------------------------------------------------------------------------- /samples/ConnectivitySample/ConnectivitySample.Droid/Properties/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /samples/ConnectivitySample/ConnectivitySample.Droid/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | using Android.App; 5 | 6 | // General Information about an assembly is controlled through the following 7 | // set of attributes. Change these attribute values to modify the information 8 | // associated with an assembly. 9 | [assembly: AssemblyTitle("ConnectivitySample.Droid")] 10 | [assembly: AssemblyDescription("")] 11 | [assembly: AssemblyConfiguration("")] 12 | [assembly: AssemblyCompany("")] 13 | [assembly: AssemblyProduct("ConnectivitySample.Droid")] 14 | [assembly: AssemblyCopyright("Copyright © 2014")] 15 | [assembly: AssemblyTrademark("")] 16 | [assembly: AssemblyCulture("")] 17 | [assembly: ComVisible(false)] 18 | 19 | // Version information for an assembly consists of the following four values: 20 | // 21 | // Major Version 22 | // Minor Version 23 | // Build Number 24 | // Revision 25 | // 26 | // You can specify all the values or you can default the Build and Revision Numbers 27 | // by using the '*' as shown below: 28 | // [assembly: AssemblyVersion("1.0.*")] 29 | [assembly: AssemblyVersion("1.0.0.0")] 30 | [assembly: AssemblyFileVersion("1.0.0.0")] 31 | 32 | // Add some common permissions, these can be removed if not needed 33 | [assembly: UsesPermission(Android.Manifest.Permission.Internet)] 34 | [assembly: UsesPermission(Android.Manifest.Permission.WriteExternalStorage)] 35 | -------------------------------------------------------------------------------- /samples/ConnectivitySample/ConnectivitySample.Droid/Resources/AboutResources.txt: -------------------------------------------------------------------------------- 1 | Images, layout descriptions, binary blobs and string dictionaries can be included 2 | in your application as resource files. Various Android APIs are designed to 3 | operate on the resource IDs instead of dealing with images, strings or binary blobs 4 | directly. 5 | 6 | For example, a sample Android app that contains a user interface layout (main.xml), 7 | an internationalization string table (strings.xml) and some icons (drawable-XXX/icon.png) 8 | would keep its resources in the "Resources" directory of the application: 9 | 10 | Resources/ 11 | drawable-hdpi/ 12 | icon.png 13 | 14 | drawable-ldpi/ 15 | icon.png 16 | 17 | drawable-mdpi/ 18 | icon.png 19 | 20 | layout/ 21 | main.xml 22 | 23 | values/ 24 | strings.xml 25 | 26 | In order to get the build system to recognize Android resources, set the build action to 27 | "AndroidResource". The native Android APIs do not operate directly with filenames, but 28 | instead operate on resource IDs. When you compile an Android application that uses resources, 29 | the build system will package the resources for distribution and generate a class called 30 | "Resource" that contains the tokens for each one of the resources included. For example, 31 | for the above Resources layout, this is what the Resource class would expose: 32 | 33 | public class Resource { 34 | public class drawable { 35 | public const int icon = 0x123; 36 | } 37 | 38 | public class layout { 39 | public const int main = 0x456; 40 | } 41 | 42 | public class strings { 43 | public const int first_string = 0xabc; 44 | public const int second_string = 0xbcd; 45 | } 46 | } 47 | 48 | You would then use R.drawable.icon to reference the drawable/icon.png file, or Resource.layout.main 49 | to reference the layout/main.xml file, or Resource.strings.first_string to reference the first 50 | string in the dictionary file values/strings.xml. 51 | -------------------------------------------------------------------------------- /samples/ConnectivitySample/ConnectivitySample.Droid/Resources/drawable-hdpi/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jamesmontemagno/ConnectivityPlugin/393fabe87fd41b3fcd622308da1b6d28b34dee3f/samples/ConnectivitySample/ConnectivitySample.Droid/Resources/drawable-hdpi/icon.png -------------------------------------------------------------------------------- /samples/ConnectivitySample/ConnectivitySample.Droid/Resources/drawable-xhdpi/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jamesmontemagno/ConnectivityPlugin/393fabe87fd41b3fcd622308da1b6d28b34dee3f/samples/ConnectivitySample/ConnectivitySample.Droid/Resources/drawable-xhdpi/icon.png -------------------------------------------------------------------------------- /samples/ConnectivitySample/ConnectivitySample.Droid/Resources/drawable-xxhdpi/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jamesmontemagno/ConnectivityPlugin/393fabe87fd41b3fcd622308da1b6d28b34dee3f/samples/ConnectivitySample/ConnectivitySample.Droid/Resources/drawable-xxhdpi/icon.png -------------------------------------------------------------------------------- /samples/ConnectivitySample/ConnectivitySample.Droid/Resources/drawable/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jamesmontemagno/ConnectivityPlugin/393fabe87fd41b3fcd622308da1b6d28b34dee3f/samples/ConnectivitySample/ConnectivitySample.Droid/Resources/drawable/icon.png -------------------------------------------------------------------------------- /samples/ConnectivitySample/ConnectivitySample.Droid/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /samples/ConnectivitySample/ConnectivitySample.WinPhone/App.xaml: -------------------------------------------------------------------------------- 1 |  7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /samples/ConnectivitySample/ConnectivitySample.WinPhone/Assets/AlignmentGrid.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jamesmontemagno/ConnectivityPlugin/393fabe87fd41b3fcd622308da1b6d28b34dee3f/samples/ConnectivitySample/ConnectivitySample.WinPhone/Assets/AlignmentGrid.png -------------------------------------------------------------------------------- /samples/ConnectivitySample/ConnectivitySample.WinPhone/Assets/ApplicationIcon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jamesmontemagno/ConnectivityPlugin/393fabe87fd41b3fcd622308da1b6d28b34dee3f/samples/ConnectivitySample/ConnectivitySample.WinPhone/Assets/ApplicationIcon.png -------------------------------------------------------------------------------- /samples/ConnectivitySample/ConnectivitySample.WinPhone/Assets/Tiles/FlipCycleTileLarge.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jamesmontemagno/ConnectivityPlugin/393fabe87fd41b3fcd622308da1b6d28b34dee3f/samples/ConnectivitySample/ConnectivitySample.WinPhone/Assets/Tiles/FlipCycleTileLarge.png -------------------------------------------------------------------------------- /samples/ConnectivitySample/ConnectivitySample.WinPhone/Assets/Tiles/FlipCycleTileMedium.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jamesmontemagno/ConnectivityPlugin/393fabe87fd41b3fcd622308da1b6d28b34dee3f/samples/ConnectivitySample/ConnectivitySample.WinPhone/Assets/Tiles/FlipCycleTileMedium.png -------------------------------------------------------------------------------- /samples/ConnectivitySample/ConnectivitySample.WinPhone/Assets/Tiles/FlipCycleTileSmall.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jamesmontemagno/ConnectivityPlugin/393fabe87fd41b3fcd622308da1b6d28b34dee3f/samples/ConnectivitySample/ConnectivitySample.WinPhone/Assets/Tiles/FlipCycleTileSmall.png -------------------------------------------------------------------------------- /samples/ConnectivitySample/ConnectivitySample.WinPhone/Assets/Tiles/IconicTileMediumLarge.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jamesmontemagno/ConnectivityPlugin/393fabe87fd41b3fcd622308da1b6d28b34dee3f/samples/ConnectivitySample/ConnectivitySample.WinPhone/Assets/Tiles/IconicTileMediumLarge.png -------------------------------------------------------------------------------- /samples/ConnectivitySample/ConnectivitySample.WinPhone/Assets/Tiles/IconicTileSmall.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jamesmontemagno/ConnectivityPlugin/393fabe87fd41b3fcd622308da1b6d28b34dee3f/samples/ConnectivitySample/ConnectivitySample.WinPhone/Assets/Tiles/IconicTileSmall.png -------------------------------------------------------------------------------- /samples/ConnectivitySample/ConnectivitySample.WinPhone/LocalizedStrings.cs: -------------------------------------------------------------------------------- 1 | using ConnectivitySample.WinPhone.Resources; 2 | 3 | namespace ConnectivitySample.WinPhone 4 | { 5 | /// 6 | /// Provides access to string resources. 7 | /// 8 | public class LocalizedStrings 9 | { 10 | private static AppResources _localizedResources = new AppResources(); 11 | 12 | public AppResources LocalizedResources { get { return _localizedResources; } } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /samples/ConnectivitySample/ConnectivitySample.WinPhone/MainPage.xaml: -------------------------------------------------------------------------------- 1 |  16 | 17 | -------------------------------------------------------------------------------- /samples/ConnectivitySample/ConnectivitySample.WinPhone/MainPage.xaml.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Net; 5 | using System.Windows; 6 | using System.Windows.Controls; 7 | using System.Windows.Navigation; 8 | using Microsoft.Phone.Controls; 9 | using Microsoft.Phone.Shell; 10 | 11 | namespace ConnectivitySample.WinPhone 12 | { 13 | public partial class MainPage : global::Xamarin.Forms.Platform.WinPhone.FormsApplicationPage 14 | { 15 | public MainPage() 16 | { 17 | InitializeComponent(); 18 | SupportedOrientations = SupportedPageOrientation.PortraitOrLandscape; 19 | 20 | global::Xamarin.Forms.Forms.Init(); 21 | LoadApplication(new ConnectivitySample.App()); 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /samples/ConnectivitySample/ConnectivitySample.WinPhone/Properties/AppManifest.xml: -------------------------------------------------------------------------------- 1 |  4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /samples/ConnectivitySample/ConnectivitySample.WinPhone/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | using System.Resources; 5 | 6 | // General Information about an assembly is controlled through the following 7 | // set of attributes. Change these attribute values to modify the information 8 | // associated with an assembly. 9 | [assembly: AssemblyTitle("ConnectivitySample.WinPhone")] 10 | [assembly: AssemblyDescription("")] 11 | [assembly: AssemblyConfiguration("")] 12 | [assembly: AssemblyCompany("")] 13 | [assembly: AssemblyProduct("ConnectivitySample.WinPhone")] 14 | [assembly: AssemblyCopyright("Copyright © 2014")] 15 | [assembly: AssemblyTrademark("")] 16 | [assembly: AssemblyCulture("")] 17 | 18 | // Setting ComVisible to false makes the types in this assembly not visible 19 | // to COM components. If you need to access a type in this assembly from 20 | // COM, set the ComVisible attribute to true on that type. 21 | [assembly: ComVisible(false)] 22 | 23 | // The following GUID is for the ID of the typelib if this project is exposed to COM 24 | [assembly: Guid("65077432-0c92-466b-b68d-911a8ec84f1d")] 25 | 26 | // Version information for an assembly consists of the following four values: 27 | // 28 | // Major Version 29 | // Minor Version 30 | // Build Number 31 | // Revision 32 | // 33 | // You can specify all the values or you can default the Revision and Build Numbers 34 | // by using the '*' as shown below: 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | [assembly: NeutralResourcesLanguageAttribute("en-US")] 38 | -------------------------------------------------------------------------------- /samples/ConnectivitySample/ConnectivitySample.WinPhone/Properties/WMAppManifest.xml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | Assets\ApplicationIcon.png 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | Assets\Tiles\FlipCycleTileSmall.png 21 | 0 22 | Assets\Tiles\FlipCycleTileMedium.png 23 | ConnectivitySample.WinPhone 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /samples/ConnectivitySample/ConnectivitySample.WinPhone/README_FIRST.txt: -------------------------------------------------------------------------------- 1 | For the Windows Phone toolkit make sure that you have 2 | marked the icons in the "Toolkit.Content" folder as content. That way they 3 | can be used as the icons for the ApplicationBar control. -------------------------------------------------------------------------------- /samples/ConnectivitySample/ConnectivitySample.WinPhone/SplashScreenImage.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jamesmontemagno/ConnectivityPlugin/393fabe87fd41b3fcd622308da1b6d28b34dee3f/samples/ConnectivitySample/ConnectivitySample.WinPhone/SplashScreenImage.jpg -------------------------------------------------------------------------------- /samples/ConnectivitySample/ConnectivitySample.WinPhone/Toolkit.Content/ApplicationBar.Add.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jamesmontemagno/ConnectivityPlugin/393fabe87fd41b3fcd622308da1b6d28b34dee3f/samples/ConnectivitySample/ConnectivitySample.WinPhone/Toolkit.Content/ApplicationBar.Add.png -------------------------------------------------------------------------------- /samples/ConnectivitySample/ConnectivitySample.WinPhone/Toolkit.Content/ApplicationBar.Cancel.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jamesmontemagno/ConnectivityPlugin/393fabe87fd41b3fcd622308da1b6d28b34dee3f/samples/ConnectivitySample/ConnectivitySample.WinPhone/Toolkit.Content/ApplicationBar.Cancel.png -------------------------------------------------------------------------------- /samples/ConnectivitySample/ConnectivitySample.WinPhone/Toolkit.Content/ApplicationBar.Check.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jamesmontemagno/ConnectivityPlugin/393fabe87fd41b3fcd622308da1b6d28b34dee3f/samples/ConnectivitySample/ConnectivitySample.WinPhone/Toolkit.Content/ApplicationBar.Check.png -------------------------------------------------------------------------------- /samples/ConnectivitySample/ConnectivitySample.WinPhone/Toolkit.Content/ApplicationBar.Delete.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jamesmontemagno/ConnectivityPlugin/393fabe87fd41b3fcd622308da1b6d28b34dee3f/samples/ConnectivitySample/ConnectivitySample.WinPhone/Toolkit.Content/ApplicationBar.Delete.png -------------------------------------------------------------------------------- /samples/ConnectivitySample/ConnectivitySample.WinPhone/Toolkit.Content/ApplicationBar.Select.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jamesmontemagno/ConnectivityPlugin/393fabe87fd41b3fcd622308da1b6d28b34dee3f/samples/ConnectivitySample/ConnectivitySample.WinPhone/Toolkit.Content/ApplicationBar.Select.png -------------------------------------------------------------------------------- /samples/ConnectivitySample/ConnectivitySample.WinPhone/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /samples/ConnectivitySample/ConnectivitySample.iOS/AppDelegate.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | 5 | using Foundation; 6 | using UIKit; 7 | 8 | namespace ConnectivitySample.iOS 9 | { 10 | // The UIApplicationDelegate for the application. This class is responsible for launching the 11 | // User Interface of the application, as well as listening (and optionally responding) to 12 | // application events from iOS. 13 | [Register("AppDelegate")] 14 | public partial class AppDelegate : global::Xamarin.Forms.Platform.iOS.FormsApplicationDelegate 15 | { 16 | // 17 | // This method is invoked when the application has loaded and is ready to run. In this 18 | // method you should instantiate the window, load the UI into it and then make the window 19 | // visible. 20 | // 21 | // You have 17 seconds to return from this method, or iOS will terminate your application. 22 | // 23 | public override bool FinishedLaunching(UIApplication app, NSDictionary options) 24 | { 25 | global::Xamarin.Forms.Forms.Init(); 26 | LoadApplication(new App()); 27 | 28 | return base.FinishedLaunching(app, options); 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /samples/ConnectivitySample/ConnectivitySample.iOS/Entitlements.plist: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /samples/ConnectivitySample/ConnectivitySample.iOS/Info.plist: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | UIDeviceFamily 6 | 7 | 1 8 | 2 9 | 10 | UISupportedInterfaceOrientations 11 | 12 | UIInterfaceOrientationPortrait 13 | UIInterfaceOrientationLandscapeLeft 14 | UIInterfaceOrientationLandscapeRight 15 | 16 | UISupportedInterfaceOrientations~ipad 17 | 18 | UIInterfaceOrientationPortrait 19 | UIInterfaceOrientationPortraitUpsideDown 20 | UIInterfaceOrientationLandscapeLeft 21 | UIInterfaceOrientationLandscapeRight 22 | 23 | MinimumOSVersion 24 | 6.0 25 | CFBundleDisplayName 26 | ConnectivitySample 27 | CFBundleIdentifier 28 | com.yourcompany.ConnectivitySample 29 | CFBundleVersion 30 | 1.0 31 | CFBundleIconFiles 32 | 33 | Icon-60@2x 34 | Icon-60@3x 35 | Icon-76 36 | Icon-76@2x 37 | Default 38 | Default@2x 39 | Default-568h@2x 40 | Default-Portrait 41 | Default-Portrait@2x 42 | Icon-Small-40 43 | Icon-Small-40@2x 44 | Icon-Small-40@3x 45 | Icon-Small 46 | Icon-Small@2x 47 | Icon-Small@3x 48 | 49 | UILaunchStoryboardName 50 | LaunchScreen 51 | 52 | 53 | -------------------------------------------------------------------------------- /samples/ConnectivitySample/ConnectivitySample.iOS/Main.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | 5 | using Foundation; 6 | using UIKit; 7 | 8 | namespace ConnectivitySample.iOS 9 | { 10 | public class Application 11 | { 12 | // This is the main entry point of the application. 13 | static void Main(string[] args) 14 | { 15 | // if you want to use a different Application Delegate class from "AppDelegate" 16 | // you can specify it here. 17 | UIApplication.Main(args, null, "AppDelegate"); 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /samples/ConnectivitySample/ConnectivitySample.iOS/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("ConnectivitySample.iOS")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("ConnectivitySample.iOS")] 13 | [assembly: AssemblyCopyright("Copyright © 2014")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("72bdc44f-c588-44f3-b6df-9aace7daafdd")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /samples/ConnectivitySample/ConnectivitySample.iOS/Resources/Default-568h@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jamesmontemagno/ConnectivityPlugin/393fabe87fd41b3fcd622308da1b6d28b34dee3f/samples/ConnectivitySample/ConnectivitySample.iOS/Resources/Default-568h@2x.png -------------------------------------------------------------------------------- /samples/ConnectivitySample/ConnectivitySample.iOS/Resources/Default-Portrait.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jamesmontemagno/ConnectivityPlugin/393fabe87fd41b3fcd622308da1b6d28b34dee3f/samples/ConnectivitySample/ConnectivitySample.iOS/Resources/Default-Portrait.png -------------------------------------------------------------------------------- /samples/ConnectivitySample/ConnectivitySample.iOS/Resources/Default-Portrait@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jamesmontemagno/ConnectivityPlugin/393fabe87fd41b3fcd622308da1b6d28b34dee3f/samples/ConnectivitySample/ConnectivitySample.iOS/Resources/Default-Portrait@2x.png -------------------------------------------------------------------------------- /samples/ConnectivitySample/ConnectivitySample.iOS/Resources/Default.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jamesmontemagno/ConnectivityPlugin/393fabe87fd41b3fcd622308da1b6d28b34dee3f/samples/ConnectivitySample/ConnectivitySample.iOS/Resources/Default.png -------------------------------------------------------------------------------- /samples/ConnectivitySample/ConnectivitySample.iOS/Resources/Default@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jamesmontemagno/ConnectivityPlugin/393fabe87fd41b3fcd622308da1b6d28b34dee3f/samples/ConnectivitySample/ConnectivitySample.iOS/Resources/Default@2x.png -------------------------------------------------------------------------------- /samples/ConnectivitySample/ConnectivitySample.iOS/Resources/Icon-60@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jamesmontemagno/ConnectivityPlugin/393fabe87fd41b3fcd622308da1b6d28b34dee3f/samples/ConnectivitySample/ConnectivitySample.iOS/Resources/Icon-60@2x.png -------------------------------------------------------------------------------- /samples/ConnectivitySample/ConnectivitySample.iOS/Resources/Icon-60@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jamesmontemagno/ConnectivityPlugin/393fabe87fd41b3fcd622308da1b6d28b34dee3f/samples/ConnectivitySample/ConnectivitySample.iOS/Resources/Icon-60@3x.png -------------------------------------------------------------------------------- /samples/ConnectivitySample/ConnectivitySample.iOS/Resources/Icon-76.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jamesmontemagno/ConnectivityPlugin/393fabe87fd41b3fcd622308da1b6d28b34dee3f/samples/ConnectivitySample/ConnectivitySample.iOS/Resources/Icon-76.png -------------------------------------------------------------------------------- /samples/ConnectivitySample/ConnectivitySample.iOS/Resources/Icon-76@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jamesmontemagno/ConnectivityPlugin/393fabe87fd41b3fcd622308da1b6d28b34dee3f/samples/ConnectivitySample/ConnectivitySample.iOS/Resources/Icon-76@2x.png -------------------------------------------------------------------------------- /samples/ConnectivitySample/ConnectivitySample.iOS/Resources/Icon-Small-40.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jamesmontemagno/ConnectivityPlugin/393fabe87fd41b3fcd622308da1b6d28b34dee3f/samples/ConnectivitySample/ConnectivitySample.iOS/Resources/Icon-Small-40.png -------------------------------------------------------------------------------- /samples/ConnectivitySample/ConnectivitySample.iOS/Resources/Icon-Small-40@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jamesmontemagno/ConnectivityPlugin/393fabe87fd41b3fcd622308da1b6d28b34dee3f/samples/ConnectivitySample/ConnectivitySample.iOS/Resources/Icon-Small-40@2x.png -------------------------------------------------------------------------------- /samples/ConnectivitySample/ConnectivitySample.iOS/Resources/Icon-Small-40@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jamesmontemagno/ConnectivityPlugin/393fabe87fd41b3fcd622308da1b6d28b34dee3f/samples/ConnectivitySample/ConnectivitySample.iOS/Resources/Icon-Small-40@3x.png -------------------------------------------------------------------------------- /samples/ConnectivitySample/ConnectivitySample.iOS/Resources/Icon-Small.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jamesmontemagno/ConnectivityPlugin/393fabe87fd41b3fcd622308da1b6d28b34dee3f/samples/ConnectivitySample/ConnectivitySample.iOS/Resources/Icon-Small.png -------------------------------------------------------------------------------- /samples/ConnectivitySample/ConnectivitySample.iOS/Resources/Icon-Small@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jamesmontemagno/ConnectivityPlugin/393fabe87fd41b3fcd622308da1b6d28b34dee3f/samples/ConnectivitySample/ConnectivitySample.iOS/Resources/Icon-Small@2x.png -------------------------------------------------------------------------------- /samples/ConnectivitySample/ConnectivitySample.iOS/Resources/Icon-Small@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jamesmontemagno/ConnectivityPlugin/393fabe87fd41b3fcd622308da1b6d28b34dee3f/samples/ConnectivitySample/ConnectivitySample.iOS/Resources/Icon-Small@3x.png -------------------------------------------------------------------------------- /samples/ConnectivitySample/ConnectivitySample.iOS/Resources/LaunchScreen.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | -------------------------------------------------------------------------------- /samples/ConnectivitySample/ConnectivitySample.iOS/iTunesArtwork: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jamesmontemagno/ConnectivityPlugin/393fabe87fd41b3fcd622308da1b6d28b34dee3f/samples/ConnectivitySample/ConnectivitySample.iOS/iTunesArtwork -------------------------------------------------------------------------------- /samples/ConnectivitySample/ConnectivitySample.iOS/iTunesArtwork@2x: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jamesmontemagno/ConnectivityPlugin/393fabe87fd41b3fcd622308da1b6d28b34dee3f/samples/ConnectivitySample/ConnectivitySample.iOS/iTunesArtwork@2x -------------------------------------------------------------------------------- /samples/ConnectivitySample/ConnectivitySample.iOS/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /samples/ConnectivitySample/ConnectivitySample/App.cs: -------------------------------------------------------------------------------- 1 | using Plugin.Connectivity; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Text; 6 | using Xamarin.Forms; 7 | 8 | namespace ConnectivitySample 9 | { 10 | public class App : Application 11 | { 12 | static ContentPage page; 13 | public App() 14 | { 15 | var connectivityButton = new Button 16 | { 17 | Text = "Connectivity Test" 18 | }; 19 | 20 | var connected = new Label 21 | { 22 | Text = "Is Connected: " 23 | }; 24 | 25 | var connectionTypes = new Label 26 | { 27 | Text = "Connection Types: " 28 | }; 29 | 30 | var bandwidths = new Label 31 | { 32 | Text = "Bandwidths" 33 | }; 34 | 35 | var host = new Entry 36 | { 37 | Text = "127.0.0.1" 38 | }; 39 | 40 | var host2 = new Entry 41 | { 42 | Text = "montemagno.com" 43 | }; 44 | 45 | var port = new Entry 46 | { 47 | Text = "80", 48 | Keyboard = Keyboard.Numeric 49 | }; 50 | 51 | var canReach1 = new Label 52 | { 53 | Text = "Can reach1: " 54 | }; 55 | 56 | var canReach2 = new Label 57 | { 58 | Text = "Can reach2: " 59 | }; 60 | 61 | connectivityButton.Clicked += async (sender, args) => 62 | { 63 | connected.Text = CrossConnectivity.Current.IsConnected ? "Connected" : "No Connection"; 64 | bandwidths.Text = "Bandwidths: "; 65 | foreach (var band in CrossConnectivity.Current.Bandwidths) 66 | { 67 | bandwidths.Text += band.ToString() + ", "; 68 | } 69 | connectionTypes.Text = "ConnectionTypes: "; 70 | foreach (var band in CrossConnectivity.Current.ConnectionTypes) 71 | { 72 | connectionTypes.Text += band.ToString() + ", "; 73 | } 74 | 75 | try 76 | { 77 | canReach1.Text = await CrossConnectivity.Current.IsReachable(host.Text) ? "Reachable" : "Not reachable"; 78 | } 79 | catch (Exception ex) 80 | { 81 | } 82 | try 83 | { 84 | canReach2.Text = await CrossConnectivity.Current.IsRemoteReachable(host2.Text, int.Parse(port.Text)) ? "Reachable" : "Not reachable"; 85 | } 86 | catch (Exception ex) 87 | { 88 | } 89 | }; 90 | 91 | CrossConnectivity.Current.ConnectivityChanged += (sender, args) => 92 | { 93 | page.DisplayAlert("Connectivity Changed", "IsConnected: " + CrossConnectivity.Current.IsConnected + " Args:" + args.IsConnected.ToString(), "OK"); 94 | }; 95 | 96 | CrossConnectivity.Current.ConnectivityTypeChanged += (sender, args) => 97 | { 98 | page.DisplayAlert("Connectivity Type Changed", "Types: " + args.ConnectionTypes.FirstOrDefault(), "OK"); 99 | }; 100 | 101 | // The root page of your application 102 | MainPage = page = new ContentPage 103 | { 104 | Content = new StackLayout 105 | { 106 | Padding = 50, 107 | VerticalOptions = LayoutOptions.Center, 108 | Children = 109 | { 110 | connectivityButton, 111 | connected, 112 | bandwidths, 113 | connectionTypes, 114 | host, 115 | host2, 116 | port, 117 | canReach1, 118 | canReach2, 119 | } 120 | } 121 | }; 122 | } 123 | 124 | protected override void OnStart() 125 | { 126 | // Handle when your app starts 127 | } 128 | 129 | protected override void OnSleep() 130 | { 131 | // Handle when your app sleeps 132 | } 133 | 134 | protected override void OnResume() 135 | { 136 | // Handle when your app resumes 137 | } 138 | } 139 | } 140 | -------------------------------------------------------------------------------- /samples/ConnectivitySample/ConnectivitySample/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Resources; 2 | using System.Reflection; 3 | using System.Runtime.CompilerServices; 4 | using System.Runtime.InteropServices; 5 | 6 | // General Information about an assembly is controlled through the following 7 | // set of attributes. Change these attribute values to modify the information 8 | // associated with an assembly. 9 | [assembly: AssemblyTitle("ConnectivitySample")] 10 | [assembly: AssemblyDescription("")] 11 | [assembly: AssemblyConfiguration("")] 12 | [assembly: AssemblyCompany("")] 13 | [assembly: AssemblyProduct("ConnectivitySample")] 14 | [assembly: AssemblyCopyright("Copyright © 2014")] 15 | [assembly: AssemblyTrademark("")] 16 | [assembly: AssemblyCulture("")] 17 | [assembly: NeutralResourcesLanguage("en")] 18 | 19 | // Version information for an assembly consists of the following four values: 20 | // 21 | // Major Version 22 | // Minor Version 23 | // Build Number 24 | // Revision 25 | // 26 | // You can specify all the values or you can default the Build and Revision Numbers 27 | // by using the '*' as shown below: 28 | // [assembly: AssemblyVersion("1.0.*")] 29 | [assembly: AssemblyVersion("1.0.0.0")] 30 | [assembly: AssemblyFileVersion("1.0.0.0")] 31 | -------------------------------------------------------------------------------- /samples/ConnectivitySample/ConnectivitySample/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /src/Connectivity.Plugin.Abstractions/BaseConnectivity.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Threading.Tasks; 4 | 5 | namespace Plugin.Connectivity.Abstractions 6 | { 7 | /// 8 | /// Base class for all connectivity classes 9 | /// 10 | public abstract class BaseConnectivity : IConnectivity, IDisposable 11 | { 12 | /// 13 | /// Gets if there is an active internet connection 14 | /// 15 | public abstract bool IsConnected 16 | { 17 | get; 18 | } 19 | 20 | /// 21 | /// Tests if a host name is pingable 22 | /// 23 | /// The host name can either be a machine name, such as "java.sun.com", or a textual representation of its IP address (127.0.0.1) 24 | /// Timeout in milliseconds 25 | /// 26 | public abstract Task IsReachable(string host, int msTimeout = 5000); 27 | 28 | /// 29 | /// Tests if a remote host name is reachable 30 | /// 31 | /// Host name can be a remote IP or URL of website 32 | /// Port to attempt to check is reachable. 33 | /// Timeout in milliseconds. 34 | /// 35 | public abstract Task IsRemoteReachable(string host, int port = 80, int msTimeout = 5000); 36 | 37 | /// 38 | /// Gets the list of all active connection types. 39 | /// 40 | public abstract IEnumerable ConnectionTypes 41 | { 42 | get; 43 | } 44 | 45 | /// 46 | /// Retrieves a list of available bandwidths for the platform. 47 | /// Only active connections. 48 | /// 49 | public abstract IEnumerable Bandwidths 50 | { 51 | get; 52 | } 53 | 54 | /// 55 | /// When connectivity changes 56 | /// 57 | /// 58 | protected virtual void OnConnectivityChanged(ConnectivityChangedEventArgs e) => 59 | ConnectivityChanged?.Invoke(this, e); 60 | 61 | /// 62 | /// When connectivity type changes 63 | /// 64 | /// 65 | protected virtual void OnConnectivityTypeChanged(ConnectivityTypeChangedEventArgs e) => 66 | ConnectivityTypeChanged?.Invoke(this, e); 67 | 68 | /// 69 | /// Connectivity event 70 | /// 71 | public event ConnectivityChangedEventHandler ConnectivityChanged; 72 | 73 | /// 74 | /// Connectivity type changed event 75 | /// 76 | public event ConnectivityTypeChangedEventHandler ConnectivityTypeChanged; 77 | 78 | 79 | /// 80 | /// Dispose of class and parent classes 81 | /// 82 | public void Dispose() 83 | { 84 | Dispose(true); 85 | GC.SuppressFinalize(this); 86 | } 87 | 88 | /// 89 | /// Dispose up 90 | /// 91 | ~BaseConnectivity() 92 | { 93 | Dispose(false); 94 | } 95 | private bool disposed = false; 96 | /// 97 | /// Dispose method 98 | /// 99 | /// 100 | public virtual void Dispose(bool disposing) 101 | { 102 | if (!disposed) 103 | { 104 | if (disposing) 105 | { 106 | //dispose only 107 | } 108 | 109 | disposed = true; 110 | } 111 | } 112 | } 113 | } 114 | -------------------------------------------------------------------------------- /src/Connectivity.Plugin.Abstractions/ConnectionType.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace Plugin.Connectivity.Abstractions 8 | { 9 | /// 10 | /// Type of connection 11 | /// 12 | public enum ConnectionType 13 | { 14 | /// 15 | /// Cellular connection, 3G, Edge, 4G, LTE 16 | /// 17 | Cellular, 18 | /// 19 | /// Wifi connection 20 | /// 21 | WiFi, 22 | /// 23 | /// Desktop or ethernet connection 24 | /// 25 | Desktop, 26 | /// 27 | /// Wimax (only android) 28 | /// 29 | Wimax, 30 | /// 31 | /// Other type of connection 32 | /// 33 | Other, 34 | /// 35 | /// Bluetooth connection 36 | /// 37 | Bluetooth 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/Connectivity.Plugin.Abstractions/Connectivity.Plugin.Abstractions.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | netstandard1.0 5 | Plugin.Connectivity.Abstractions 6 | Plugin.Connectivity.Abstractions 7 | 1.0.0.0 8 | 1.0.0.0 9 | 1.0.0.0 10 | 11 | 12 | 13 | bin\Release\netstandard1.0\Plugin.Connectivity.Abstractions.xml 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /src/Connectivity.Plugin.Abstractions/IConnectivity.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Threading.Tasks; 4 | /* 5 | * Ported with permission from: Thomasz Cielecki @Cheesebaron 6 | * Connectivity: https://github.com/Cheesebaron/Cheesebaron.MvxPlugins 7 | */ 8 | namespace Plugin.Connectivity.Abstractions 9 | { 10 | /// 11 | /// Interface for Connectivity 12 | /// 13 | public interface IConnectivity : IDisposable 14 | { 15 | /// 16 | /// Gets if there is an active internet connection 17 | /// 18 | bool IsConnected { get; } 19 | /// 20 | /// Tests if a host name is pingable 21 | /// 22 | /// The host name can either be a machine name, such as "java.sun.com", or a textual representation of its IP address (127.0.0.1) 23 | /// Timeout in milliseconds 24 | /// 25 | Task IsReachable(string host, int msTimeout = 5000); 26 | /// 27 | /// Tests if a remote host name is reachable 28 | /// 29 | /// Host name can be a remote IP or URL of website 30 | /// Port to attempt to check is reachable. 31 | /// Timeout in milliseconds. 32 | /// 33 | Task IsRemoteReachable(string host, int port = 80, int msTimeout = 5000); 34 | /// 35 | /// Gets the list of all active connection types. 36 | /// 37 | IEnumerable ConnectionTypes { get; } 38 | /// 39 | /// Retrieves a list of available bandwidths for the platform. 40 | /// Only active connections. 41 | /// 42 | IEnumerable Bandwidths { get; } 43 | 44 | /// 45 | /// Event handler when connection changes 46 | /// 47 | event ConnectivityChangedEventHandler ConnectivityChanged; 48 | 49 | /// 50 | /// Event handler when connection type changes 51 | /// 52 | event ConnectivityTypeChangedEventHandler ConnectivityTypeChanged; 53 | } 54 | 55 | /// 56 | /// Arguments to pass to event handlers 57 | /// 58 | public class ConnectivityChangedEventArgs : EventArgs 59 | { 60 | /// 61 | /// Gets if there is an active internet connection 62 | /// 63 | public bool IsConnected { get; set; } 64 | } 65 | 66 | /// 67 | /// Arguments to pass to connectivity type changed event handlers 68 | /// 69 | public class ConnectivityTypeChangedEventArgs : EventArgs 70 | { 71 | /// 72 | /// Gets if there is an active internet connection 73 | /// 74 | public bool IsConnected { get; set; } 75 | 76 | /// 77 | /// Gets the list of all active connection types. 78 | /// 79 | public IEnumerable ConnectionTypes { get; set; } 80 | } 81 | 82 | /// 83 | /// Connectivity changed event handlers 84 | /// 85 | /// 86 | /// 87 | public delegate void ConnectivityChangedEventHandler(object sender, ConnectivityChangedEventArgs e); 88 | 89 | /// 90 | /// Connectivity type changed event handlers 91 | /// 92 | /// 93 | /// 94 | public delegate void ConnectivityTypeChangedEventHandler(object sender, ConnectivityTypeChangedEventArgs e); 95 | } 96 | -------------------------------------------------------------------------------- /src/Connectivity.Plugin.Android/Connectivity.Plugin.Android.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | Debug 5 | AnyCPU 6 | 8.0.30703 7 | 2.0 8 | {56A56F17-7DE1-4CA1-9617-BF32E971AC84} 9 | {EFBA0AD7-5A72-4C68-AF49-83D382785DCF};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} 10 | Library 11 | Properties 12 | Plugin.Connectivity 13 | Plugin.Connectivity 14 | 512 15 | Resources\Resource.Designer.cs 16 | Off 17 | false 18 | True 19 | v6.0 20 | 21 | 22 | true 23 | full 24 | false 25 | bin\Debug\ 26 | DEBUG;TRACE 27 | prompt 28 | 4 29 | 30 | 31 | pdbonly 32 | true 33 | bin\Release\ 34 | TRACE 35 | prompt 36 | 4 37 | bin\Release\Plugin.Connectivity.xml 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | CrossConnectivity.cs 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | {503c3c83-390a-48ef-845c-df4c928cb4a9} 64 | Connectivity.Plugin.Abstractions 65 | 66 | 67 | 68 | 75 | -------------------------------------------------------------------------------- /src/Connectivity.Plugin.Android/ConnectivityChangeBroadcastReceiver.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Threading.Tasks; 4 | using Android.App; 5 | using Android.Content; 6 | using Android.Net; 7 | using Plugin.Connectivity.Abstractions; 8 | 9 | namespace Plugin.Connectivity 10 | { 11 | /// 12 | /// Broadcast receiver to get notifications from Android on connectivity change 13 | /// 14 | [BroadcastReceiver(Enabled = true, Exported = false, Label = "Connectivity Plugin Broadcast Receiver")] 15 | //[IntentFilter(new[] { "android.net.conn.CONNECTIVITY_CHANGE" })] 16 | [Android.Runtime.Preserve(AllMembers = true)] 17 | public class ConnectivityChangeBroadcastReceiver : BroadcastReceiver 18 | { 19 | /// 20 | /// Action to call when connectivity changes 21 | /// 22 | public static Action ConnectionChanged; 23 | 24 | /// 25 | /// Action to call when connectivity type changes 26 | /// 27 | public static Action ConnectionTypeChanged; 28 | 29 | private bool isConnected; 30 | private ConnectivityManager connectivityManager; 31 | /// 32 | /// 33 | /// 34 | public ConnectivityChangeBroadcastReceiver() 35 | { 36 | isConnected = IsConnected; 37 | } 38 | 39 | ConnectivityManager ConnectivityManager 40 | { 41 | get 42 | { 43 | if (connectivityManager == null || connectivityManager.Handle == IntPtr.Zero) 44 | connectivityManager = (ConnectivityManager)(Application.Context.GetSystemService(Context.ConnectivityService)); 45 | 46 | return connectivityManager; 47 | } 48 | } 49 | 50 | /// 51 | /// Gets if there is an active internet connection 52 | /// 53 | bool IsConnected => ConnectivityImplementation.GetIsConnected(ConnectivityManager); 54 | 55 | /// 56 | /// Received a notification via BR. 57 | /// 58 | /// 59 | /// 60 | public override async void OnReceive(Context context, Intent intent) 61 | { 62 | if (intent.Action != ConnectivityManager.ConnectivityAction) 63 | return; 64 | 65 | //await 500ms to ensure that the the connection manager updates 66 | await Task.Delay(500); 67 | 68 | var connectionChangedAction = ConnectionChanged; 69 | var newConnection = IsConnected; 70 | if (connectionChangedAction != null) 71 | { 72 | if (newConnection != isConnected) 73 | { 74 | isConnected = newConnection; 75 | 76 | connectionChangedAction(new ConnectivityChangedEventArgs { IsConnected = isConnected }); 77 | } 78 | } 79 | 80 | var connectionTypeChangedAction = ConnectionTypeChanged; 81 | if (connectionTypeChangedAction != null) 82 | { 83 | 84 | var connectionTypes = ConnectivityImplementation.GetConnectionTypes(ConnectivityManager); 85 | 86 | connectionTypeChangedAction(new ConnectivityTypeChangedEventArgs { IsConnected = newConnection, ConnectionTypes = connectionTypes }); 87 | } 88 | } 89 | } 90 | } -------------------------------------------------------------------------------- /src/Connectivity.Plugin.Android/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | using Android.App; 5 | 6 | // General Information about an assembly is controlled through the following 7 | // set of attributes. Change these attribute values to modify the information 8 | // associated with an assembly. 9 | [assembly: AssemblyTitle("Plugin.Connectivity")] 10 | [assembly: AssemblyDescription("")] 11 | [assembly: AssemblyConfiguration("")] 12 | [assembly: AssemblyCompany("")] 13 | [assembly: AssemblyProduct("Plugin.Connectivity")] 14 | [assembly: AssemblyCopyright("Copyright © 2014")] 15 | [assembly: AssemblyTrademark("")] 16 | [assembly: AssemblyCulture("")] 17 | [assembly: ComVisible(false)] 18 | 19 | // Version information for an assembly consists of the following four values: 20 | // 21 | // Major Version 22 | // Minor Version 23 | // Build Number 24 | // Revision 25 | // 26 | // You can specify all the values or you can default the Build and Revision Numbers 27 | // by using the '*' as shown below: 28 | // [assembly: AssemblyVersion("1.0.*")] 29 | [assembly: AssemblyVersion("2.1.2")] 30 | [assembly: AssemblyFileVersion("2.1.2")] 31 | 32 | 33 | //Permissions for android 34 | [assembly: UsesPermission(Android.Manifest.Permission.AccessNetworkState)] 35 | [assembly: UsesPermission(Android.Manifest.Permission.AccessWifiState)] -------------------------------------------------------------------------------- /src/Connectivity.Plugin.Android/Resources/AboutResources.txt: -------------------------------------------------------------------------------- 1 | Images, layout descriptions, binary blobs and string dictionaries can be included 2 | in your application as resource files. Various Android APIs are designed to 3 | operate on the resource IDs instead of dealing with images, strings or binary blobs 4 | directly. 5 | 6 | For example, a sample Android app that contains a user interface layout (main.xml), 7 | an internationalization string table (strings.xml) and some icons (drawable-XXX/icon.png) 8 | would keep its resources in the "Resources" directory of the application: 9 | 10 | Resources/ 11 | drawable-hdpi/ 12 | icon.png 13 | 14 | drawable-ldpi/ 15 | icon.png 16 | 17 | drawable-mdpi/ 18 | icon.png 19 | 20 | layout/ 21 | main.xml 22 | 23 | values/ 24 | strings.xml 25 | 26 | In order to get the build system to recognize Android resources, set the build action to 27 | "AndroidResource". The native Android APIs do not operate directly with filenames, but 28 | instead operate on resource IDs. When you compile an Android application that uses resources, 29 | the build system will package the resources for distribution and generate a class called 30 | "Resource" that contains the tokens for each one of the resources included. For example, 31 | for the above Resources layout, this is what the Resource class would expose: 32 | 33 | public class Resource { 34 | public class drawable { 35 | public const int icon = 0x123; 36 | } 37 | 38 | public class layout { 39 | public const int main = 0x456; 40 | } 41 | 42 | public class strings { 43 | public const int first_string = 0xabc; 44 | public const int second_string = 0xbcd; 45 | } 46 | } 47 | 48 | You would then use R.drawable.icon to reference the drawable/icon.png file, or Resource.layout.main 49 | to reference the layout/main.xml file, or Resource.strings.first_string to reference the first 50 | string in the dictionary file values/strings.xml. -------------------------------------------------------------------------------- /src/Connectivity.Plugin.Android/Resources/Resource.Designer.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jamesmontemagno/ConnectivityPlugin/393fabe87fd41b3fcd622308da1b6d28b34dee3f/src/Connectivity.Plugin.Android/Resources/Resource.Designer.cs -------------------------------------------------------------------------------- /src/Connectivity.Plugin.Mac/Connectivity.Plugin.Mac.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | Debug 5 | AnyCPU 6 | {A3F8F2AB-B479-4A4A-A458-A89E7DC349F1};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} 7 | {9AE7DCA3-296B-4338-930B-8FFEF78433F2} 8 | Library 9 | Plugin.Connectivity 10 | Resources 11 | Plugin.Connectivity 12 | Xamarin.Mac 13 | v2.0 14 | 15 | 16 | true 17 | full 18 | false 19 | bin\Debug 20 | DEBUG; 21 | prompt 22 | 4 23 | false 24 | false 25 | false 26 | false 27 | false 28 | false 29 | false 30 | false 31 | 32 | 33 | true 34 | bin\Release 35 | prompt 36 | 4 37 | false 38 | false 39 | false 40 | false 41 | false 42 | false 43 | false 44 | false 45 | bin\Release\Plugin.Connectivity.xml 46 | __UNIFIED__;__MAC__ 47 | pdbonly 48 | true 49 | 50 | 51 | 52 | 53 | 54 | ..\..\..\..\Program Files (x86)\Reference Assemblies\Microsoft\Framework\Xamarin.Mac\v2.0\Facades\System.Runtime.dll 55 | 56 | 57 | ..\..\..\..\Program Files (x86)\Reference Assemblies\Microsoft\Framework\Xamarin.Mac\v2.0\Facades\System.Threading.Tasks.dll 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | CrossConnectivity.cs 68 | 69 | 70 | 71 | 72 | {3b973815-8ceb-49b1-81ea-e1da53cd4197} 73 | Connectivity.Plugin.Abstractions 74 | 75 | 76 | 77 | 78 | -------------------------------------------------------------------------------- /src/Connectivity.Plugin.Mac/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | 4 | // Information about this assembly is defined by the following attributes. 5 | // Change them to the values specific to your project. 6 | 7 | [assembly: AssemblyTitle ("Plugin.Connectivity")] 8 | [assembly: AssemblyDescription ("")] 9 | [assembly: AssemblyConfiguration ("")] 10 | [assembly: AssemblyCompany ("")] 11 | [assembly: AssemblyProduct ("Plugin.Connectivity")] 12 | [assembly: AssemblyCopyright ("Copyright © 2014")] 13 | [assembly: AssemblyTrademark ("")] 14 | [assembly: AssemblyCulture ("")] 15 | 16 | // The assembly version has the format "{Major}.{Minor}.{Build}.{Revision}". 17 | // The form "{Major}.{Minor}.*" will automatically update the build and revision, 18 | // and "{Major}.{Minor}.{Build}.*" will update just the revision. 19 | 20 | [assembly: AssemblyVersion ("2.0.2")] 21 | [assembly: AssemblyFileVersion ("2.0.2")] 22 | 23 | // The following attributes are used to specify the signing key for the assembly, 24 | // if desired. See the Mono documentation for more information about signing. 25 | 26 | //[assembly: AssemblyDelaySign(false)] 27 | //[assembly: AssemblyKeyFile("")] 28 | 29 | -------------------------------------------------------------------------------- /src/Connectivity.Plugin.Net45/Connectivity.Plugin.Net45.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {D45DEDF0-357D-455C-8189-E3DE0039CB4E} 8 | Library 9 | Properties 10 | Plugin.Connectivity 11 | Plugin.Connectivity 12 | v4.5 13 | 512 14 | 15 | 16 | true 17 | full 18 | false 19 | bin\Debug\ 20 | DEBUG;TRACE 21 | prompt 22 | 4 23 | 24 | 25 | pdbonly 26 | true 27 | bin\Release\ 28 | TRACE 29 | prompt 30 | 4 31 | bin\Release\Plugin.Connectivity.XML 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | CrossConnectivity.cs 46 | 47 | 48 | 49 | 50 | 51 | 52 | {503c3c83-390a-48ef-845c-df4c928cb4a9} 53 | Connectivity.Plugin.Abstractions 54 | 55 | 56 | 57 | 64 | -------------------------------------------------------------------------------- /src/Connectivity.Plugin.Net45/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("Plugin.Connectivity")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("Plugin.Connectivity")] 13 | [assembly: AssemblyCopyright("Copyright © 2015")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("d45dedf0-357d-455c-8189-e3de0039cb4e")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /src/Connectivity.Plugin.NetCore/Connectivity.Plugin.NetCore.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | netcoreapp2.0 5 | Plugin.Connectivity 6 | Plugin.Connectivity 7 | 1.0.0.0 8 | 1.0.0.0 9 | 1.0.0.0 10 | 11 | 12 | 13 | bin\Debug\netcoreapp2.0\Plugin.Connectivity.xml 14 | 15 | 16 | 17 | bin\Release\netcoreapp2.0\Plugin.Connectivity.xml 18 | 19 | 20 | 21 | 22 | 23 | 24 | CrossConnectivity.cs 25 | 26 | 27 | ConnectivityImplementation.cs 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /src/Connectivity.Plugin.Shared.Apple/Connectivity.Plugin.Shared.Apple.projitems: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | $(MSBuildAllProjects);$(MSBuildThisFileFullPath) 5 | true 6 | b302bd77-2e10-4889-876a-2589aa1bdb67 7 | 8 | 9 | Connectivity.Plugin.Shared.Apple 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /src/Connectivity.Plugin.Shared.Apple/Connectivity.Plugin.Shared.Apple.shproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | b302bd77-2e10-4889-876a-2589aa1bdb67 5 | 14.0 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /src/Connectivity.Plugin.Tizen/Connectivity.Plugin.Tizen.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | tizen40 6 | false 7 | Plugin.Connectivity 8 | Plugin.Connectivity 9 | 10 | 11 | 12 | portable 13 | 14 | 15 | None 16 | 17 | 18 | 19 | 20 | 21 | Runtime 22 | 23 | 24 | 25 | 26 | 27 | CrossConnectivity.cs 28 | 29 | 30 | 31 | 32 | {503c3c83-390a-48ef-845c-df4c928cb4a9} 33 | Connectivity.Plugin.Abstractions 34 | 35 | 36 | -------------------------------------------------------------------------------- /src/Connectivity.Plugin.UWP/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("Plugin.Connectivity")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("Plugin.Connectivity")] 13 | [assembly: AssemblyCopyright("Copyright © 2015")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Version information for an assembly consists of the following four values: 18 | // 19 | // Major Version 20 | // Minor Version 21 | // Build Number 22 | // Revision 23 | // 24 | // You can specify all the values or you can default the Build and Revision Numbers 25 | // by using the '*' as shown below: 26 | // [assembly: AssemblyVersion("1.0.*")] 27 | [assembly: AssemblyVersion("2.1.2")] 28 | [assembly: AssemblyFileVersion("2.1.2")] 29 | [assembly: ComVisible(false)] -------------------------------------------------------------------------------- /src/Connectivity.Plugin.UWP/Properties/Plugin.Connectivity.rd.xml: -------------------------------------------------------------------------------- 1 | 2 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /src/Connectivity.Plugin.UWP/project.json: -------------------------------------------------------------------------------- 1 | { 2 | "dependencies": { 3 | "Microsoft.NETCore.UniversalWindowsPlatform": "5.2.3" 4 | }, 5 | "frameworks": { 6 | "uap10.0": {} 7 | }, 8 | "runtimes": { 9 | "win10-arm": {}, 10 | "win10-arm-aot": {}, 11 | "win10-x86": {}, 12 | "win10-x86-aot": {}, 13 | "win10-x64": {}, 14 | "win10-x64-aot": {} 15 | } 16 | } -------------------------------------------------------------------------------- /src/Connectivity.Plugin.iOS/Connectivity.Plugin.iOS.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | Debug 5 | AnyCPU 6 | 8.0.30703 7 | 2.0 8 | {2882AEEB-D4CD-4EB9-8A6C-6653B33681F0} 9 | {FEACFBD2-3405-455C-9665-78FE426C6842};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} 10 | Library 11 | Plugin.Connectivity 12 | Resources 13 | Plugin.Connectivity 14 | 15 | 16 | true 17 | full 18 | false 19 | bin\iPhone\Debug 20 | DEBUG 21 | prompt 22 | 4 23 | false 24 | true 25 | iPhone Developer 26 | 27 | 28 | pdbonly 29 | true 30 | bin\iPhone\Release 31 | prompt 32 | 4 33 | false 34 | iPhone Developer 35 | bin\iPhone\Release\Plugin.Connectivity.xml 36 | true 37 | 38 | 39 | 40 | CrossConnectivity.cs 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | {503c3c83-390a-48ef-845c-df4c928cb4a9} 53 | Connectivity.Plugin.Abstractions 54 | 55 | 56 | 57 | 58 | -------------------------------------------------------------------------------- /src/Connectivity.Plugin.iOS/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("Plugin.Connectivity")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("Plugin.Connectivity")] 13 | [assembly: AssemblyCopyright("Copyright © 2014")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("38453772-383c-4ada-845b-100c5b84f50a")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("2.1.2")] 36 | [assembly: AssemblyFileVersion("2.1.2")] 37 | -------------------------------------------------------------------------------- /src/Connectivity.Plugin.tvOS/Connectivity.Plugin.tvOS.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | Debug 5 | AnyCPU 6 | {06FA79CB-D6CD-4721-BB4B-1BD202089C55};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} 7 | {44087DE8-D645-4F7B-A655-20EEA65EF209} 8 | Library 9 | Plugin.Connectivity 10 | Resources 11 | Plugin.Connectivity 12 | 13 | 14 | true 15 | full 16 | false 17 | bin\Debug 18 | DEBUG; 19 | prompt 20 | 4 21 | false 22 | 23 | 24 | full 25 | true 26 | bin\Release 27 | prompt 28 | 4 29 | false 30 | bin\Release\Plugin.Connectivity.xml 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | CrossConnectivity.cs 44 | 45 | 46 | 47 | 48 | 49 | {3b973815-8ceb-49b1-81ea-e1da53cd4197} 50 | Connectivity.Plugin.Abstractions 51 | 52 | 53 | 54 | 55 | -------------------------------------------------------------------------------- /src/Connectivity.Plugin.tvOS/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("Plugin.Connectivity")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("Plugin.Connectivity")] 13 | [assembly: AssemblyCopyright("Copyright © 2017")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("44087de8-d645-4f7b-a655-20eea65ef209")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /src/Connectivity.Plugin.watchOS/Connectivity.Plugin.watchOS.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | Debug 5 | AnyCPU 6 | {CDB8CAFD-4DB1-4C1C-BF55-4C82979B0EB5} 7 | {FC940695-DFE0-4552-9F25-99AF4A5619A1};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} 8 | Library 9 | Connectivity.Plugin 10 | Connectivity.Plugin 11 | Resources 12 | 13 | 14 | true 15 | full 16 | false 17 | bin\Debug 18 | DEBUG; 19 | prompt 20 | 4 21 | true 22 | true 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | true 32 | bin\Release 33 | 34 | 35 | prompt 36 | 4 37 | true 38 | true 39 | 40 | 41 | 42 | 43 | 44 | 45 | bin\Release\Connectivity.Plugin.xml 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | ConnectivityImplementation.cs 56 | 57 | 58 | Reachability.cs 59 | 60 | 61 | CrossConnectivity.cs 62 | 63 | 64 | 65 | 66 | 67 | 68 | {6EDB0588-FFC5-4EF5-8A99-9E241D0F878D} 69 | Connectivity.Plugin.Abstractions 70 | 71 | 72 | -------------------------------------------------------------------------------- /src/Connectivity.Plugin.watchOS/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("Connectivity.Plugin.watchOS")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("Connectivity.Plugin.watchOS")] 13 | [assembly: AssemblyCopyright("Copyright © 2017")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("cdb8cafd-4db1-4c1c-bf55-4c82979b0eb5")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /src/Connectivity.Plugin/Connectivity.Plugin.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | netstandard1.0 5 | Plugin.Connectivity 6 | Plugin.Connectivity 7 | 1.0.0.0 8 | 1.0.0.0 9 | 1.0.0.0 10 | 11 | 12 | 13 | bin\Release\netstandard1.0\Plugin.Connectivity.xml 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /src/Connectivity.Plugin/CrossConnectivity.cs: -------------------------------------------------------------------------------- 1 | using Plugin.Connectivity.Abstractions; 2 | using System; 3 | 4 | namespace Plugin.Connectivity 5 | { 6 | /// 7 | /// Cross platform Connectivity implementations 8 | /// 9 | public class CrossConnectivity 10 | { 11 | static Lazy implementation = new Lazy(() => CreateConnectivity(), System.Threading.LazyThreadSafetyMode.PublicationOnly); 12 | 13 | /// 14 | /// Gets if the plugin is supported on the current platform. 15 | /// 16 | public static bool IsSupported => implementation.Value == null ? false : true; 17 | 18 | /// 19 | /// Current plugin implementation to use 20 | /// 21 | public static IConnectivity Current 22 | { 23 | get 24 | { 25 | var ret = implementation.Value; 26 | if (ret == null) 27 | { 28 | throw NotImplementedInReferenceAssembly(); 29 | } 30 | return ret; 31 | } 32 | } 33 | 34 | static IConnectivity CreateConnectivity() 35 | { 36 | #if NETSTANDARD1_0 37 | return null; 38 | #else 39 | return new ConnectivityImplementation(); 40 | #endif 41 | } 42 | 43 | internal static Exception NotImplementedInReferenceAssembly() => 44 | new NotImplementedException("This functionality is not implemented in the portable version of this assembly. You should reference the NuGet package from your main application project in order to reference the platform-specific implementation."); 45 | 46 | 47 | 48 | /// 49 | /// Dispose of everything 50 | /// 51 | public static void Dispose() 52 | { 53 | if (implementation?.IsValueCreated ?? false) 54 | { 55 | implementation.Value.Dispose(); 56 | 57 | implementation = new Lazy(() => CreateConnectivity(), System.Threading.LazyThreadSafetyMode.PublicationOnly); 58 | } 59 | } 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /tests/Connectivity.Plugin.Tests.iOS/AppDelegate.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | 5 | using Foundation; 6 | using UIKit; 7 | using MonoTouch.NUnit.UI; 8 | 9 | namespace Connectivity.Plugin.Tests.iOS 10 | { 11 | // The UIApplicationDelegate for the application. This class is responsible for launching the 12 | // User Interface of the application, as well as listening (and optionally responding) to 13 | // application events from iOS. 14 | [Register("AppDelegate")] 15 | public partial class AppDelegate : UIApplicationDelegate 16 | { 17 | // class-level declarations 18 | UIWindow window; 19 | TouchRunner runner; 20 | 21 | // 22 | // This method is invoked when the application has loaded and is ready to run. In this 23 | // method you should instantiate the window, load the UI into it and then make the window 24 | // visible. 25 | // 26 | // You have 17 seconds to return from this method, or iOS will terminate your application. 27 | // 28 | public override bool FinishedLaunching(UIApplication app, NSDictionary options) 29 | { 30 | // create a new window instance based on the screen size 31 | window = new UIWindow(UIScreen.MainScreen.Bounds); 32 | runner = new TouchRunner(window); 33 | 34 | // register every tests included in the main application/assembly 35 | runner.Add(System.Reflection.Assembly.GetExecutingAssembly()); 36 | 37 | window.RootViewController = new UINavigationController(runner.GetViewController()); 38 | 39 | // make the window visible 40 | window.MakeKeyAndVisible(); 41 | 42 | return true; 43 | } 44 | } 45 | } -------------------------------------------------------------------------------- /tests/Connectivity.Plugin.Tests.iOS/Entitlements.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /tests/Connectivity.Plugin.Tests.iOS/Info.plist: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | CFBundleDisplayName 6 | Connectivity.Plugin.Tests.iOS 7 | CFBundleIdentifier 8 | com.your-company.Connectivity.Plugin.Tests.iOS 9 | CFBundleShortVersionString 10 | 1.0 11 | CFBundleVersion 12 | 1.0 13 | UIDeviceFamily 14 | 15 | 1 16 | 2 17 | 18 | UISupportedInterfaceOrientations 19 | 20 | UIInterfaceOrientationPortrait 21 | UIInterfaceOrientationLandscapeLeft 22 | UIInterfaceOrientationLandscapeRight 23 | 24 | UISupportedInterfaceOrientations~ipad 25 | 26 | UIInterfaceOrientationPortrait 27 | UIInterfaceOrientationPortraitUpsideDown 28 | UIInterfaceOrientationLandscapeLeft 29 | UIInterfaceOrientationLandscapeRight 30 | 31 | MinimumOSVersion 32 | 33 | NSAppTransportSecurity 34 | 35 | NSAllowsArbitraryLoads 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /tests/Connectivity.Plugin.Tests.iOS/Main.cs: -------------------------------------------------------------------------------- 1 | using UIKit; 2 | 3 | namespace Connectivity.Plugin.Tests.iOS 4 | { 5 | public class Application 6 | { 7 | // This is the main entry point of the application. 8 | static void Main(string[] args) 9 | { 10 | // if you want to use a different Application Delegate class from "AppDelegate" 11 | // you can specify it here. 12 | UIApplication.Main(args, null, "AppDelegate"); 13 | } 14 | } 15 | } -------------------------------------------------------------------------------- /tests/Connectivity.Plugin.Tests.iOS/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("Connectivity.Plugin.Tests.iOS")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("Connectivity.Plugin.Tests.iOS")] 13 | [assembly: AssemblyCopyright("Copyright © 2016")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("84e94706-420b-423e-8c56-7c53042a7fdb")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /tests/Connectivity.Plugin.Tests.iOS/Resources/Default-568h@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jamesmontemagno/ConnectivityPlugin/393fabe87fd41b3fcd622308da1b6d28b34dee3f/tests/Connectivity.Plugin.Tests.iOS/Resources/Default-568h@2x.png -------------------------------------------------------------------------------- /tests/Connectivity.Plugin.Tests.iOS/Resources/Default.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jamesmontemagno/ConnectivityPlugin/393fabe87fd41b3fcd622308da1b6d28b34dee3f/tests/Connectivity.Plugin.Tests.iOS/Resources/Default.png -------------------------------------------------------------------------------- /tests/Connectivity.Plugin.Tests.iOS/Resources/Default@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jamesmontemagno/ConnectivityPlugin/393fabe87fd41b3fcd622308da1b6d28b34dee3f/tests/Connectivity.Plugin.Tests.iOS/Resources/Default@2x.png -------------------------------------------------------------------------------- /tests/Connectivity.Tests.Android/Assets/AboutAssets.txt: -------------------------------------------------------------------------------- 1 | Any raw assets you want to be deployed with your application can be placed in 2 | this directory (and child directories) and given a Build Action of "AndroidAsset". 3 | 4 | These files will be deployed with you package and will be accessible using Android's 5 | AssetManager, like this: 6 | 7 | public class ReadAsset : Activity 8 | { 9 | protected override void OnCreate (Bundle bundle) 10 | { 11 | base.OnCreate (bundle); 12 | 13 | InputStream input = Assets.Open ("my_asset.txt"); 14 | } 15 | } 16 | 17 | Additionally, some Android functions will automatically load asset files: 18 | 19 | Typeface tf = Typeface.CreateFromAsset (Context.Assets, "fonts/samplefont.ttf"); -------------------------------------------------------------------------------- /tests/Connectivity.Tests.Android/Configuration.props: -------------------------------------------------------------------------------- 1 | 2 | 3 | $(HOME)/Library/Developer/Xamarin/android-sdk-macosx 4 | $(JAVA_HOME) 5 | 6 | $([System.IO.Path]::GetFullPath ('$(AndroidSdkDirectory)')) 7 | 8 | $(AndroidSdkFullPath)\platform-tools 9 | adb 10 | 11 | avdmanager 12 | $(AndroidSdkFullPath)\tools 13 | $(AndroidToolPath)\bin 14 | $(AndroidSdkFullPath)\tools 15 | emulator 16 | 17 | -------------------------------------------------------------------------------- /tests/Connectivity.Tests.Android/MainActivity.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using Android.App; 3 | using Android.OS; 4 | using Xamarin.Android.NUnitLite; 5 | 6 | namespace Connectivity.Tests.Droid 7 | { 8 | [Activity(Label = "Connectivity.Tests.Android", MainLauncher = true, Icon = "@drawable/icon")] 9 | public class MainActivity : TestSuiteActivity 10 | { 11 | protected override void OnCreate(Bundle bundle) 12 | { 13 | // tests can be inside the main assembly 14 | AddTest(Assembly.GetExecutingAssembly()); 15 | // or in any reference assemblies 16 | // AddTest (typeof (Your.Library.TestClass).Assembly); 17 | 18 | // Once you called base.OnCreate(), you cannot add more assemblies. 19 | base.OnCreate(bundle); 20 | } 21 | } 22 | } 23 | 24 | -------------------------------------------------------------------------------- /tests/Connectivity.Tests.Android/NUnit.projitems: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Connectivity.Tests.Android.Connectivity.Tests.Android 6 | app.tests.TestInstrumentation 7 | $(MyBuildOutputPath)/test-results.xml 8 | 9 | 10 | -------------------------------------------------------------------------------- /tests/Connectivity.Tests.Android/Properties/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /tests/Connectivity.Tests.Android/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | using Android.App; 5 | 6 | // General Information about an assembly is controlled through the following 7 | // set of attributes. Change these attribute values to modify the information 8 | // associated with an assembly. 9 | [assembly: AssemblyTitle("Connectivity.Tests.Android")] 10 | [assembly: AssemblyDescription("")] 11 | [assembly: AssemblyConfiguration("")] 12 | [assembly: AssemblyCompany("")] 13 | [assembly: AssemblyProduct("Connectivity.Tests.Android")] 14 | [assembly: AssemblyCopyright("Copyright © 2016")] 15 | [assembly: AssemblyTrademark("")] 16 | [assembly: AssemblyCulture("")] 17 | [assembly: ComVisible(false)] 18 | 19 | // Version information for an assembly consists of the following four values: 20 | // 21 | // Major Version 22 | // Minor Version 23 | // Build Number 24 | // Revision 25 | // 26 | // You can specify all the values or you can default the Build and Revision Numbers 27 | // by using the '*' as shown below: 28 | // [assembly: AssemblyVersion("1.0.*")] 29 | [assembly: AssemblyVersion("1.0.0.0")] 30 | [assembly: AssemblyFileVersion("1.0.0.0")] 31 | -------------------------------------------------------------------------------- /tests/Connectivity.Tests.Android/Resources/AboutResources.txt: -------------------------------------------------------------------------------- 1 | Images, layout descriptions, binary blobs and string dictionaries can be included 2 | in your application as resource files. Various Android APIs are designed to 3 | operate on the resource IDs instead of dealing with images, strings or binary blobs 4 | directly. 5 | 6 | For example, a sample Android app that contains a user interface layout (main.axml), 7 | an internationalization string table (strings.xml) and some icons (drawable-XXX/icon.png) 8 | would keep its resources in the "Resources" directory of the application: 9 | 10 | Resources/ 11 | drawable/ 12 | icon.png 13 | 14 | layout/ 15 | main.axml 16 | 17 | values/ 18 | strings.xml 19 | 20 | In order to get the build system to recognize Android resources, set the build action to 21 | "AndroidResource". The native Android APIs do not operate directly with filenames, but 22 | instead operate on resource IDs. When you compile an Android application that uses resources, 23 | the build system will package the resources for distribution and generate a class called "R" 24 | (this is an Android convention) that contains the tokens for each one of the resources 25 | included. For example, for the above Resources layout, this is what the R class would expose: 26 | 27 | public class R { 28 | public class drawable { 29 | public const int icon = 0x123; 30 | } 31 | 32 | public class layout { 33 | public const int main = 0x456; 34 | } 35 | 36 | public class strings { 37 | public const int first_string = 0xabc; 38 | public const int second_string = 0xbcd; 39 | } 40 | } 41 | 42 | You would then use R.drawable.icon to reference the drawable/icon.png file, or R.layout.main 43 | to reference the layout/main.axml file, or R.strings.first_string to reference the first 44 | string in the dictionary file values/strings.xml. -------------------------------------------------------------------------------- /tests/Connectivity.Tests.Android/Resources/drawable/Icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jamesmontemagno/ConnectivityPlugin/393fabe87fd41b3fcd622308da1b6d28b34dee3f/tests/Connectivity.Tests.Android/Resources/drawable/Icon.png -------------------------------------------------------------------------------- /tests/Connectivity.Tests.Android/Resources/values/Strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | Hello World, Click Me! 4 | Connectivity.Tests.Android 5 | 6 | -------------------------------------------------------------------------------- /tests/Connectivity.Tests.Android/TestInstrumentation.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Reflection; 3 | using Android.App; 4 | using Android.Runtime; 5 | using Xamarin.Android.NUnitLite; 6 | 7 | namespace Connectivity.Tests.Droid 8 | { 9 | [Instrumentation(Name = "app.tests.TestInstrumentation")] 10 | public class TestInstrumentation : TestSuiteInstrumentation 11 | { 12 | protected TestInstrumentation(IntPtr handle, JniHandleOwnership transfer) : base(handle, transfer) 13 | { 14 | } 15 | 16 | protected override void AddTests() 17 | { 18 | AddTest(Assembly.GetExecutingAssembly()); 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /tests/Connectivity.Tests.Android/TestSample.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using NUnit.Framework; 3 | using Plugin.Connectivity; 4 | using System.Linq; 5 | 6 | namespace Connectivity.Tests 7 | { 8 | [TestFixture] 9 | public class TestsSample 10 | { 11 | 12 | [SetUp] 13 | public void Setup() { } 14 | 15 | 16 | [TearDown] 17 | public void Tear() { } 18 | 19 | [Test] 20 | public void IsConnected() 21 | { 22 | Assert.True(CrossConnectivity.Current.IsConnected, "Emulator was not connected"); 23 | } 24 | 25 | [Test] 26 | public void ConnectionTypes() 27 | { 28 | var connected = CrossConnectivity.Current.IsConnected; 29 | var types = CrossConnectivity.Current.ConnectionTypes; 30 | Assert.IsTrue(!types.Contains(Plugin.Connectivity.Abstractions.ConnectionType.Other)); 31 | 32 | } 33 | 34 | [Test] 35 | public async void CanReachRemote() 36 | { 37 | var canReach = await CrossConnectivity.Current.IsRemoteReachable("google.com"); 38 | Assert.IsTrue(canReach); 39 | } 40 | 41 | 42 | } 43 | } -------------------------------------------------------------------------------- /tests/Connectivity.Tests.Android/lib/Xamarin.Android.Tools.AndroidSdk.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jamesmontemagno/ConnectivityPlugin/393fabe87fd41b3fcd622308da1b6d28b34dee3f/tests/Connectivity.Tests.Android/lib/Xamarin.Android.Tools.AndroidSdk.dll -------------------------------------------------------------------------------- /tests/Connectivity.Tests.Android/lib/Xamarin.Android.Tools.BootstrapTasks.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jamesmontemagno/ConnectivityPlugin/393fabe87fd41b3fcd622308da1b6d28b34dee3f/tests/Connectivity.Tests.Android/lib/Xamarin.Android.Tools.BootstrapTasks.dll -------------------------------------------------------------------------------- /tests/Connectivity.Tests.Android/lib/xa-prep-tasks.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jamesmontemagno/ConnectivityPlugin/393fabe87fd41b3fcd622308da1b6d28b34dee3f/tests/Connectivity.Tests.Android/lib/xa-prep-tasks.dll -------------------------------------------------------------------------------- /tests/Connectivity.Tests.Tizen/Connectivity.Tests.Tizen.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Exe 6 | tizen40 7 | 8 | 9 | 10 | portable 11 | 12 | 13 | None 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | Runtime 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /tests/Connectivity.Tests.Tizen/Connectivity.Tests.Tizen_App.cs: -------------------------------------------------------------------------------- 1 | using Tizen.Applications; 2 | using ElmSharp; 3 | using Plugin.Connectivity; 4 | using System.Diagnostics; 5 | using System; 6 | 7 | namespace Connectivity.Tests.Tizen 8 | { 9 | class App : CoreUIApplication 10 | { 11 | private ToastMessage toast; 12 | 13 | protected override void OnCreate() 14 | { 15 | base.OnCreate(); 16 | Initialize(); 17 | } 18 | 19 | void Initialize() 20 | { 21 | toast = new ToastMessage(); 22 | 23 | Window window = new Window("ConnectivityTest") 24 | { 25 | AvailableRotations = DisplayRotation.Degree_0 | DisplayRotation.Degree_180 | DisplayRotation.Degree_270 | DisplayRotation.Degree_90 26 | }; 27 | window.BackButtonPressed += (s, e) => 28 | { 29 | Exit(); 30 | }; 31 | window.Show(); 32 | 33 | var box = new Box(window) 34 | { 35 | AlignmentX = -1, 36 | AlignmentY = -1, 37 | WeightX = 1, 38 | WeightY = 1, 39 | }; 40 | box.Show(); 41 | 42 | var bg = new Background(window) 43 | { 44 | Color = Color.White 45 | }; 46 | bg.SetContent(box); 47 | 48 | var conformant = new Conformant(window); 49 | conformant.Show(); 50 | conformant.SetContent(bg); 51 | 52 | var IsConnected = new Button(window) 53 | { 54 | Text = "IsConnected", 55 | AlignmentX = -1, 56 | AlignmentY = -1, 57 | WeightX = 1, 58 | }; 59 | IsConnected.Clicked += IsConnected_ClickedAsync; 60 | IsConnected.Show(); 61 | box.PackEnd(IsConnected); 62 | 63 | var ConnectionTypes = new Button(window) 64 | { 65 | Text = "ConnectionTypes", 66 | AlignmentX = -1, 67 | AlignmentY = -1, 68 | WeightX = 1, 69 | }; 70 | ConnectionTypes.Clicked += ConnectionTypes_ClickedAsync; 71 | ConnectionTypes.Show(); 72 | box.PackEnd(ConnectionTypes); 73 | 74 | var CanReachRemote = new Button(window) 75 | { 76 | Text = "CanReachRemote", 77 | AlignmentX = -1, 78 | AlignmentY = -1, 79 | WeightX = 1, 80 | }; 81 | CanReachRemote.Clicked += CanReachRemote_ClickedAsync; 82 | CanReachRemote.Show(); 83 | box.PackEnd(CanReachRemote); 84 | } 85 | 86 | static void Main(string[] args) 87 | { 88 | Elementary.Initialize(); 89 | Elementary.ThemeOverlay(); 90 | App app = new App(); 91 | app.Run(args); 92 | } 93 | 94 | private void PostToastMessage(string message) 95 | { 96 | toast.Message = message; 97 | toast.Post(); 98 | Debug.WriteLine(message); 99 | } 100 | 101 | private void IsConnected_ClickedAsync(object sender, System.EventArgs e) 102 | { 103 | try 104 | { 105 | PostToastMessage("IsConnected : " + CrossConnectivity.Current.IsConnected); 106 | } 107 | catch (Exception ex) 108 | { 109 | PostToastMessage(ex.Message); 110 | } 111 | } 112 | 113 | private void ConnectionTypes_ClickedAsync(object sender, System.EventArgs e) 114 | { 115 | try 116 | { 117 | var types = CrossConnectivity.Current.ConnectionTypes; 118 | foreach(var type in types) 119 | PostToastMessage("ConnectionTypes : " + type); 120 | } 121 | catch (Exception ex) 122 | { 123 | PostToastMessage(ex.Message); 124 | } 125 | } 126 | 127 | private async void CanReachRemote_ClickedAsync(object sender, System.EventArgs e) 128 | { 129 | try 130 | { 131 | PostToastMessage("IsRemoteReachable : " + await CrossConnectivity.Current.IsRemoteReachable("http://www.github.com")); 132 | } 133 | catch (Exception ex) 134 | { 135 | PostToastMessage(ex.Message); 136 | } 137 | } 138 | } 139 | } 140 | -------------------------------------------------------------------------------- /tests/Connectivity.Tests.Tizen/shared/res/Connectivity.Tests.Tizen.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jamesmontemagno/ConnectivityPlugin/393fabe87fd41b3fcd622308da1b6d28b34dee3f/tests/Connectivity.Tests.Tizen/shared/res/Connectivity.Tests.Tizen.png -------------------------------------------------------------------------------- /tests/Connectivity.Tests.Tizen/tizen-manifest.xml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 11 | 12 | Connectivity.Tests.Tizen.png 13 | 14 | 15 | 16 | http://tizen.org/privilege/network.get 17 | http://tizen.org/privilege/internet 18 | 19 | 20 | -------------------------------------------------------------------------------- /tests/Connectivity.Tests.iOS/AppDelegate.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | 5 | using Foundation; 6 | using UIKit; 7 | using MonoTouch.NUnit.UI; 8 | 9 | namespace Connectivity.Tests.iOS 10 | { 11 | // The UIApplicationDelegate for the application. This class is responsible for launching the 12 | // User Interface of the application, as well as listening (and optionally responding) to 13 | // application events from iOS. 14 | [Register("AppDelegate")] 15 | public partial class AppDelegate : UIApplicationDelegate 16 | { 17 | // class-level declarations 18 | UIWindow window; 19 | TouchRunner runner; 20 | 21 | // 22 | // This method is invoked when the application has loaded and is ready to run. In this 23 | // method you should instantiate the window, load the UI into it and then make the window 24 | // visible. 25 | // 26 | // You have 17 seconds to return from this method, or iOS will terminate your application. 27 | // 28 | public override bool FinishedLaunching(UIApplication app, NSDictionary options) 29 | { 30 | // create a new window instance based on the screen size 31 | window = new UIWindow(UIScreen.MainScreen.Bounds); 32 | runner = new TouchRunner(window); 33 | 34 | // register every tests included in the main application/assembly 35 | runner.Add(System.Reflection.Assembly.GetExecutingAssembly()); 36 | 37 | window.RootViewController = new UINavigationController(runner.GetViewController()); 38 | 39 | // make the window visible 40 | window.MakeKeyAndVisible(); 41 | 42 | return true; 43 | } 44 | } 45 | } -------------------------------------------------------------------------------- /tests/Connectivity.Tests.iOS/Entitlements.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /tests/Connectivity.Tests.iOS/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDisplayName 6 | Connectivity.Tests.iOS 7 | CFBundleShortVersionString 8 | 1.0 9 | CFBundleVersion 10 | 1.0 11 | UIDeviceFamily 12 | 13 | 1 14 | 2 15 | 16 | UISupportedInterfaceOrientations 17 | 18 | UIInterfaceOrientationPortrait 19 | UIInterfaceOrientationLandscapeLeft 20 | UIInterfaceOrientationLandscapeRight 21 | 22 | UISupportedInterfaceOrientations~ipad 23 | 24 | UIInterfaceOrientationPortrait 25 | UIInterfaceOrientationPortraitUpsideDown 26 | UIInterfaceOrientationLandscapeLeft 27 | UIInterfaceOrientationLandscapeRight 28 | 29 | MinimumOSVersion 30 | 10.2 31 | NSAppTransportSecurity 32 | 33 | NSAllowsArbitraryLoads 34 | 35 | 36 | CFBundleName 37 | Connectivity.Tests.iOS 38 | CFBundleIdentifier 39 | com.plugin.connectivity 40 | 41 | 42 | -------------------------------------------------------------------------------- /tests/Connectivity.Tests.iOS/Main.cs: -------------------------------------------------------------------------------- 1 | using UIKit; 2 | 3 | namespace Connectivity.Tests.iOS 4 | { 5 | public class Application 6 | { 7 | // This is the main entry point of the application. 8 | static void Main(string[] args) 9 | { 10 | // if you want to use a different Application Delegate class from "AppDelegate" 11 | // you can specify it here. 12 | UIApplication.Main(args, null, "AppDelegate"); 13 | } 14 | } 15 | } -------------------------------------------------------------------------------- /tests/Connectivity.Tests.iOS/Makefile: -------------------------------------------------------------------------------- 1 | TOUCH_SERVER=unit-test-tools/Touch.Server.exe 2 | TEST_RESULT=./test_results.xml 3 | MTOUCH=/Developer/MonoTouch/usr/bin/mtouch 4 | UNIT_SUMMARY=unit-test-tools/nunit-summary.exe 5 | THIS_FILE := $(lastword $(MAKEFILE_LIST)) 6 | PROJECT_FILE=Connectivity.Tests.iOS.csproj 7 | APP_NAME=ConnectivityTestsiOS.app 8 | 9 | all: build-simulator build-device 10 | 11 | run-all-tests: run-simulator run-device 12 | 13 | build-simulator: 14 | msbuild $(PROJECT_FILE) /t:Rebuild 15 | 16 | build-device: 17 | msbuild $(PROJECT_FILE) /t:ReBuild /p:Platform=iPhone 18 | 19 | run-simulator-tests: download-server build-simulator 20 | mono --debug $(TOUCH_SERVER) \ 21 | --launchsim ./bin/iPhoneSimulator/Debug/$(APP_NAME) \ 22 | -autoexit -skipheader \ 23 | -logfile=$(TEST_RESULT) \ 24 | --verbose \ 25 | --device=":v2:runtime=com.apple.CoreSimulator.SimRuntime.iOS-11-2,devicetype=com.apple.CoreSimulator.SimDeviceType.iPhone-SE" 26 | @$(MAKE) -f $(THIS_FILE) show-results 27 | 28 | run-device-tests: download-server build-device 29 | $(MTOUCH) --installdev ./bin/iPhone/Debug/$(APP_NAME) 30 | mono --debug $(TOUCH_SERVER) --launchdev com.plugin.connectivity -autoexit -skipheader -logfile=$(TEST_RESULT) 31 | @$(MAKE) -f $(THIS_FILE) show-results 32 | 33 | show-results: 34 | mono $(UNIT_SUMMARY) $(TEST_RESULT) 35 | rm -rf $(TEST_RESULT) 36 | 37 | download-server: 38 | @if ! test -f $(TOUCH_SERVER); then \ 39 | curl -L -O "https://github.com/prashantvc/Touch.Server/releases/download/0.1/Touch.Server.exe" > Touch.Server.exe; \ 40 | mkdir unit-test-tools; \ 41 | mv Touch.Server.exe $(TOUCH_SERVER); \ 42 | fi 43 | 44 | @if ! test -f $(UNIT_SUMMARY); then \ 45 | curl -L -O "https://github.com/prashantvc/nunit-summary/releases/download/0.4/nunit-summary.exe" > nunit-summary.exe; \ 46 | mv nunit-summary.exe $(UNIT_SUMMARY); \ 47 | fi -------------------------------------------------------------------------------- /tests/Connectivity.Tests.iOS/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("Connectivity.Tests.iOS")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("Connectivity.Tests.iOS")] 13 | [assembly: AssemblyCopyright("Copyright © 2016")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("5a9daea7-ae79-4623-ae8c-d9744eac2acb")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /tests/Connectivity.Tests.iOS/Resources/Default-568h@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jamesmontemagno/ConnectivityPlugin/393fabe87fd41b3fcd622308da1b6d28b34dee3f/tests/Connectivity.Tests.iOS/Resources/Default-568h@2x.png -------------------------------------------------------------------------------- /tests/Connectivity.Tests.iOS/Resources/Default.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jamesmontemagno/ConnectivityPlugin/393fabe87fd41b3fcd622308da1b6d28b34dee3f/tests/Connectivity.Tests.iOS/Resources/Default.png -------------------------------------------------------------------------------- /tests/Connectivity.Tests.iOS/Resources/Default@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jamesmontemagno/ConnectivityPlugin/393fabe87fd41b3fcd622308da1b6d28b34dee3f/tests/Connectivity.Tests.iOS/Resources/Default@2x.png -------------------------------------------------------------------------------- /tests/Connectivity.Tests.iOS/run-unittests.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | echo 'Output path = ' $1 4 | 5 | TEST_RESULT=$1/test_results.xml 6 | TOUCH_SERVER=unit-test-tools/Touch.Server.exe 7 | 8 | 9 | echo 'Delete test result' 10 | rm -rf $TEST_RESULT 11 | 12 | #downloading touch.server 13 | if [ ! -f $TOUCH_SERVER ]; then 14 | echo "Touch server doesn't exists" 15 | curl -L -O "https://github.com/prashantvc/Touch.Server/releases/download/0.1/Touch.Server.exe" > Touch.Server.exe 16 | mkdir unit-test-tools 17 | mv Touch.Server.exe $TOUCH_SERVER 18 | fi; 19 | 20 | mono --debug $TOUCH_SERVER \ 21 | --launchsim ./bin/iPhoneSimulator/Debug/ConnectivityTestsiOS.app \ 22 | -autoexit \ 23 | -skipheader \ 24 | -logfile=$TEST_RESULT \ 25 | --verbose \ 26 | --device=":v2:runtime=com.apple.CoreSimulator.SimRuntime.iOS-11-2,devicetype=com.apple.CoreSimulator.SimDeviceType.iPhone-SE" -------------------------------------------------------------------------------- /tests/Connectivity.Tests/Class1.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | namespace Connectivity.Tests 7 | { 8 | public class Class1 9 | { 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /tests/Connectivity.Tests/Connectivity.Tests.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 10.0 6 | Debug 7 | AnyCPU 8 | {d06f58ef-ddd3-45ed-bd68-565fc544268d} 9 | Library 10 | Properties 11 | Connectivity.Tests 12 | Connectivity.Tests 13 | en-US 14 | 512 15 | {786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} 16 | Profile111 17 | v4.5 18 | 19 | 20 | true 21 | full 22 | false 23 | bin\Debug\ 24 | DEBUG;TRACE 25 | prompt 26 | 4 27 | 28 | 29 | pdbonly 30 | true 31 | bin\Release\ 32 | TRACE 33 | prompt 34 | 4 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 51 | 52 | 53 | -------------------------------------------------------------------------------- /tests/Connectivity.Tests/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Resources; 2 | using System.Reflection; 3 | using System.Runtime.CompilerServices; 4 | using System.Runtime.InteropServices; 5 | 6 | // General Information about an assembly is controlled through the following 7 | // set of attributes. Change these attribute values to modify the information 8 | // associated with an assembly. 9 | [assembly: AssemblyTitle("Connectivity.Tests")] 10 | [assembly: AssemblyDescription("")] 11 | [assembly: AssemblyConfiguration("")] 12 | [assembly: AssemblyCompany("")] 13 | [assembly: AssemblyProduct("Connectivity.Tests")] 14 | [assembly: AssemblyCopyright("Copyright © 2016")] 15 | [assembly: AssemblyTrademark("")] 16 | [assembly: AssemblyCulture("")] 17 | [assembly: NeutralResourcesLanguage("en")] 18 | 19 | // Version information for an assembly consists of the following four values: 20 | // 21 | // Major Version 22 | // Minor Version 23 | // Build Number 24 | // Revision 25 | // 26 | // You can specify all the values or you can default the Build and Revision Numbers 27 | // by using the '*' as shown below: 28 | // [assembly: AssemblyVersion("1.0.*")] 29 | [assembly: AssemblyVersion("1.0.0.0")] 30 | [assembly: AssemblyFileVersion("1.0.0.0")] 31 | -------------------------------------------------------------------------------- /tests/ConnectivityTest.UWP/App.xaml: -------------------------------------------------------------------------------- 1 |  7 | 8 | 9 | -------------------------------------------------------------------------------- /tests/ConnectivityTest.UWP/Assets/LockScreenLogo.scale-200.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jamesmontemagno/ConnectivityPlugin/393fabe87fd41b3fcd622308da1b6d28b34dee3f/tests/ConnectivityTest.UWP/Assets/LockScreenLogo.scale-200.png -------------------------------------------------------------------------------- /tests/ConnectivityTest.UWP/Assets/SplashScreen.scale-200.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jamesmontemagno/ConnectivityPlugin/393fabe87fd41b3fcd622308da1b6d28b34dee3f/tests/ConnectivityTest.UWP/Assets/SplashScreen.scale-200.png -------------------------------------------------------------------------------- /tests/ConnectivityTest.UWP/Assets/Square150x150Logo.scale-200.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jamesmontemagno/ConnectivityPlugin/393fabe87fd41b3fcd622308da1b6d28b34dee3f/tests/ConnectivityTest.UWP/Assets/Square150x150Logo.scale-200.png -------------------------------------------------------------------------------- /tests/ConnectivityTest.UWP/Assets/Square44x44Logo.scale-200.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jamesmontemagno/ConnectivityPlugin/393fabe87fd41b3fcd622308da1b6d28b34dee3f/tests/ConnectivityTest.UWP/Assets/Square44x44Logo.scale-200.png -------------------------------------------------------------------------------- /tests/ConnectivityTest.UWP/Assets/Square44x44Logo.targetsize-24_altform-unplated.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jamesmontemagno/ConnectivityPlugin/393fabe87fd41b3fcd622308da1b6d28b34dee3f/tests/ConnectivityTest.UWP/Assets/Square44x44Logo.targetsize-24_altform-unplated.png -------------------------------------------------------------------------------- /tests/ConnectivityTest.UWP/Assets/StoreLogo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jamesmontemagno/ConnectivityPlugin/393fabe87fd41b3fcd622308da1b6d28b34dee3f/tests/ConnectivityTest.UWP/Assets/StoreLogo.png -------------------------------------------------------------------------------- /tests/ConnectivityTest.UWP/Assets/Wide310x150Logo.scale-200.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jamesmontemagno/ConnectivityPlugin/393fabe87fd41b3fcd622308da1b6d28b34dee3f/tests/ConnectivityTest.UWP/Assets/Wide310x150Logo.scale-200.png -------------------------------------------------------------------------------- /tests/ConnectivityTest.UWP/MainPage.xaml: -------------------------------------------------------------------------------- 1 |  10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /tests/ConnectivityTest.UWP/MainPage.xaml.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.IO; 4 | using System.Linq; 5 | using System.Runtime.InteropServices.WindowsRuntime; 6 | using Windows.Foundation; 7 | using Windows.Foundation.Collections; 8 | using Windows.UI.Xaml; 9 | using Windows.UI.Xaml.Controls; 10 | using Windows.UI.Xaml.Controls.Primitives; 11 | using Windows.UI.Xaml.Data; 12 | using Windows.UI.Xaml.Input; 13 | using Windows.UI.Xaml.Media; 14 | using Windows.UI.Xaml.Navigation; 15 | 16 | // The Blank Page item template is documented at https://go.microsoft.com/fwlink/?LinkId=402352&clcid=0x409 17 | 18 | namespace ConnectivityTest.UWP 19 | { 20 | /// 21 | /// An empty page that can be used on its own or navigated to within a Frame. 22 | /// 23 | public sealed partial class MainPage 24 | { 25 | public MainPage() 26 | { 27 | this.InitializeComponent(); 28 | LoadApplication(new ConnectivityTest.App()); 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /tests/ConnectivityTest.UWP/Package.appxmanifest: -------------------------------------------------------------------------------- 1 |  2 | 3 | 8 | 9 | 13 | 14 | 15 | 16 | 17 | ConnectivityTest.UWP 18 | Motz 19 | Assets\StoreLogo.png 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 34 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | -------------------------------------------------------------------------------- /tests/ConnectivityTest.UWP/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("ConnectivityTest.UWP")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("ConnectivityTest.UWP")] 13 | [assembly: AssemblyCopyright("Copyright © 2017")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Version information for an assembly consists of the following four values: 18 | // 19 | // Major Version 20 | // Minor Version 21 | // Build Number 22 | // Revision 23 | // 24 | // You can specify all the values or you can default the Build and Revision Numbers 25 | // by using the '*' as shown below: 26 | // [assembly: AssemblyVersion("1.0.*")] 27 | [assembly: AssemblyVersion("1.0.0.0")] 28 | [assembly: AssemblyFileVersion("1.0.0.0")] 29 | [assembly: ComVisible(false)] -------------------------------------------------------------------------------- /tests/ConnectivityTest.UWP/Properties/Default.rd.xml: -------------------------------------------------------------------------------- 1 | 17 | 18 | 19 | 20 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /tests/ConnectivityTest.UWP/project.json: -------------------------------------------------------------------------------- 1 | { 2 | "dependencies": { 3 | "Microsoft.NETCore.UniversalWindowsPlatform": "5.2.3", 4 | "Xamarin.Forms": "2.3.4.247" 5 | }, 6 | "frameworks": { 7 | "uap10.0": {} 8 | }, 9 | "runtimes": { 10 | "win10-arm": {}, 11 | "win10-arm-aot": {}, 12 | "win10-x86": {}, 13 | "win10-x86-aot": {}, 14 | "win10-x64": {}, 15 | "win10-x64-aot": {} 16 | } 17 | } -------------------------------------------------------------------------------- /tests/ConnectivyTest.Net45/App.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /tests/ConnectivyTest.Net45/ConnectivyTest.Net45.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {83D5765B-FCE4-4C52-B449-28F3A3BFF1F6} 8 | Exe 9 | Properties 10 | ConnectivyTest.Net45 11 | ConnectivyTest.Net45 12 | v4.5.2 13 | 512 14 | true 15 | 16 | 17 | AnyCPU 18 | true 19 | full 20 | false 21 | bin\Debug\ 22 | DEBUG;TRACE 23 | prompt 24 | 4 25 | 26 | 27 | AnyCPU 28 | pdbonly 29 | true 30 | bin\Release\ 31 | TRACE 32 | prompt 33 | 4 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | {503c3c83-390a-48ef-845c-df4c928cb4a9} 55 | Connectivity.Plugin.Abstractions 56 | 57 | 58 | {d45dedf0-357d-455c-8189-e3de0039cb4e} 59 | Connectivity.Plugin.Net45 60 | 61 | 62 | 63 | 70 | -------------------------------------------------------------------------------- /tests/ConnectivyTest.Net45/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Threading.Tasks; 3 | using Plugin.Connectivity; 4 | 5 | namespace ConnectivyTest.Net45 6 | { 7 | class Program 8 | { 9 | // Simple test console to ensure that .net45 CrossConnectivity works. 10 | static void Main(string[] args) 11 | { 12 | Task.Run(async () => 13 | { 14 | var isConnected = CrossConnectivity.Current.IsConnected; 15 | 16 | var isReachable = await CrossConnectivity.Current.IsReachable("http://www.github.com"); 17 | var isHostReachable = await CrossConnectivity.Current.IsRemoteReachable("http://www.github.com"); 18 | 19 | Console.WriteLine($"IsConnected: {isConnected}"); 20 | Console.WriteLine($"Is github Reachable: {isReachable}"); 21 | Console.WriteLine($"Is remote port 80 on github reachable: {isHostReachable}"); 22 | 23 | CrossConnectivity.Current.ConnectivityChanged += Current_ConnectivityChanged; 24 | 25 | Console.WriteLine("press enter to close."); 26 | 27 | Console.ReadLine(); 28 | }).Wait(); 29 | 30 | } 31 | 32 | private static void Current_ConnectivityChanged(object sender, Plugin.Connectivity.Abstractions.ConnectivityChangedEventArgs e) 33 | { 34 | Console.WriteLine($"IsConnected {e.IsConnected}"); 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /tests/ConnectivyTest.Net45/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("ConnectivyTest.Net45")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("ConnectivyTest.Net45")] 13 | [assembly: AssemblyCopyright("Copyright © 2017")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("83d5765b-fce4-4c52-b449-28f3a3bff1f6")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /tests/app/ConnectivityTest/App.xaml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /tests/app/ConnectivityTest/App.xaml.cs: -------------------------------------------------------------------------------- 1 | using Xamarin.Forms; 2 | 3 | namespace ConnectivityTest 4 | { 5 | public partial class App : Application 6 | { 7 | public App() 8 | { 9 | InitializeComponent(); 10 | 11 | MainPage = new NavigationPage(new ConnectivityTestPage()); 12 | } 13 | 14 | protected override void OnStart() 15 | { 16 | // Handle when your app starts 17 | } 18 | 19 | protected override void OnSleep() 20 | { 21 | // Handle when your app sleeps 22 | } 23 | 24 | protected override void OnResume() 25 | { 26 | // Handle when your app resumes 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /tests/app/ConnectivityTest/ConnectivityTest.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | Debug 5 | AnyCPU 6 | {94C0596E-0531-428E-8850-B955879086CC} 7 | {786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} 8 | true 9 | Library 10 | ConnectivityTest 11 | ConnectivityTest 12 | v4.5 13 | Profile78 14 | 15 | 16 | true 17 | full 18 | false 19 | bin\Debug 20 | DEBUG; 21 | prompt 22 | 4 23 | 24 | 25 | true 26 | bin\Release 27 | prompt 28 | 4 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | App.xaml 37 | 38 | 39 | ConnectivityTestPage.xaml 40 | 41 | 42 | 43 | 44 | 45 | ..\..\packages\Xamarin.Forms.2.3.4.247\lib\portable-win+net45+wp80+win81+wpa81+MonoAndroid10+Xamarin.iOS10+xamarinmac20\Xamarin.Forms.Core.dll 46 | 47 | 48 | ..\..\packages\Xamarin.Forms.2.3.4.247\lib\portable-win+net45+wp80+win81+wpa81+MonoAndroid10+Xamarin.iOS10+xamarinmac20\Xamarin.Forms.Platform.dll 49 | 50 | 51 | ..\..\packages\Xamarin.Forms.2.3.4.247\lib\portable-win+net45+wp80+win81+wpa81+MonoAndroid10+Xamarin.iOS10+xamarinmac20\Xamarin.Forms.Xaml.dll 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | {503c3c83-390a-48ef-845c-df4c928cb4a9} 60 | Connectivity.Plugin.Abstractions 61 | 62 | 63 | {4c6b4247-169d-4144-afc8-34b27c07450e} 64 | Connectivity.Plugin 65 | 66 | 67 | 68 | 69 | -------------------------------------------------------------------------------- /tests/app/ConnectivityTest/ConnectivityTestPage.xaml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 |