<template>
  <div>
    
      123333
  </div>
</template>

<script setup>
import { onMounted } from "vue"
import { LocalNotifications } from '@capacitor/local-notifications';



// 请求通知权限
const   requestPermissions = async   () => {
  // 获取权限
  const result = await LocalNotifications.requestPermissions();
  console.log('Permission result:', result);
  // alert(JSON.stringify(result))
}


const scheduleNotification = async   () => {
 
  await requestPermissions()

  await LocalNotifications.schedule({
    notifications: [
      {
        title: "更新通知。",
        body: "最新版本：1.0.0 「重大升级」",
        id: 1, // 唯一ID
        sound: "default", // iOS必须设置声音:cite[5]
        schedule: { at: new Date(Date.now() + 5000) } // 5秒后触发
      }
    ]
  });
}

onMounted(()=>{
  scheduleNotification()
})
</script>

<style lang="less" scoped>

</style>