0
votes

I know about xamarin connection with SQLite but it is locally

I need to connect my remotely MySQL database with xamarin.forms (I know about the security issue of this without using web services layer, but i will only use it for my own work)

This plugin is for xamarin.iOS and Xamarin.Android

I cannot add it using dependency service because i cannot add this component to the shared project

So is there any example of connecting MySQL database with xamarin.forms

1
You add the component to each platform project, and use DI to access it from the shared PCL project. You don't add the component to the shared project - Jason

1 Answers

3
votes

You can't add references to your shared library. Shared libraries act like a list of files that are directly included in the project. The advantage of shared projects is just, that you do not have to maintain these included files for each project that uses code of the contained files. See the Xamarin documentation for further explanation.

What you have to do, if you want to consume a 3rd party libray within a shared library: Add the library to each project that uses the shared library (e.g. your iOS and Android project)

2ct to the mentioned security issue

You are right about the security issue. That's why I'd advice against, using mysql directly from your app. (I'll explain it for other readers that aren't aware of this problem and stumble over this question)

You should tunnel it through HTTPS because:

  1. Some networks just block certain ports (HTTP and HTTPS are usually not blocked)
  2. You publish your credentials with your app either statically or dynamically, but the credentials to your database are interceptable either way. You should authenticate a user and not an app. So there should be some kind of authentication / authorization that is revokeable. There was a nice talk from Kerry Lothrop on the Xamarin Evolve 2016 on this topic. https://www.youtube.com/watch?v=uLFtQHNxGaI