I have tried local notification. the way you are trying is applicable to ionic 2 version. Your ionic framework version is - 3.0.1. For this ionic 3 version use following link. https://ionicframework.com/docs/native/local-notifications/'
I have successfully implemented this.
What you need to do is
1.create provider for local notification. Write scheduling method in this provider (given in link I shared)
2. call the scheduling method in provider from your home.ts file.
I have just implemented this plugin into one of my projects and I had a little trouble. One thing to watch out for is that IOS now only display local notifications when the app is in the background mode/not focused (link).
I also used Eddy Verbruggen repo as I believed this has the IOS 10 fixes. Although both Eddy Verbruggen and Katzer do have an IOS 10 branches on there repos. Could be that you code is all good in the hood, just local notification are not working in the way in witch toy attend them to do.
But I’m still having some issue with local notification. The following code works when testing with iOS simulator but not in my iPhone7+.
What I want to do is when an app’s running in the background, i want to send a notification to a user after a few seconds…
// The pause event emits when the native platform puts the application into the background, typically when the user switches to a different application.
this.platform.pause.subscribe(() => {
console.log(‘pause before’);
this.localNotifications.cancelAll().then(() => {
let notification = {
id: 999,
title: ‘Hey!’,
text: ‘You put me into background :(’,
at: new Date(new Date().getTime() + (10 * 1000)),
every: ‘0’
};
this.localNotifications.schedule(notification);
Running it within iOS simulator, I see logs (pause before, localNotifications schedule --> success) from console and received notification after 10 seconds when app goes into background. But running with real iOS device, I only see the log for “pause before” when i put the app into background. The rest of code is not executed until resume…
Please edit your post and use the </> button above the post input field to format your code or error message or wrap it in ``` (“code fences”) manually. This will make sure your text is readable and if it recognizes the programming language it also automatically adds code syntax highlighting. Thanks.
Notfication works and I see the logs in the safari console -
[Log] pause (console-via-logger.js, line 173)
[Log] localNotifications schedule --> success (console-via-logger.js, line 173)
Running it with real device (iPhone7+);
Notification works after app’s running in forground (resume) again. I only see the following in the safari console when I put the app into background mode.
[Log] pause (console-via-logger.js, line 173)
schedule call back block is called after app’s resumed.