Other Xamarin APIs

Adjust the log level

You can control the amount of log messages that show up from Mobile Center in the console. Use the LogLevel-API to enable additional logging while debugging. By default, it is set to ASSERT for the App Store environments and WARN otherwise.

To have as many log messages as possible, use LogLevel.Verbose.

MobileCenter.LogLevel = LogLevel.Verbose;

Identify installations

The Mobile Center SDK creates a UUID for each device once the app is installed. This identifier remains the same for a device when the app is updated and a new one is generated only when the app is re-installed. The following API is useful for debugging purposes.

System.Guid installId = await MobileCenter.GetInstallIdAsync();

Disable all services at runtime

If you want to disable all Mobile Center services at once, use the Enabled property. When disabled, the SDK will not forward any information to Mobile Center.

MobileCenter.SetEnabledAsync(false);

To enable all services at once again, use the same API but pass true as a parameter.

MobileCenter.SetEnabledAsync(true);

You don't need to await this call to make other API calls (such as IsEnabledAsync) consistent.

Check if Mobile Center is enabled

You can also check if Mobile Center is enabled or not.

bool enabled = await MobileCenter.IsEnabledAsync();

Use custom properties

Mobile Center allows you to define custom properties as key value pairs in your app. You may use custom properties for various purposes. For instance, you can use custom properties to segment your users, and then send push notifications to a specific audience.

You can set custom properties by calling the SetCustomProperties() API. A valid key for custom property should match regular expression pattern ^[a-zA-Z][a-zA-Z0-9]*$. A custom property's value may be one of the following C# types: string, int, long, double, float, decimal, bool and DateTime.

CustomProperties properties = new CustomProperties();
properties.Set("color", "blue").Set("score", 10).Set("now", DateTime.UtcNow);
MobileCenter.SetCustomProperties(properties);
Note

If you set the same custom property more than once, previous values will be overwritten by the last one.

You may remove any custom property by calling the Clear() API. This will only remove the value of the property for a device. It will not remove the property name from Mobile Center portal.

CustomProperties properties = new CustomProperties();
properties.Clear("score");
MobileCenter.SetCustomProperties(properties);