Skip to main content
Glama
RunningAppRouteHandler.swift1.44 kB
import FlyingFox import XCTest import os @MainActor struct RunningAppRouteHandler: HTTPHandler { private let logger = Logger( subsystem: Bundle.main.bundleIdentifier!, category: String(describing: Self.self) ) private static let springboardBundleId = "com.apple.springboard" func handleRequest(_ request: FlyingFox.HTTPRequest) async throws -> FlyingFox.HTTPResponse { guard let requestBody = try? await JSONDecoder().decode(RunningAppRequest.self, from: request.bodyData) else { return AppError(type: .precondition, message: "incorrect request body for getting running app id request").httpResponse } do { let runningAppId = requestBody.appIds.first { appId in let app = XCUIApplication(bundleIdentifier: appId) return app.state == .runningForeground } let response = ["runningAppBundleId": runningAppId ?? RunningAppRouteHandler.springboardBundleId] let responseData = try JSONSerialization.data( withJSONObject: response, options: .prettyPrinted ) return HTTPResponse(statusCode: .ok, body: responseData) } catch let error { return AppError(message: "Failure in getting running app, error: \(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