Schedule New Local Notification Every Hour
We are trying to develop an ionic app which will show local notification according at a scheduled interval according to users preference. The local notification should have a new content every time. This content will be saved locally. We need the app to work completely offline. These notifications should also work when the app is closed.
If someone can guide us onto how this can be done, it will be great.
cordova ionic-framework ionic3 hybrid-mobile-app localnotification
add a comment |
We are trying to develop an ionic app which will show local notification according at a scheduled interval according to users preference. The local notification should have a new content every time. This content will be saved locally. We need the app to work completely offline. These notifications should also work when the app is closed.
If someone can guide us onto how this can be done, it will be great.
cordova ionic-framework ionic3 hybrid-mobile-app localnotification
add a comment |
We are trying to develop an ionic app which will show local notification according at a scheduled interval according to users preference. The local notification should have a new content every time. This content will be saved locally. We need the app to work completely offline. These notifications should also work when the app is closed.
If someone can guide us onto how this can be done, it will be great.
cordova ionic-framework ionic3 hybrid-mobile-app localnotification
We are trying to develop an ionic app which will show local notification according at a scheduled interval according to users preference. The local notification should have a new content every time. This content will be saved locally. We need the app to work completely offline. These notifications should also work when the app is closed.
If someone can guide us onto how this can be done, it will be great.
cordova ionic-framework ionic3 hybrid-mobile-app localnotification
cordova ionic-framework ionic3 hybrid-mobile-app localnotification
asked Nov 13 '18 at 17:49
Onkar SinghOnkar Singh
212
212
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
You can make use of the Local Notification Plugin available from Ionic native, install it by running:
$ ionic cordova plugin add cordova-plugin-local-notification
$ npm install --save @ionic-native/local-notifications
Once installed, you can use it in whichever component you want with the following code:
import { LocalNotifications } from '@ionic-native/local-notifications';
constructor(private localNotifications: LocalNotifications) { }
// Schedule delayed notification
this.localNotifications.schedule({
text: localStorage.getItem('localNotificationData'),
trigger: {at: new Date(new Date().getTime() + 3600)},
led: 'FF0000',
sound: 'file://sound.mp3'
});
The Local notification will fire when the time in the date-time object you enter in the trigger field elapses. It will display whatever text you enter in the text field. In the above example, I set the text field value to whatever is returned from local storage. You can substitute that part with a hardcoded string or wherever you are saving your data. You will have to schedule a notification like this for each notification you want the user to receive. Once local notifications are set, they can run when the app is closed, no extra code needed.
Hope this helps!
As the title suggests we want to schedule a notification every hour or any similar interval. With you suggested solution we will have to loop over all the notification in our local storage and schedule each one separately. But if the user changes the preference then we will have to cancel all these notification and schedule each notification again. This does not seem like a good solution.
– Onkar Singh
Nov 14 '18 at 15:04
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53286838%2fschedule-new-local-notification-every-hour%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
You can make use of the Local Notification Plugin available from Ionic native, install it by running:
$ ionic cordova plugin add cordova-plugin-local-notification
$ npm install --save @ionic-native/local-notifications
Once installed, you can use it in whichever component you want with the following code:
import { LocalNotifications } from '@ionic-native/local-notifications';
constructor(private localNotifications: LocalNotifications) { }
// Schedule delayed notification
this.localNotifications.schedule({
text: localStorage.getItem('localNotificationData'),
trigger: {at: new Date(new Date().getTime() + 3600)},
led: 'FF0000',
sound: 'file://sound.mp3'
});
The Local notification will fire when the time in the date-time object you enter in the trigger field elapses. It will display whatever text you enter in the text field. In the above example, I set the text field value to whatever is returned from local storage. You can substitute that part with a hardcoded string or wherever you are saving your data. You will have to schedule a notification like this for each notification you want the user to receive. Once local notifications are set, they can run when the app is closed, no extra code needed.
Hope this helps!
As the title suggests we want to schedule a notification every hour or any similar interval. With you suggested solution we will have to loop over all the notification in our local storage and schedule each one separately. But if the user changes the preference then we will have to cancel all these notification and schedule each notification again. This does not seem like a good solution.
– Onkar Singh
Nov 14 '18 at 15:04
add a comment |
You can make use of the Local Notification Plugin available from Ionic native, install it by running:
$ ionic cordova plugin add cordova-plugin-local-notification
$ npm install --save @ionic-native/local-notifications
Once installed, you can use it in whichever component you want with the following code:
import { LocalNotifications } from '@ionic-native/local-notifications';
constructor(private localNotifications: LocalNotifications) { }
// Schedule delayed notification
this.localNotifications.schedule({
text: localStorage.getItem('localNotificationData'),
trigger: {at: new Date(new Date().getTime() + 3600)},
led: 'FF0000',
sound: 'file://sound.mp3'
});
The Local notification will fire when the time in the date-time object you enter in the trigger field elapses. It will display whatever text you enter in the text field. In the above example, I set the text field value to whatever is returned from local storage. You can substitute that part with a hardcoded string or wherever you are saving your data. You will have to schedule a notification like this for each notification you want the user to receive. Once local notifications are set, they can run when the app is closed, no extra code needed.
Hope this helps!
As the title suggests we want to schedule a notification every hour or any similar interval. With you suggested solution we will have to loop over all the notification in our local storage and schedule each one separately. But if the user changes the preference then we will have to cancel all these notification and schedule each notification again. This does not seem like a good solution.
– Onkar Singh
Nov 14 '18 at 15:04
add a comment |
You can make use of the Local Notification Plugin available from Ionic native, install it by running:
$ ionic cordova plugin add cordova-plugin-local-notification
$ npm install --save @ionic-native/local-notifications
Once installed, you can use it in whichever component you want with the following code:
import { LocalNotifications } from '@ionic-native/local-notifications';
constructor(private localNotifications: LocalNotifications) { }
// Schedule delayed notification
this.localNotifications.schedule({
text: localStorage.getItem('localNotificationData'),
trigger: {at: new Date(new Date().getTime() + 3600)},
led: 'FF0000',
sound: 'file://sound.mp3'
});
The Local notification will fire when the time in the date-time object you enter in the trigger field elapses. It will display whatever text you enter in the text field. In the above example, I set the text field value to whatever is returned from local storage. You can substitute that part with a hardcoded string or wherever you are saving your data. You will have to schedule a notification like this for each notification you want the user to receive. Once local notifications are set, they can run when the app is closed, no extra code needed.
Hope this helps!
You can make use of the Local Notification Plugin available from Ionic native, install it by running:
$ ionic cordova plugin add cordova-plugin-local-notification
$ npm install --save @ionic-native/local-notifications
Once installed, you can use it in whichever component you want with the following code:
import { LocalNotifications } from '@ionic-native/local-notifications';
constructor(private localNotifications: LocalNotifications) { }
// Schedule delayed notification
this.localNotifications.schedule({
text: localStorage.getItem('localNotificationData'),
trigger: {at: new Date(new Date().getTime() + 3600)},
led: 'FF0000',
sound: 'file://sound.mp3'
});
The Local notification will fire when the time in the date-time object you enter in the trigger field elapses. It will display whatever text you enter in the text field. In the above example, I set the text field value to whatever is returned from local storage. You can substitute that part with a hardcoded string or wherever you are saving your data. You will have to schedule a notification like this for each notification you want the user to receive. Once local notifications are set, they can run when the app is closed, no extra code needed.
Hope this helps!
answered Nov 13 '18 at 18:01
Charis The ProgrammerCharis The Programmer
314212
314212
As the title suggests we want to schedule a notification every hour or any similar interval. With you suggested solution we will have to loop over all the notification in our local storage and schedule each one separately. But if the user changes the preference then we will have to cancel all these notification and schedule each notification again. This does not seem like a good solution.
– Onkar Singh
Nov 14 '18 at 15:04
add a comment |
As the title suggests we want to schedule a notification every hour or any similar interval. With you suggested solution we will have to loop over all the notification in our local storage and schedule each one separately. But if the user changes the preference then we will have to cancel all these notification and schedule each notification again. This does not seem like a good solution.
– Onkar Singh
Nov 14 '18 at 15:04
As the title suggests we want to schedule a notification every hour or any similar interval. With you suggested solution we will have to loop over all the notification in our local storage and schedule each one separately. But if the user changes the preference then we will have to cancel all these notification and schedule each notification again. This does not seem like a good solution.
– Onkar Singh
Nov 14 '18 at 15:04
As the title suggests we want to schedule a notification every hour or any similar interval. With you suggested solution we will have to loop over all the notification in our local storage and schedule each one separately. But if the user changes the preference then we will have to cancel all these notification and schedule each notification again. This does not seem like a good solution.
– Onkar Singh
Nov 14 '18 at 15:04
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53286838%2fschedule-new-local-notification-every-hour%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown