# Invoke Platform Code

{% hint style="warning" %}
Invoking platform code is only supported on [Wisej.NET Hybrid Local Applications](https://docs.wisej.com/hybrid/development/local-application)**.**
{% endhint %}

In situations where Wisej.NET Hybrid doesn't provide any APIs for accessing specific platform APIs, you can write your own code to access the required platform APIs. This requires knowledge of [Apple's iOS and MacCatalyst APIs](https://developer.apple.com/documentation/technologies?language=objc), [Google's Android APIs](https://developer.android.com/reference), and [Microsoft's Windows App SDK APIs](https://learn.microsoft.com/en-us/windows/windows-app-sdk/api/winrt).

Platform code can be invoked from cross-platform code by using conditional compilation, or by using partial classes and partial methods.

## **Example Project**

{% embed url="<https://github.com/iceteagroup/wisej-hybrid-examples/tree/main/PlatformCode>" %}

## **Examples**

**Registering for remote notifications on iOS:**

```csharp
// register for remote notifications in a Wisej.NET button click.
private void button1_Click(object sender, System.EventArgs e)
{
#if IOS
	// execute code on iOS UI Thread.
	CoreFoundation.DispatchQueue.MainQueue.DispatchAsync(() =>
	{
		// register for remote notifications.
		UIKit.UIApplication.SharedApplication.RegisterForRemoteNotifications();
	});
#endif
}
```

#### Determining what type of biometrics are supported on the device:

```csharp
private void button1_Click(object sender, System.EventArgs e)
{
#if IOS
	var context = new LocalAuthentication.LAContext();
	Foundation.NSError error = null;

	context.CanEvaluatePolicy(LocalAuthentication.LAPolicy.DeviceOwnerAuthenticationWithBiometrics, out error);

	if (error?.LocalizedDescription == null)
		AlertBox.Show(context.BiometryType.ToString());
	else
		AlertBox.Show(error?.LocalizedDescription);
#endif
}
```

{% hint style="warning" %}
You must also add the **NSFaceIDUsageDescription** key to the Info.plist file to use biometrics.
{% endhint %}

## Further Reading

{% embed url="<https://learn.microsoft.com/en-us/dotnet/maui/platform-integration/invoke-platform-code>" %}
Invoking Platform Code in .NET MAUI
{% endembed %}
