Skip to main content
Glama

ios_push_notification

Simulate iOS push notifications for Lightning Network payment events to test notification flows and push setup in wallet development.

Instructions

Test payment notification flows and push setup

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
notificationTypeNoType of notification to simulatepayment_received
amountSatsNoAmount in satoshis (for payment notifications)

Implementation Reference

  • The main handler function for the 'ios_push_notification' tool. It calls iosService.testPushNotification(), incorporates input arguments, and appends implementation steps and Node.js server integration code.
    execute: async (args: any): Promise<ToolResult> => { try { const result = await iosService.testPushNotification(); return { content: [{ type: 'text', text: JSON.stringify({ ...result, notificationType: args.notificationType, amountSats: args.amountSats, implementationSteps: [ '1. Request notification permissions on app launch', '2. Register for remote notifications', '3. Handle notification tokens and updates', '4. Process Lightning events in background', '5. Display rich notifications with payment details', '6. Update app badge with pending actions' ], serverIntegration: ` // Server-side notification example (Node.js) import apn from 'apn'; class LightningNotificationServer { private provider: apn.Provider; constructor() { this.provider = new apn.Provider({ token: { key: process.env.APNS_KEY_PATH, keyId: process.env.APNS_KEY_ID, teamId: process.env.APPLE_TEAM_ID }, production: process.env.NODE_ENV === 'production' }); } async notifyPaymentReceived( deviceToken: string, paymentHash: string, amountSats: number, memo?: string ) { const notification = new apn.Notification({ alert: { title: "Payment Received", subtitle: memo || "Lightning Payment", body: \`You received \${amountSats.toLocaleString()} sats\` }, sound: "payment_received.wav", badge: 1, topic: "com.yourapp.bundle", payload: { type: "payment_received", paymentHash, amountSats }, pushType: "alert", priority: 10 }); const result = await this.provider.send(notification, deviceToken); if (result.failed.length > 0) { console.error('Notification failed:', result.failed[0].response); } return result; } }`.trim() }, null, 2) }] }; } catch (error) { return { content: [{ type: 'text', text: JSON.stringify({ success: false, error: error instanceof Error ? error.message : 'Unknown error' }, null, 2) }], isError: true }; } }
  • Input schema defining parameters for the tool: notificationType (enum) and amountSats (number).
    inputSchema: { type: 'object', properties: { notificationType: { type: 'string', enum: ['payment_received', 'channel_opened', 'channel_closed', 'sync_complete'], description: 'Type of notification to simulate', default: 'payment_received' }, amountSats: { type: 'number', description: 'Amount in satoshis (for payment notifications)', default: 1000 } } },
  • src/index.ts:20-20 (registration)
    Import of the pushNotificationTool from its definition file.
    import { pushNotificationTool } from './tools/iosPushNotification.js';
  • src/index.ts:38-62 (registration)
    Registration of pushNotificationTool in the tools array used by MCP server handlers for listTools and callTool requests.
    const tools = [ generateInvoiceTool, payInvoiceTool, getChannelStatusTool, getNodeInfoTool, backupStateTool, keychainTestTool, backgroundTestTool, pushNotificationTool, biometricAuthTool, createChannelTool, closeChannelTool, getBalanceTool, decodeInvoiceTool, listPaymentsTool, estimateFeeTool, generateMnemonicTool, deriveAddressTool, getSwiftCodeTool, getArchitectureTool, testScenarioTool, networkGraphTool, eventHandlingTool, chainSyncTool, ];
  • Helper method in IOSService class that provides comprehensive Swift code examples for iOS push notification setup, authorization, payment notifications, and integration with Lightning events. Called by the tool handler.
    async testPushNotification(): Promise<{ success: boolean; message: string; swiftCode: string; }> { const swiftCode = ` import UserNotifications import UIKit class LightningNotificationService { static func requestAuthorization() async -> Bool { do { let options: UNAuthorizationOptions = [.alert, .badge, .sound] let granted = try await UNUserNotificationCenter.current() .requestAuthorization(options: options) if granted { await MainActor.run { UIApplication.shared.registerForRemoteNotifications() } } return granted } catch { print("Notification authorization failed: \\(error)") return false } } static func notifyPaymentReceived(amountMsat: UInt64, description: String?) { let content = UNMutableNotificationContent() content.title = "Payment Received" content.body = "You received \\(amountMsat / 1000) sats" if let desc = description { content.subtitle = desc } content.sound = .default content.badge = 1 let request = UNNotificationRequest( identifier: UUID().uuidString, content: content, trigger: nil // Immediate delivery ) UNUserNotificationCenter.current().add(request) { error in if let error = error { print("Failed to deliver notification: \\(error)") } } } static func handleIncomingPayment(paymentHash: String) { // Fetch payment details from LDK guard let payment = ldkManager.getPayment(hash: paymentHash) else { return } // Show notification notifyPaymentReceived( amountMsat: payment.amountMsat, description: payment.description ) // Update app badge Task { @MainActor in UIApplication.shared.applicationIconBadgeNumber += 1 } } }`.trim(); return { success: true, message: 'Push notification test completed', swiftCode }; }

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/StevenGeller/ldk-mcp'

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