Getting Started With Visual Studio Mobile Center In Xamarin iOS

Introduction

Xamarin is a platform to develop cross-platform and multi-platform apps (for example, Windows phone, Android and iOS). In Xamarin platform, the code sharing concept is used. In Xamarin Studio, Visual Studio is also available.

Visual Studio Mobile Center is a mission control for your mobile apps.

Bring your apps written in any language to Visual Studio Mobile Center’s Cloud and lifecycle Services. You will get faster release cycles, higher-quality apps and the time and data to focus on what the users want. Learn more.
Prerequisites
  • Xamarin Studio.
  • Xcode.
  • Mobile Center account
The steps given below are required to be followed in order to create a Crash Report, using Visual Studio Mobile Center in Xamarin iOS, using Xamarin Studio.

Go to the link https://mobile.azure.com and log in with your credentials

Step 1

After login to Mobile Center, create a New App in Mobile Center site.

Add New—> Add New app.

 
 
Step 2

In this step, give your app Name (Ex:XamainiosCrashreport) and description. 
  1. OS:iOS
  2. Platform:Xamarin
Afterwards, click Add New app.
 
 

Step 3

In this step, go to Manage App and general information. Copy your app secret key.



Step 4

Go to Xamarin Studio.

Click New Solution—> select iOS—>select App--> Choose Sngle View App. Afterwards, click Next.

 

Step 5

In this step, configure your app. Give the app name (Ex:sample), Organization Identifier. Afterwards, click Next.

 
 
Step 6

In this step, give your project name (Ex: Sample) and solution name (Ex: Sample). Give the path of your project. Afterwards, click Create.

 

Step 7

Subsequently, go to the Solution. In the solution, get all the files and sources in your project. Now, select Main.storyboard and double click to open Main.storyboard page.
 
 

Step 8

After opening the Main.storyboard, you can design this page, as per your desire.
 
 

Step 9

In this step, design your app, using storyboard and Toolbox.

Button (btnCrash)
 
 

Step 10

In this step, add two packages in your project.
  1. Mobile Center
  2. Mobile Center Crashes
Go to Solution Explorer—>Package—>Add Package.

Now, choose Mobile Center, Mobile Center crashes and select Version. Afterwards, click Add Package.

 

Step 11

In this step, go to ViewController.cs page. Write the code given below.

ViewController.cs
  1. using System;  
  2. using UIKit;  
  3. using Microsoft.Azure.Mobile;  
  4. using Microsoft.Azure.Mobile.Crashes;  
  5. namespace XamariniOSCrashReport {  
  6.     public partial class ViewController: UIViewController {  
  7.         public  
  8.         const string MOBILE_CENTER_ID = "8f7b790d-cafc-4555-ad29-5a784375ac89";  
  9.         protected ViewController(IntPtr handle): base(handle) {  
  10.             // Note: this .ctor should not contain any initialization logic.  
  11.         }  
  12.         public override void ViewDidLoad() {  
  13.             base.ViewDidLoad();  
  14.             MobileCenter.Start(MOBILE_CENTER_ID, typeof(Crashes));  
  15.             // Perform any additional setup after loading the view, typically from a nib.  
  16.         }  
  17.         partial void BtnClick_TouchUpInside(UIButton sender) {  
  18.             throw new NotImplementedException("Not Implement Exception");  
  19.         }  
  20.         public override void DidReceiveMemoryWarning() {  
  21.             base.DidReceiveMemoryWarning();  
  22.             // Release any cached data, images, etc that aren't in use.  
  23.         }  
  24.     }  
  25. }  


Step 12

Now, go to Run option, choose Debug and the list of iPhone and iPad Simulators, which are available. You can choose any one Simulator and run it.
 
 

Output

After a few seconds, the app will start running on your iPhone Simulator.You will see your app working successfully.

 
 
You can click Button app will crash.



Now, you can go to Mobile Center and the Crash Report will be written successfully.



Summary

This was the process of how to create a Crash Report, using Visual Studio Mobile Center in Xamarin iOS, using Xamarin Studio.