跳到主要内容

Mobile Integration

TinyEmulator uses Capacitor 7.0 for native mobile app builds.

Supported Platforms

PlatformStatusBuild Command
iOS✅ Readynpm run build-ios
Android✅ Readynpm run build-android
HarmonyOS✅ Readynpm run build-harmony

Capacitor Configuration

// capacitor.config.json
{
"appId": "com.xxyx.emulator",
"appName": "TinyEmulator",
"webDir": "dist",
"plugins": {
"StatusBar": {
"overlaysWebView": false
}
}
}

Native Plugins

TinyEmulator includes the following Capacitor plugins:

PluginPurpose
@capacitor/appApp lifecycle management
@capacitor/hapticsVibration feedback
@capacitor/shareNative share sheet
@capacitor/status-barStatus bar control
@hugotomazi/capacitor-navigation-barAndroid navigation bar
capacitor-plugin-safe-areaSafe area insets

Building iOS App

# 1. Build the web assets
npm run build-ios

# 2. Open Xcode
npx cap open ios

# 3. Archive and publish to App Store

Building Android App

# 1. Build the web assets
npm run build-android

# 2. Open Android Studio
npx cap open android

# 3. Build APK / AAB

Building HarmonyOS App

# Build as single file (for HarmonyOS WebView)
SINGLE_FILE=true TARGET=HARMONY vite build --mode harmony

URL Scheme Integration

TinyEmulator registers the tinyemulator:// URL scheme for deep linking.

Open the app from a web page

<a href="tinyemulator://startup?core=nes&rom=game.nes">
Open in TinyEmulator App
</a>

Smart Lancher

The lancher page handles app detection:

// Mobile: tries to open app, falls back to download
// Desktop: redirects to web emulator
import CallApp from 'callapp-lib';

const lib = new CallApp({
scheme: 'tinyemulator://',
path: 'startup',
outChain: {
path: '',
params: {}
}
});

lib.open({ path: '/startup', param: { core: 'nes' } });

Custom App Integration

To embed TinyEmulator into your own mobile app:

1. WebView Integration

// iOS - WKWebView
let webView = WKWebView(frame: .zero)
webView.load(URLRequest(url: URL(string: "https://play.tinyemulator.com")!))
// Android - WebView
val webView = WebView(context)
webView.settings.javaScriptEnabled = true
webView.loadUrl("https://play.tinyemulator.com")

2. Capacitor Integration in Your App

# Install TinyEmulator as a dependency
npm install github:SowrdLonn/tinyemulator

# Use as a Capacitor plugin
npx cap add ios
npx cap add android