Skip to main content
Glama
KeyboardRouteHandler.swift1.11 kB
import Foundation import XCTest import FlyingFox import os @MainActor struct KeyboardRouteHandler: HTTPHandler { func handleRequest(_ request: FlyingFox.HTTPRequest) async throws -> FlyingFox.HTTPResponse { guard let requestBody = try? await JSONDecoder().decode(KeyboardHandlerRequest.self, from: request.bodyData) else { return AppError(type: .precondition, message: "incorrect request body provided for input text").httpResponse } do { let appId = RunningApp.getForegroundAppId(requestBody.appIds) let keyboard = XCUIApplication(bundleIdentifier: appId).keyboards.firstMatch let isKeyboardVisible = keyboard.exists let keyboardInfo = KeyboardHandlerResponse(isKeyboardVisible: isKeyboardVisible) let responseBody = try JSONEncoder().encode(keyboardInfo) return HTTPResponse(statusCode: .ok, body: responseBody) } catch let error { return AppError(message: "Keyboard handler failed \(error.localizedDescription)").httpResponse } } }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/mobile-dev-inc/Maestro'

If you have feedback or need assistance with the MCP directory API, please join our Discord server