My application NotifyMe is growing slowly, I am glad it is growing at all. Anyway, I decided to connect it to Visual Studio Mobile Center portal.
It is a set of cloud services for building and managing mobile application.
Visual Studio Mobile Center has three main adventages. It allows to:
– collect crash reports with user analytics
– add cloud-based authentication and table storage
– build application automatically and distribute it to testers
Today I am going to focus on the first paragraph, and I will show you in steps how you can do it in your application.
First, create an account https://mobile.azure.com/login. The fastest way is to authenticate through GitHub or Microsoft Account.
And add new application to manage. For android:
And for iOS:
My app is written in Xamarin.Forms but I had to add my app twice, separately for every platform.
Next you will get a specific instructions how to connect Mobile Center to your application.
First step is to add these nuget packages:
Second and last step is to add MobileCenter.Start(…) method in specific place in application code. It depends on the platform. Done. It is simple isn’t it? 🙂
To collect data about usage I prepared logger component.
public interface IMobileCenterLogger { void TrackEvent(string userName, EventType type); void TrackCrash(Exception ex); }
And its implementation.
public class MobileCenterLogger : IMobileCenterLogger { public void TrackEvent(string userName, EventType type) { var name = Enum.GetName(typeof(EventType), type); var properties = new Dictionary<string, string>(); properties.Add(nameof(userName), userName); Analytics.TrackEvent(name, properties); } public void TrackCrash(Exception ex) { var properties = new Dictionary<string, string>(); properties.Add("Message", ex.Message); Analytics.TrackEvent("Crash" ,properties); } }
Now I have an ability to track every user in application. For example myself. As you can see I did basic operations in my application.
Visual Studio Mobile Center except custom events can provide other helpful information. For example:
- count of active users
- average session duration
- users devices
- languages
- countries with pretty nice map
After connection I have also crash reports without any single line of code. Every unhandled crash is stored with a simple but really helpful stacktrace.
(If you going to test it in your app, notice that crashes can be catched by Mobile Center only in Release configuration )
No more to say, this is a powerful tool and it will be more better in few months.
Here is a product roadmap https://docs.microsoft.com/en-us/mobile-center/general/roadmap.
Don’t waste your time and check it while it is for free.