Native shell bridge

Maintainer reference. The hosted portal at https://portal.gfelektro.com runs inside Electron (desktop), iOS (ios/PortalEU), or Android (mobile/portal_android). Each shell exposes a small JavaScript API for OS notifications and FCM device tokens.

window.portalNativeAPI (iOS / Android)

Member Type Description
platform 'ios' | 'android' Shell identifier
isNativeShell true Detection flag for the web app
notifications.requestPermission() Promise Ask the user for notification permission
notifications.checkPermission() Promise Current permission state
notifications.show(title, options?) void OS notification; options may include body, tag, id, data
push.getNativeToken() Promise<string | null> FCM registration token for Firestore, or null

Injection order

  1. Native prelude defines portalNativeAPI (Swift: PortalNativeBridge.swift, Android prelude in portal_webview_screen.dart).
  2. portal-native-bridge.js patches window.Notification and ServiceWorkerRegistration.prototype.showNotification.
  3. Clicks are delivered via portal-notification-clicked CustomEvent on window.

window.electronNotificationAPI (desktop)

Electron uses preload.js and electron-notification-clicked. Do not remove it.

Digital-Platform (web app repo)

Implement in the separate Digital-Platform repository: openExternalUrl.ts, pushSubscriptionService.ts, browserNotifications.ts, notificationCapability.ts. Server: functions/src/webPushNotify.ts multicasts to all tokens in fcmTokens.

Security

Never commit GoogleService-Info.plist, google-services.json, .p8, or .p12 files. Users install the macOS app from the DMG only — see macOS install guide.