Skip to content

Keyboard

iOS, Android

The Background Task API makes it easy to run background tasks. Currently, this plugin supports running a task when the app is backgrounded, and soon will support periodic background fetch operations.

Methods

KeyboardBridge.RegisterEventListeners()

KeyboardBridge.Show()

KeyboardBridge.Hide()

KeyboardBridge.SetAccessoryBarVisible()

KeyboardBridge.AddEventListener()

KeyboardBridge.RemoveEventListener()

Example

    private static async Task KeyboardShow() {
        try {
            await KeyboardBridge.Show();
        }
        catch (Exception e) {
            // Handle error
        }
    }

    private static async Task KeyboardSetAccessoryBarVisible() {
        try {
            await KeyboardBridge.SetAccessoryBarVisible(true);
        }
        catch (Exception e) {
            // Handle error
        }
    }

    private static async Task KeyboardSetAccessoryBarHidden() {
        try {
            await KeyboardBridge.SetAccessoryBarVisible(false);
        }
        catch (Exception e) {
            // Handle error
        }
    }

    private static async Task KeyboardHide() {
        try {
            await KeyboardBridge.Hide();
        }
        catch (Exception e) {
            // Handle error
        }
    }

    private static async Task KeyboardEvents() {
        try {
            await KeyboardBridge.RegisterEventListeners();

            KeyboardBridge.AddEventListener(KeyboardEvent.KeyboardWillShow, (e) =>
                Console.WriteLine($"Received KeyboardWillShow event: {e}"));
            KeyboardBridge.AddEventListener(KeyboardEvent.KeyboardDidShow, (e) =>
                Console.WriteLine($"Received KeyboardDidShow event: {e}"));
            KeyboardBridge.AddEventListener(KeyboardEvent.KeyboardWillHide, (e) =>
                Console.WriteLine($"Received KeyboardWillHide event: {e}"));
            KeyboardBridge.AddEventListener(KeyboardEvent.KeyboardDidHide, (e) =>
                Console.WriteLine($"Received KeyboardDidHide event: {e}"));
        }
        catch (Exception e) {
            // Handle error
        }
    }

API

RegisterEventListeners

Initializes event listeners to allow for updates. Use AddEventListener to add listener function for specific event.

static Task<object> RegisterEventListeners()

Show

Show the keyboard. This method is alpha and may have issues

static Task<object> Show()

Hide

Hide the keyboard.

static Task<object> Hide()

SetAccessoryBarVisible

Set whether the accessory bar should be visible on the keyboard. We recommend disabling the accessory bar for short forms (login, signup, etc.) to provide a cleaner UI

static Task<object> SetAccessoryBarVisible(bool isVisible)

AddEventListener

Subscribe to keyboard events.

static void AddEventListener(KeyboardEvent eventType, Action<string> callback)

RemoveEventListener

Unsubscribe to keyboard events.

static void RemoveEventListener(KeyboardEvent eventType, Action<string> callback) {

Models

KeyboardEvent

    public enum KeyboardEvent {
        KeyboardWillShow,
        KeyboardDidShow,
        KeyboardWillHide,
        KeyboardDidHide
    }

Comments