/api/program/on-mobile

GET

Detects whether the CloudCoin Console program is running on a mobile device platform.

Description

The `/api/program/on-mobile` endpoint determines if the CloudCoin Console server is running on a mobile device. This detection is based on platform architecture and operating system characteristics, including Android devices, iOS devices, and ARM-based mobile platforms.

💡 Use Cases

This endpoint is useful for:

  • Mobile-optimized UI selection - Automatically switch to touch-friendly interfaces
  • Feature availability checks - Some operations may be limited or unavailable on mobile
  • Platform-specific recommendations - Guide users to appropriate mobile workflows
  • Performance adjustments - Optimize batch sizes and timeouts for mobile networks
  • Storage path detection - Handle mobile-specific file system constraints
⚠️ Mobile Platform Detection

Mobile device detection is based on:

  • Android: Checks for __ANDROID__ compiler flag or Android system paths (/system/build.prop, /data/data)
  • iOS: Checks for iOS-specific compiler flags (TARGET_OS_IPHONE, TARGET_IPHONE_SIMULATOR)
  • ARM Architecture: Detects ARM processors commonly used in mobile devices
  • x86/x64 Desktop: Windows, Linux, and macOS on Intel/AMD processors return false

Note: ARM-based embedded devices (like Raspberry Pi) may not be detected as mobile if they lack Android-specific indicators.

Parameters

This endpoint does not require any parameters.

Response

Returns a JSON object indicating whether the program is running on a mobile device.

Response Properties

status string
Always "success" for this endpoint.
operation string
Always "program_on_mobile".
on_mobile boolean
true if running on a mobile device (Android, iOS, or mobile ARM platform), false if running on desktop (Windows, Linux, macOS on x86/x64).

Example Response (Desktop)

{
  "status": "success",
  "operation": "program_on_mobile",
  "on_mobile": false
}

Example Response (Mobile)

{
  "status": "success",
  "operation": "program_on_mobile",
  "on_mobile": true
}

Examples

JavaScript (fetch)

const API_HOST = 'http://localhost:8080';

async function checkMobilePlatform() {
    try {
        const response = await fetch(`${API_HOST}/api/program/on-mobile`);
        const result = await response.json();

        if (result.on_mobile) {
            console.log('Running on mobile device');
            // Enable mobile-optimized UI
            enableMobileUI();
        } else {
            console.log('Running on desktop');
            // Use standard desktop interface
            enableDesktopUI();
        }
    } catch (error) {
        console.error('Error checking mobile status:', error);
    }
}

function enableMobileUI() {
    // Adjust UI for touch interactions
    document.body.classList.add('mobile-mode');
    // Reduce batch sizes for mobile networks
    window.MAX_BATCH_SIZE = 10;
}

function enableDesktopUI() {
    document.body.classList.add('desktop-mode');
    window.MAX_BATCH_SIZE = 100;
}

checkMobilePlatform();

cURL

# Check if running on mobile device
curl -X GET "http://localhost:8080/api/program/on-mobile"

# With formatted output using jq
curl -X GET "http://localhost:8080/api/program/on-mobile" | jq '.'

Go

package main

import (
    "encoding/json"
    "fmt"
    "io/ioutil"
    "net/http"
)

const ApiHost = "http://localhost:8080"

type MobileResponse struct {
    Status    string `json:"status"`
    Operation string `json:"operation"`
    OnMobile  bool   `json:"on_mobile"`
}

func main() {
    resp, err := http.Get(fmt.Sprintf("%s/api/program/on-mobile", ApiHost))
    if err != nil {
        panic(err)
    }
    defer resp.Body.Close()

    body, _ := ioutil.ReadAll(resp.Body)

    var result MobileResponse
    if err := json.Unmarshal(body, &result); err != nil {
        panic(err)
    }

    if result.OnMobile {
        fmt.Println("CloudCoin Console is running on a mobile device")
        // Adjust application behavior for mobile
        maxBatchSize := 10
        fmt.Printf("Using mobile batch size: %d\n", maxBatchSize)
    } else {
        fmt.Println("CloudCoin Console is running on desktop")
        // Use standard desktop settings
        maxBatchSize := 100
        fmt.Printf("Using desktop batch size: %d\n", maxBatchSize)
    }
}

Python

import requests
import json

API_HOST = 'http://localhost:8080'

def check_mobile_platform():
    """Check if CloudCoin Console is running on mobile device"""
    try:
        response = requests.get(f'{API_HOST}/api/program/on-mobile')
        result = response.json()

        on_mobile = result.get('on_mobile', False)

        if on_mobile:
            print('Running on mobile device')
            # Adjust for mobile constraints
            config = {
                'max_batch_size': 10,
                'timeout': 30000,  # Longer timeout for mobile networks
                'enable_touch_ui': True
            }
        else:
            print('Running on desktop')
            # Use standard desktop configuration
            config = {
                'max_batch_size': 100,
                'timeout': 10000,
                'enable_touch_ui': False
            }

        print(f'Configuration: {json.dumps(config, indent=2)}')
        return config

    except requests.exceptions.RequestException as e:
        print(f'Error checking mobile status: {e}')
        return None

if __name__ == '__main__':
    check_mobile_platform()

Platform Detection Details

The mobile device detection uses compiler flags and file system checks to identify the platform:

// Pseudo-code showing detection logic
bool is_mobile_device(void) {
    #ifdef __ANDROID__
        return true;  // Android device
    #elif ARM_ARCHITECTURE
        // Check for Android-specific paths
        if (file_exists("/system/build.prop") ||
            file_exists("/data/data")) {
            return true;  // Android on ARM
        }
        return false;  // ARM but not mobile (e.g., Raspberry Pi)
    #elif iOS_PLATFORM
        return true;  // iOS or iOS simulator
    #else
        return false;  // x86/x64 desktop
    #endif
}
Platform Architecture Detection Method Returns
Android ARM/ARM64 __ANDROID__ flag or Android system paths true
iOS ARM64 TARGET_OS_IPHONE flag true
Windows x86/x64 Default (no mobile indicators) false
Linux x86/x64 Default (no mobile indicators) false
macOS x86/ARM Default (no iOS indicators) false
Raspberry Pi ARM ARM but no Android paths false

Practical Applications

1. Adaptive User Interface

Automatically adjust UI components based on mobile detection:

async function initializeUI() {
    const response = await fetch('/api/program/on-mobile');
    const result = await response.json();

    if (result.on_mobile) {
        // Mobile-specific adjustments
        document.body.classList.add('touch-enabled');

        // Larger touch targets
        document.querySelectorAll('button').forEach(btn => {
            btn.style.minHeight = '44px';
            btn.style.minWidth = '44px';
        });

        // Simplified navigation
        enableBottomNavigation();

        // Reduce visual complexity
        disableAnimations();
    }
}

2. Performance Optimization

Adjust batch sizes and timeouts for mobile network constraints:

async function getOptimalBatchSize() {
    const response = await fetch('/api/program/on-mobile');
    const result = await response.json();

    const config = {
        batchSize: result.on_mobile ? 10 : 100,
        timeout: result.on_mobile ? 30000 : 10000,
        retries: result.on_mobile ? 3 : 1,
        parallelRequests: result.on_mobile ? 2 : 10
    };

    return config;
}

async function detectCoins(coinFiles) {
    const config = await getOptimalBatchSize();

    // Process in smaller batches on mobile
    for (let i = 0; i < coinFiles.length; i += config.batchSize) {
        const batch = coinFiles.slice(i, i + config.batchSize);
        await processBatch(batch, config.timeout);
    }
}

3. Feature Availability

Disable or warn about resource-intensive features on mobile:

async function checkFeatureAvailability(feature) {
    const response = await fetch('/api/program/on-mobile');
    const result = await response.json();

    const mobileRestrictions = {
        'bulk-heal': 'Consider processing in smaller batches',
        'large-export': 'May be slow on mobile networks',
        'video-tutorials': 'Recommended to use WiFi connection'
    };

    if (result.on_mobile && mobileRestrictions[feature]) {
        showWarning(mobileRestrictions[feature]);
    }
}

Related Endpoints

/api/program/on-usb

Check if the program is running from a USB drive for portable wallet detection.

/api/program/status

Get comprehensive program status including version, active wallet, and server time.

/api/program/echo

Test RAIDA network connectivity with platform-aware timeout configurations.