將應用程式安裝到您的裝置以便快速存取
從主畫面快速存取
更快載入和離線支援
在您的裝置上獲得類似應用程式的體驗
Test haptic vibration patterns and push notifications on this device.
These are the exact message handlers your native iOS wrapper is currently exposing to the web app.
Haptics require a real device — Android Chrome (navigator.vibrate) or iOS native wrapper (WKWebView). The Base44 preview sandbox does not support vibration.
Tap each button to trigger the vibration pattern. On a real phone, you'll feel the vibration.
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.
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.
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)
}