这是离子/电容器/角项目插件的示例代码:
import { ForegroundService } from '@awesome-cordova-plugins/foreground-service/ngx';
constructor(public foregroundService: ForegroundService) { }
...
startService() {
// Notification importance is optional, the default is 1 - Low (no sound or vibration)
this.foregroundService.start ('GPS Running', 'Background Service', 'drawable/fsicon');
}
stopService() {
// Disable the foreground service
this.foregroundService.stop();
}我不熟悉棱角,也没有普通的JavaScript (不是打字稿)的例子。在普通的JavaScript中,这些代码看起来如何?
发布于 2022-09-11 17:33:12
我不是一个离子专家,但在阅读了医生们之后,我打赌它应该像这样使用:
// import without `ngx`
import { ForegroundService } from '@awesome-cordova-plugins/foreground-service';
// create the object from class
const foregroundService = new ForegroundService();
// start the service
foregroundService.start('GPS Running', 'Background Service', 'drawable/fsicon');
// stop the service
foregroundService.stop()了解有关在React中使用离子本机组件的更多信息部分特别有用
https://stackoverflow.com/questions/73681242
复制相似问题