Posts

Xamarin Forms + Parse + Push Notifications + Android = trouble

Image
Quick Introduction It took me some times to implement Parse's push notifications in my Xamarin Forms (Android) application. I find out some issues and made workarounds. Strangely, I have the impression that I'm a rare guy working with Xamarin Forms and Parse... But maybe you are in the same situation that I was. So just read the following. The context I'm actually making a (cool) Xamarin Forms app (maybe I will talk about it later in another post). One of my final steps is to implement Push notifications. Details of the context of my project are the following: - Xamarin Forms (Android & iOS) app - I use Parse server for my business server. Actually I host my Parse server at  https://parse.buddy.com for convenient reasons but I could host it on many other servers. - So logically, for the push notifications, I would like to use Parse push notification service. - In order to use Parse Services, I use Parse .NET SDK (latest available version is v.1.7.0

Shuffle List in C#

Image
Yesterday, I was looking for an algorithm to shuffle a list of objects in C#. So in my mind, I started to think about "complex" algorithms to do that, using random numbers and list elements switching... I say "complex" because while I was googling, I found a good solution to do that ! And it takes only 1 line :p I would have never thinked of that :) :) Here is the cool code: var shuffledList = myObjectList.OrderBy(item => Guid.NewGuid()); So, that's really simple. You can use the "OrderBy()" Linq extension to rearrange the list. This method will take a 'random' object, in this case a GUID. And we know that GUIDs are 'unique' so, it does the job! You can use variants like this one: var rnd = new Random(); var shuffledList = myObjectList.OrderBy(rnd.Next()); Next step, compare performances, between different solutions...

Visual Studio for MAC, review (fr)

Image
If you are a developer, there are many chance that you already used Visual Studio, the famous Microsoft's IDE. Visual Studio for MAC is borned a few weeks ago . But is it a productive tool like on PC ? If you are a Xamarin Developer and never tried it, I suggest you to take a look at this short review to get some clues ! This review is avaible in french on mobilissime.fr : http://www.mobilissime.fr/index.php/2017/06/20/visual-studio-pour-mac-petite-revue-de-lide/

[Xamarin Forms] Custom bottom bordered entry (iOS & Android)

Image
Custom entry with renderers For my Xamarin Forms project I needed to render an 'Entry' control with a bottom border of a specific color. There are several possibilities but I will show you mine. For that, I used renderers. iOS one is particularly not trivial. The wished result look like that: iOS Renderer [assembly: ExportRenderer(typeof(ExtDatePicker), typeof(ExtDatePickerRenderer))] namespace MyCompany.iOS.Renderers { public class ExtDatePickerRenderer : DatePickerRenderer { protected override void OnElementChanged(ElementChangedEventArgs<DatePicker> e) { base.OnElementChanged(e); // Need to connect to Sizechanged event because first render time, Entry has no size (-1). if (e.NewElement != null) e.NewElement.SizeChanged += (obj, args) => { var xamEl = obj as DatePicker; if (xamEl == null) ret

[Xamarin Forms] build error: Unable to cast object of type 'Xamarin.Forms.Xaml.ElementNode' to type 'Xamarin.Forms.Xaml.ValueNode'

Image
Xaml build error For one of my Xamarin project, I just had this build error: This error was related to my XAML code : Unable to cast object of type 'Xamarin.Forms.Xaml.ElementNode' to type 'Xamarin.Forms.Xaml.ValueNode' After searching for a long 'moment', I just didn't understand what happened... My investigation (this process can help you :p) So I decided to remove a large part of my xaml code and then re-add it little by little. Each step I tried to compile to see when error occurs. So In my case, I determined that the piece of code that was going wrong was the following: Ok, it was my mistake but in the code editor, Visual Studio didn't tell me anything. I was trying to bind an event ( I though it was a property ) to a DateTime property... What is not possible. Hope this helps someone to save a few minutes :)

Parse for Xamarin Forms - No PCL, my solution with conditional builds

Image
About Parse In my previous article (or next, we will see ;) I talk about Parse BaaS. This is a 'Back end As Services' that offers you simple but really convenient back end capabilities for storage but also managing users... I approach why I choose this technology for my mobile application, looking for advantages and drawbacks. Parse, after being purchased by Facebook, was closed last year, but fortunately, the source code is open source and Parse still exists . So you can install your own server or use the new Parse on Buddy platform for instance. You can take a look here:  https://buddy.com/parse/ The problem with Parse for Xamarin Forms So, actually the problem is that we can find .NET Xamarin SDK but specifically for iOS and Android frameworks. There is no SDK for Xamarin Forms. The ideal solution could be the following: Many 'pseudo' solutions can be found on internet but I will give you mine, using conditional builds in Visual Studio. I

[Xamarin Forms] XAML previewer in Visual Studio 2017 (really slow)

Image
Preview my Xamarin Forms XAML ? Today, I started a new Xamarin Forms application and for that I decided to use Visual Studio 2017 Community edition. Why ? Because I know that this version includes interesting features to me. One of this feature is that we can preview our Xamarin Forms XAML pages (theorically in a better way than in VS2015). First, we have to notice that to preview XF XAML pages, we don't use the exact same way as with  traditional XAML pages. In fact what we are looking for is not the designer but the Xamarin Forms Previewer Window . Take a look at the next steps to understand the differences...  There is not a lot of details on Xamarin Web site: https://developer.xamarin.com/guides/xamarin-forms/xaml/xaml-previewer/ XAML Designer vs Xamarin Forms Previewer On a XF XAML page, right click on the code: Using traditional "Designer menu" as for traditional XAML page We got an error Then use the previewer ( menu VIEW\Other Wi

[Fast&Furious guide] VS 2017, how to change IDE's language

Image
Visual Studio is now available to download. In my case, I used the english web installer to install the english version. But I was a little bit surprised (or not) to see that the installed version was setup with the same language as my operating system. So here is the simple steps to change the IDE's language: 1- Run Visual Studio 2017 installer (in administrator mode) then click"update" button of the instance you want to update: 2- Then click on the language modules tab 3- Then check all languages you want to use in your IDE 4- Restart Visual Studio then go to Menu / TOOLS / Options / (Environnement - International Settings) menu 5- Finally choose your prefered language in the languages combobox. Note that you can choose 'Same as Microsoft Windows' option. Restart and enjoy programming !