// native-bridge.js — Detects if running inside Capacitor native app // and provides native API access (camera for barcode, push notifications, haptics) (function() { 'use strict'; window.NexusNative = { isNative: typeof Capacitor !== 'undefined', // Camera for barcode scanning async scanBarcode() { if (!this.isNative) return null; try { const { Camera } = await import('@capacitor/camera'); const photo = await Camera.getPhoto({ quality: 90, resultType: 'base64' }); // In production, send to a barcode decode service return photo; } catch(e) { return null; } }, // Push notification registration async registerPush() { if (!this.isNative) return null; try { const { PushNotifications } = await import('@capacitor/push-notifications'); const result = await PushNotifications.requestPermissions(); if (result.receive === 'granted') { await PushNotifications.register(); } PushNotifications.addListener('registration', token => { console.log('Push token:', token.value); // Send token to server for this employee }); PushNotifications.addListener('pushNotificationReceived', notification => { console.log('Push received:', notification); }); } catch(e) { console.log('Push not available:', e); } }, // Haptic feedback async vibrate() { if (!this.isNative) return; try { const { Haptics, ImpactStyle } = await import('@capacitor/haptics'); await Haptics.impact({ style: ImpactStyle.Light }); } catch(e) {} }, // Status bar (hide for fullscreen POS) async setupStatusBar() { if (!this.isNative) return; try { const { StatusBar, Style } = await import('@capacitor/status-bar'); await StatusBar.setStyle({ style: Style.Dark }); await StatusBar.setBackgroundColor({ color: '#0d0d0d' }); } catch(e) {} } }; // Auto-init if native if (window.NexusNative.isNative) { window.NexusNative.setupStatusBar(); window.NexusNative.registerPush(); } })();