全新功能即將推出!我們正在為你打造更多實用功能和更好的體驗 — 特別是為 DSE 2027 考生。敬請期待!🚀

安裝應用程式

將應用程式安裝到您的裝置以便快速存取

從主畫面快速存取

更快載入和離線支援

📱

在您的裝置上獲得類似應用程式的體驗

AdminHapticTest

Admin: Haptic & Push Test

Test haptic vibration patterns and push notifications on this device.

Detected iOS Bridge Handlers
window.webkit.messageHandlers is undefined

These are the exact message handlers your native iOS wrapper is currently exposing to the web app.

Device Capabilities
navigator.vibrate: Yes
iOS WKWebView Haptic: No
Native iOS App: No
Installed PWA: No
Push API: Yes
Notification Permission: denied

Haptics require a real device — Android Chrome (navigator.vibrate) or iOS native wrapper (WKWebView). The Base44 preview sandbox does not support vibration.

Haptic Vibration Test

Tap each button to trigger the vibration pattern. On a real phone, you'll feel the vibration.

Push Notification Test

Step 1: Enable notifications on this device. Step 2: Send a test push.

Step 1: Enable Push Notifications

This subscribes your current browser/device to receive push notifications.

Notification permission is denied. Go to your browser/device settings to allow notifications for this site.

Step 2: Send Test Push Notification

Note: Push notifications only work on the published app URL, not in the Base44 preview sandbox. The service worker must be registered on the actual domain.

iOS Developer Setup Guide

Standard WKWebView on iOS does not support vibration or web push automatically. To make these tests work, your iOS wrapper developer must add the following Swift code to your WKWebViewConfiguration.

// 1. In your ViewController, add WKScriptMessageHandler
class ViewController: UIViewController, WKScriptMessageHandler {

    override func viewDidLoad() {
        super.viewDidLoad()
        
        let contentController = WKUserContentController()
        
        // Add the required handlers
        contentController.add(self, name: "haptic")
        contentController.add(self, name: "pushPermission")
        
        let config = WKWebViewConfiguration()
        config.userContentController = contentController
        
        let webView = WKWebView(frame: view.bounds, configuration: config)
        // ... load URL
    }

    // 2. Handle the messages
    func userContentController(_ userContentController: WKUserContentController, didReceive message: WKScriptMessage) {
        if message.name == "haptic" {
            let generator = UIImpactFeedbackGenerator(style: .medium)
            generator.prepare()
            generator.impactOccurred()
        }
        else if message.name == "pushPermission" {
            // Request native push permissions
            UNUserNotificationCenter.current().requestAuthorization(options: [.alert, .sound, .badge]) { granted, error in
                if granted {
                    DispatchQueue.main.async {
                        UIApplication.shared.registerForRemoteNotifications()
                    }
                }
            }
        }
    }
}

// 3. In AppDelegate.swift (Return token to web view)
func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
    let tokenParts = deviceToken.map { data in String(format: "%02.2hhx", data) }
    let token = tokenParts.joined()
    
    // IMPORTANT: Send the APNs token back to the web view
    // Assuming 'webView' is accessible here
    let js = "if(window.setNativePushToken) { window.setNativePushToken('\(token)') }"
    webView.evaluateJavaScript(js, completionHandler: nil)
}