How To: Cross Platform Animations with iOS, Android & Windows

With the last post on Xamarin Forms we went over using GZip Compression with Xamarin Forms which helps reduce data going over mobile networks. In this post, we’ll be looking at how to perform some simple animations with Xamarin Forms.

At RedBit we have Kevin, our lead designer, who makes our software and customer software usable and visually appealing. When envisioning and designing a project he suggests subtle animations to provide within the app. Then as a team, along with the customer, decide on what works and what doesn’t and then implement it.

In this article we are going to look at simple animations and sliding a panel in and out from the right side of the screen using Xamarin Forms. This is the end result of this article

show-panel-full-wpshow-panel-full-droid show-panel-full-ios

Continue reading How To: Cross Platform Animations with iOS, Android & Windows

Getting Unique Device ID for iOS, Android and Windows with Xamarin

Over a year ago, I wrote a quick tip on getting device Unique ID for Windows and Windows Phone (8 & 7). Lately, at RedBit, we have been doing quite a bit of iOS, Android and Windows projects using Xamarin and recently put two articles up on our learnings, Cross Platform Animations using Xamarin Forms and GZip Compression with Xamarin Forms. For different reasons, we needed to use a unique ID to identify devices and getting the device ID on each platform is obviously different.

For iOS you can use the UIDevice.CurrentDevice.IdentifierForVendor which can be called from a Xamarin iOS or Xamarin Forms app.

UIKit.UIDevice.CurrentDevice.IdentifierForVendor.AsString();

For Android, again it’s a different API but note, that you need API Level 9 or higher for this to work. It is called as follows from Xamarin Android or Xamarin Forms

Android.OS.Build.Serial;

For Windows you can reference this post I wrote a while back Getting Device ID on Windows & Windows Phone.

At RedBit we have an internal library that we use and here is an excerpt of our RedBit.Mobile.Hardware class

public class Hardware
{
    private static Hardware _Default;
    public static Hardware Default
    {
        get
        {
            return _Default ?? (_Default = new Hardware());
        }
    }

    ///

    /// Gets a device unique identifier
    ///

public string DeviceId { get { return GetDeviceIdInternal(); } } ///
/// Gets a device unique identifier depending on the platform ///

/// string representing the unique id private string GetDeviceIdInternal() { var id = default(string); #if __IOS__ id = UIKit.UIDevice.CurrentDevice.IdentifierForVendor.AsString(); #elif WINDOWS_PHONE id = Windows.Phone.System.Analytics.HostInformation.PublisherHostId; #else id = Android.OS.Build.Serial; #endif return id; } }

I’ve put a sample up on GitHub that outputs the device ID for iOS, Android and Windows. Here is the output on iOS.

deviceId-ios

As always, comments welcome!

Using GZip Compression with Xamarin Forms

In a recent project the RedBit team worked on, we decided to use Xamarin.Form to  build an app for Windows Phone, iOS and Android. Xamarin Forms is still a v1 product but the Xamarin team is rapidly releasing updates to fill in some gaps. As a developer you still have the opportunity to extend Xamarin Forms, for example by building custom renderers. We’ll have a series of blog posts on some learnings from the team to help extend Xamarin.Forms and meet our client’s requirements.

For this first post we’ll be looking at how to implement GZip Compression across iOS, Android and Windows. The benefit to using GZip is there is less data going over the wire reducing mobile data consumption. In the US it’s not much of a problem to send large amounts of data because of unlimited data plans, but in Canada (and other parts of the world) data is not so cheap. In terms of compression, here is a chart showing the difference in data size making a request to http://en.wikipedia.org/wiki/Gzip.

To read more about how to use GZip Compression with Xamarin Forms head over to the RedBit post to see the entire walkthrough.

Killing Your iOS App using Xamarin

In the middle of a project where the team is building a customer app for iPad using Xamarin a requirement came up to automatically shut down the after a certain action was performed by the user.  Usually it’s recommended to not ‘kill’ your app on iOS and apps may fail certification if you do this.  Make sure to read the iOS documentation.

Now because we are doing an Enterprise Deploy and not an App Store Deploy, we were pretty safe.

I go in more detail in the post titled Exiting an iOS App using Xamarin on the Exiting an iOS App using Xamarin.