How to check Internet Connectivity in xamarin forms shared project - xamarin.forms

How can I check if Internet is available in Xamarin forms shared project.
We can use Cross connectivity plugin in PCL project,
can we use the same plugin in shared project as well?

The Cross Connectivity Plugin has been deprecated in favor of Xamarin.Essentials.
First, add the Xamarin.Essentials NuGet Package to both the iOS project and Android project.
Then use it to check connectivity in the shared project:
var current = Connectivity.NetworkAccess;
if (current == NetworkAccess.Internet)
{
// Connection to internet is available
}

I created a Property which returns CrossConnectivity.Current.IsConnected in its getter.
Also using the Plugin.Connectivity.CrossConnectivity NuGet Package.

Related

Xamarin turn-by-turn navigation with routing and HERE

I am using Xamarin iOS and Android for turn-by-turn navigation routing. Can this be done with HERE?
We recommend using android studio. For Xamarin, bindings need to be created in SDK, which are not available in our existing roadmap. Hence you can either create the bindings yourself or using our professional services as SDK libraries need modification in this case. Yes it is available. It can be done.
Please refer the individual documentation for Android and Ios for more details :
Android : https://developer.here.com/documentation/android-premium/dev_guide/topics/map-guidance.html
IOS : https://developer.here.com/documentation/ios-premium/dev_guide/topics/map-guidance.html

Xamarin forms failing ti install NotificationHub Nuget in UWP project

Trying this : https://learn.microsoft.com/en-us/azure/app-service-mobile/app-service-mobile-xamarin-forms-get-started-push, using VS 2017 portable Xamarin Forms project. Except UWP all other projects including IOS , Android and Portable library are getting installed with the Notificaiton nuget package. In UWP its always failing with the below error message. Thanks for your help.
Package Microsoft.Azure.NotificationHubs 1.0.9 is not compatible with uap10.0.10240 (UAP,Version=v10.0.10240) / win10-x86-aot. Package Microsoft.Azure.NotificationHubs 1.0.9 supports: net45 (.NETFramework,Version=v4.5)
As of July 2016 Notification Hubs SDK is not available for UWP. The product team is aware of it and working on providing it.
At the moment, there are one way to workaround it:
Use WindowsAzure.Messaging.Managed Nuget package as described in Getting started with Notification Hubs for Windows Universal Platform Apps
Certain Hubs SDKs are open sourced. But, unfortunately, not Windows ones at the moment.

Adding UWP option to Xamarin cross-platform application

I made a simple Xamarin cross-platform sqlite application for Android and IOS. I want to add Universal Windows Phone version too. To do that i followed this steps. I installed SQLite.Net-PCL from nuget manager. But i still need to write something for sqlite connection. In this link, at step 6 there is code for this but its for windows phone 8. Can you please help me?
Xamarin.Forms supports database-driven applications using the SQLite database engine, which makes it possible to load and save objects in shared code.
Xamarin.Forms applications can use the SQLite.NET PCL NuGet package to incorporate database operations into shared code by referencing the SQLite classes that ship in the NuGet. Database operations can be defined in the Portable Class Library (PCL) project of the Xamarin.Forms solution, with platform-specific projects returning a path to where the database will be stored.
But i still need to write something for sqlite connection. In this link, at step 6 there is code for this but its for windows phone 8. Can you please help me?
Windows 10 Universal Windows Platform (UWP)
Add the SQLite-net PCL NuGet to the UWP project by right-clicking and choosing Manage NuGet Packages.
Once the reference is added, implement the IFileHelper interface using the platform-specific Windows.Storage API to determine the data file path.
using Windows.Storage;
...
[assembly: Dependency(typeof(FileHelper))]
namespace Todo.UWP
{
public class FileHelper : IFileHelper
{
public string GetLocalFilePath(string filename)
{
return Path.Combine(ApplicationData.Current.LocalFolder.Path, filename);
}
}
}
Details please reference Xamarin.Forms Local Databases. The accompanying sample application is a simple Todo-list application.

I am developing iOS and Android app with Xamarin Forms in MAC. I am installing PCL Xamarin.Mobile, but i am getting error

The error i am getting while installing PCL. Any idea about below mentioned error?
Could not install package 'xamstore-xamarin.mobile 0.7.1'. You are
trying to install this package into a project that targets
'.NETPortable,Version=v4.5,Profile=Profile259', but the package does
not contain any assembly references or content files that are
compatible with that framework. For more information, contact the
package author.
From Xamarin Developer Matt Ward on the Xamarin Forums
The NuGet package xamstore-xamarin.mobile 0.7.1 only supports MonoAndroid and MonoTouch. It contains MSBuild property files for these two frameworks. You will not be able to install it into a Portable Class Library (PCL) project since it does not have any files that target any PCL framework.
Instead you should be able to add it to a Android or iOS project.
Similarly Xamarin.Mobile from the component store supports Android and iOS projects. It has assemblies for those platforms as well as for Windows Phone 7/8 and Windows 8 (WinRT). So you would be able to add that component into an Android or iOS project but not a PCL project.

Entity Framework Code First Approach to Xamarin.Forms PCL app

Can I have a .NET Class Library project with Entity Framework 6.1.1 (in windowsazure.mobileservices.backend.entity nuget package) work with Xamarin.Forms PCL app? Is this achievable? If not what are the possible complications?
Question Background:
I am working on a Xamarin.Forms cross platform PCL app with Azure Mobile Services back-end, targeting Android, iOS, Windows 8.1 and WinPhone 8.1. I actually dont care about Windows 8.1 but Visual Studio does not allow me to remove this target. So it stays.
Azure Mobile Services is setup, but I need the tables to be generated automatically (strongly avoiding manually typing table definitions in azure portal). I decided to go EF code first way with windowsazure.mobileservices.backend.entity nuget package to achieve this. However, the Xamarin.Forms PCL project does not support additional assemblies.
I am thinking of adding this package into a separate class library project and referring to it from the PCL project.
Thanks for your help!
The EntityData type is the required superclass of DTOs on the server SDK. Unfortunately, it has dependencies that are not supported in a PCL project, so it has to be used with a full .NET 4.5 project.
You could instead use partial classes to share DTOs between client and server. Just put all of the non system property types in a common code file that's shared between client and server. Then, on the client, add the system property implementation (ID field, UpdatedAt optionally, Version optionally). On the server, add another partial class definition that inherits from EntityData.

Resources