Error autostart


#1

i want after restart phone show notification after 3 minute.
my code:
ionViewDidLoad() {
this.Time = 60*3;
this.shownotification();
this.autostart.enable();
console.log(‘ionViewDidLoad LocalPage’);
}

shownotification() {
let timewait = this.Time* 1000;
let notifi = {
id: this.i++,
title: “Time !!!”,
text: “Yoyoyo PicPic”,
at: new Date(new Date().getTime() + timewait),
icon: ‘file://img/clock1.png’
};
LocalNotifications.schedule(notifi);
console.log(notifi);
BackgroundMode.enable();
}

But i restart phone not show notification. where am i wrong ? . I see http://ionicframework.com/docs/native/autostart/. Thanks


#2

Does the app restart after you restart the phone?


#3

No i think it will auto start app for me


#4

This answer makes no sense, I don’t understand it


#5

sorry, app not restart after restart phone


#6

Then it is quite normal that you don’t get a notification if the autostart doesn’t work.


#7

i set this.autostart.enable(); for app. i think if enable for it then after restart phone it auto start. I wrong ?


#8

That is what it says in the documentation.

But if it isn’t working, your problem is not that “notification doesn’t show” but “autostart doesn’t work”.

  1. What is your ionic info output?
  2. What does ionic cordova plugin list return?
  3. What does your constructor look like in that file?
  4. Did you https://ionicframework.com/docs/native/#Add_Plugins_to_Your_App_Module

#9

Sorry i’m late reply.

  1. output show notification
  2. I set plugin autostart, local notifications and background module.
  3. in constructor i set
    this.Time = 60*3;
    this.shownotification();
    this.autostart.enable();
    and i remove ionViewDidLoad().
  4. yes i add module in app.module