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 , , and .
Platform code can be invoked from cross-platform code by using conditional compilation, or by using partial classes and partial methods.
Example Project
Examples
Registering for remote notifications on iOS:
// 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:
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
}
You must also add the NSFaceIDUsageDescription key to the Info.plist file to use biometrics.