Integrating Firebase Auth in Xamarin.Forms is very easy and basic authentication flow implementation can be achieved under 20 lines of code. There is more work with settings than code writing. In this article we will:
- Configure Firebase app
- Create Xamarin.Forms application to authenticate users via Firebase Auth
- Create a .NET Core WEB API project to validate Firebase Auth token and return simple data
Continue reading “Firebase authentication in Xamarin.Forms”
Every time you create a new Xamarin.Forms project in Visual Studio for Mac you have to manually convert it to .NET Standard. The conversion is very straightforward and can be done with just a few steps:
How to Convert a Portable Class Library to .NET Standard and Keep Git History
- Unload your PCL project (right click -> unload), and start editing it (right -> click edit)
- Delete Everything in the csproj and insert this:
<!--<PackageReference Include="" Version=""/>-->
- Add back NuGets (simply open packages.config, and add the package references above, or via the NuGet package manager.
- Delete AssemblyInfo.cs (this is now in the csproj) and packages.config (also in csproj via PackageReference)
Hopefully one day VS team will take care of it, till then, I decided to automate this process and created an add-in/extension for VS for Mac – Mutatio.
Mutatio – in Latin means change, transformation or exchange.
Mutatio can convert newly created or existing projects. Please keep in mind that there might be
NuGet packages that does not support .NET Standard 2.0, in this case you may see related exceptions.
In case you change your mind and you want to rollback,
Mutatio is making a backup of all the files it modifying and deleting under the project’s root directory within
mutatio_backup folder. So all you have to do is to copy the files back to your project and reload the solution.
One of the biggest challenges I met while development was related to reloading the project after conversion. Within VS for Mac after manually modifying the
*.csproj under the right click menu of the project there will appear a
Reload option, however I didn’t find a way to call this method programatically. Currently, the whole solution will be reloaded as a workaround. If you know how to solve the problem programatically I would really appreciate if you will share your knowledge by contributing or leaving a comment.
More details can be found on GitHub.
What can feel better than writing a code? Of course deleting it!
There are many good technical articles that explain why .NET Standard is great and why should we use it. My goal in this article is to demonstrate some benefits in practice.
If you didn’t switch yet from
Shared Projects to .NET Standard, I would highly recommend to do it. Most of the third party libraries are compatible and the switch is usually painless. After switching to .NET Standard you could benefit from reducing the code size and the amount of “hacks”. Let’s take a look on few practical examples. Continue reading “Reducing the amount of code by switching to .NET Standard”
Very often I hear questions like “Is there any Facebook SDK for Xamarin.Forms? Because there is one for Android Xamarin Native.”. This kind of questions can apply to different SDK that are compatible only with specific platforms and cannot be consumed directly in Xamarin.Forms. The answer to these questions usually is “If there is an available native Xamarin SDK it can be consumed in your Xamarin.Forms project. All you have to do is to create an abstraction like you would do with any other platform specific code.”.
As you might already understand, in this article we will create an abstraction over Xamarin.Facebook.Android and Xamarin.Facebook.iOS in order to display a native Facebook Login Button and handle the authentication related events in our Xamarin.Forms application.
Continue reading “Using Native Facebook Login Button in Xamarin.Forms”
Being lucky to develop a backend and a Xamarin.Forms clients on your own? Sooner or later you will have to debug the API calls and it might become painful. Unless, you will follow the next rules:
- Configure your API URL to run on 127.0.0.1 instead of a localhost:
// .NET Core Web.Api example
public static IWebHost BuildWebHost(string args) =>
- Configure your Xamarin.Forms API consumer to have a conditional URL base:
string apiUrl = null;
if (Device.RuntimePlatform == Device.Android)
apiUrl = “http://10.0.2.2:5001/api“;
else if (Device.RuntimePlatform == Device.iOS)
apiUrl = “http://localhost:5001/api“;
throw new UnsupportedPlatformException();
The problem with Android emulator is that it maps 10.0.2.2 to 127.0.0.1, not to localhost. However, the iOS Simulator uses the host machine network.
That should be it!
Many years ago when I was at high school, I wrote a bot for a web browser flags quiz game, where a flag of a random country and 4 different country names where shown to the player. It was fun!
So I created the same game for iOS and Android using Xamarin.Forms just for fun. It is open source and available on github:
This is what you get when an engineer creating a game without a designer. Luckily you can contribute if you have an idea on how to improve the UI/UX or if you want to add new features. I had a couple of them in my head:
- Learning game mode (without time or a game over)
- [X] game mode – where the flag image is covered by some objects that the player has to remove and/or etc.
If you are new to Xamarin.Forms or MVVM I would recommend to check the source code, it is touching the next interesting topics:
- ViewModel first navigation
- Custom fonts
Otherwise you are free to use the source code as you wish since it is under MIT license.
Stack Overflow is the largest, most trusted online community for developers to learn, share their programming knowledge, and build their careers.
This is the official definition of this website, and I have nothing to add or remove from it. Being an official member for 4 years and 11 months, according to my profile data, I spent many hours on C#, Android, Xamarin and Xamarin.Forms tags and I am worried.
It seems like the quality of the questions is decreasing and decreasing. The most popular question is “How to deserialise a JSON” with all its variations or “I have a problem” and a screenshot. This kind of questions have been always asked, however lately it feels like an epidemy.
What goes on the internet stays on the internet.
The questions we ask, the answers we make are publicly visible and can be used to measure our competency. Beside that, please always keep in mind that someone is going to spend time on trying to solve our issues. Let’s respect the community.
Before posting a new question please make sure that:
- The question haven’t been asked before.
- The title and the description should be easy to understand and to follow.
- Do not post screenshots of exceptions, logs or stack-traces. Share them as a plain text instead.
- Do post screenshots or images to demonstrate the problem you are trying to solve, if you think it is necessary.
- Always provide code snippets or describe how did you try to solve the problem yourself.
- Re-read your question at least 2-3 times before posting it.
Before answering a question please make sure that:
- The question haven’t been answered before. In case it was answered already just mark the question as a duplicate.
- You fully understand the question and see the problem. If in doubt ask questions in comments or start a chat.
- Always let the authors fix their own code. Describe the solution in plain text unless code is really necessary or unless the author is a total beginner.
- Review the code and suggest improvements beside the answered question.
- Downvote or vote to close only for a good reason.
- Do not answer with a link, instead share the main piece of the information in addition to a link so if the link will die there will be still a short reference.
I believe that following those simple rules we will make Stack Overflow a greater place.
Recently had to update some old Xamarin.Forms project to the latest and greatest XF and very quickly I realised that it is not going to be an easy task, since I had to manually manipulate the csproj files to remove the old nuget dependencies. I found myself going thru multiple projects multiple times in order to delete the “bin”, “obj” & “packages” directories to fix the miscellaneous build errors and I came up with a very simple script to recursively delete delete the “bin”, “obj” & “packages” directories:
||# Recursively find and delete "bin", "obj" and "packages" dirs
||# Backup your code before using this script, I am not responsible for any data loss. Please use it wisely.
||find . -iname "bin" -o -iname "obj" -o -iname "packages" | xargs rm -rf
Backup your code before using this script, I am not responsible for any data loss. Please use it wisely.
To use this script: open a terminal in your solution’s root directory and copy paste the script above. Keep in mind that “bin” & “obj” directories will be regenerated after the next build, however “packages” directory will appear again only after restoring nuget packages for the solution.
Recently I updated my macOS to High Sierra however this broke my android emulators. Non of them started and logs showed something like:
Failed to open vm 3
Failed to create HAX VM
No accelerator found.
failed to initialize HAX: Invalid argument
As the logs states there is a problem with HAXM, and to be more specific a time for update has come. To solve the issue simply download the latest and greatest version of HAXM and restart your mac.