离子反应本地通知与电容器不工作

Pra*_*dam 5 ionic-framework capacitor ionic-react ionic5

我正在尝试使用电容器来实现本地通知。

首先我使用以下命令安装插件,

npm install @ionic-native/local-notifications
npm install cordova-plugin-local-notification
Run Code Online (Sandbox Code Playgroud)

然后在我的 .js 文件中,我添加了以下代码

import { Plugins } from '@capacitor/core';
Run Code Online (Sandbox Code Playgroud)

scheduleNotification = () => {
 Plugins.LocalNotifications.schedule({
    notifications: [
      {
        title: "Title",
        body: "Body",
        id: 1,
        schedule: { at: new Date(Date.now() + 1000 * 5) },
        sound: null,
        attachments: null,
        actionTypeId: "",
        extra: null
      }
    ]
  });
console.log('scheduled notifications');
Run Code Online (Sandbox Code Playgroud)

}

我尝试了所有方法,但在运行 iOS 12 的 iPhone 6s 上看不到任何本地通知。当我检查 Xcode 日志时,我可以看到 id 为 1 的计划通知。

cordova-plugin-badge (0.8.8)
cordova-plugin-device (2.0.3)
cordova-plugin-local-notification (0.9.0-beta.2)
Run Code Online (Sandbox Code Playgroud)

小智 -1

对于ios,我认为,尚不支持。

对于 android,请尝试请求权限。