我在2天前发布此问题,但我没有收到任何答复。 我希望每天上午10:00收到本地通知。 我的代码是: 并且有时我收到通知,然后通过交换通知托盘无法删除。
请检查我的代码,并尽快给我答复
import { Component } from '@angular/core';
import { Platform, NavController, ToastController, AlertController } from 'ionic-angular';
import { StatusBar } from '@ionic-native/status-bar';
import { SplashScreen } from '@ionic-native/splash-screen';
import { HomePage } from '../pages/home/home';
import { MainpagePage } from "../pages/mainpage/mainpage";
import { LoginPage } from "../pages/login/login";
import { SplashPage } from "../pages/splash/splash";
import { Observable } from 'rxjs/Rx';
import { Geolocation } from '@ionic-native/geolocation';
import { SQLite, SQLiteObject } from '@ionic-native/sqlite';
import { DbHandlerProvider } from '../providers/db-handler/db-handler';
import { LocationTracker } from '../providers/location-tracker/location-tracker';
import { BackgroundMode } from '@ionic-native/background-mode';
import { HttpService } from '../pages/services/httpService';
import { LocalNotifications } from '@ionic-native/local-notifications';
import moment from 'moment';
import { Diagnostic } from '@ionic-native/diagnostic';
declare let cordova: any;
import { LocationAccuracy } from '@ionic-native/location-accuracy';
import { Subscription } from 'rxjs';
@Component({
templateUrl: 'app.html'
})
export class MyApp {
rootPage:any;
db: SQLiteObject;
time: any;
arrTime: any = [];
arrNotification: any = [];
onResumeSubscription: Subscription;
constructor(public platform: Platform, statusBar: StatusBar, splashScreen: SplashScreen,private geolocation: Geolocation,
private sqlite: SQLite, private dbHandlerProvider: DbHandlerProvider,
public locationTracker: LocationTracker,private backgroundMode: BackgroundMode,
public httpService: HttpService, public toastCtrl: ToastController,private localNotifications: LocalNotifications,
private diagnostic: Diagnostic, private alertCtrl: AlertController, private locationAccuracy: LocationAccuracy) {
this.dbHandlerProvider.createDatabase();
this.backgroundMode.enable();
if(localStorage.getItem('UserId') == null){
this.rootPage = LoginPage;
} else {
this.rootPage = MainpagePage;
}
platform.ready().then(() => {
setTimeout(()=>{
this.pushNotification();
},1000);
statusBar.styleDefault();
});
}
pushNotification() {
var pushTime = moment().add(0, 'days').hours(10).minutes(0).seconds(0);
let data = {
text: 'Aaron Harper Notification ',
every: 'day',
firstAt: pushTime.toDate()
}
cordova.plugins.notification.local.schedule(data);
}
}
提前谢谢你...