feat: 添加原生通知桥接功能及相关配置

This commit is contained in:
2025-11-27 13:50:21 +08:00
parent 074a7f1ff0
commit 7cba2965a9
15 changed files with 401 additions and 2 deletions

View File

@@ -0,0 +1,32 @@
import { Capacitor, registerPlugin } from '@capacitor/core'
// Web 端的兜底实现:保证浏览器环境下不会报错
const webFallback = {
async hasPermission() {
return { granted: true }
},
async requestPermission() {
return { granted: true }
},
async getPendingNotifications() {
return { notifications: [] }
},
async acknowledgeNotification() {
return { acknowledged: true }
},
async clearNotifications() {
return { cleared: true }
},
}
const NotificationBridge = registerPlugin('NotificationBridge', {
web: () => webFallback,
})
export const isNativeNotificationBridgeAvailable = () =>
typeof Capacitor.isNativePlatform === 'function'
? Capacitor.isNativePlatform()
: Capacitor.getPlatform() !== 'web'
export default NotificationBridge