# Invoke Platform Code

{% hint style="warning" %}
Invoking platform code is only supported on [Wisej.NET Hybrid Local Applications](/hybrid/development/local-application.md)**.**
{% 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 %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.wisej.com/hybrid/development/invoke-platform-code.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
