Im using the local notifications plug-in https://github.com/katzer/cordova-plugin-local-notifications, and i'm trying to schedule multiple notifications but I only get the first one.
It has something to do with the id, but I don't know if it suppose to be a object or a value I've been tracing this everywhere and are really grateful for all help!
var now = new Date().getTime(),
_60_seconds_from_now = new Date(now + 30*1000);
_120_seconds_from_now = new Date(_60_seconds_from_now.getTime() + 60*1000),
window.plugin.notification.local.add({
id: 28,
title: 'Reminder',
message: 'Dont forget to buy some ds.',
repeat: 'minutely',
date: _60_seconds_from_now
});
window.plugin.notification.local.add({
id: 27,
title: 'Reminder',
message: 'Dont forget to buy some dsfsdafsdafsdaf.',
repeat: 'minutely',
date: _120_seconds_from_now
});
I think by making repeat minutely first one is overlapping the second one... make sense ??
Related
I want to give local notification at 7:00 am every day using cordova local notification plugin but in the documentation it is not specified how to set time for a repeating notification
$cordovaLocalNotification.schedule({
id: 3,
title: 'Warning',
text: 'Dont fall asleep',
every: 'minute'
}).then(function (result) {
console.log('Notification 3 triggered');
});
If you are using cordova-plugin-local-notifications, I think It should be:
var date = new Date()
date.setDate(date.getDate()+1);
date.setHours(7);
date.setMinutes(0);
date.setSeconds(0);
$cordovaLocalNotification.schedule({
id: 3,
title: 'Warning',
text: 'Dont fall asleep',
at: date,
every: 'day'
}).then(function (result) {
console.log('Notification 3 triggered');
});
This should schedule a notification the next day at 7, that will be repeated every day, but I couldn't try it, I'm sorry.
The property for setting the time is firstAt. You can find out the documentation about the plugin here.
I have this in my console chrome:
[{"id":40,"endDate":"2017-04-22","dataA":"2017-04-19","nrC":2,"type":"CO","dataD":"2017-04-19","startDate":"2017-04-20"},{"id":40,"endDate":"2017-04-26","dataA":"2017-04-26","nrC":4,"tyoe":"CP","dataD":"2017-04-23","startDate":"2017-04-25"},
This json string is comming from the servlet that calls DAO class to take the information from db.
So, this string is (dynamically) passed into a jsp page from request session...and i put it into var DAYS = '${jsonArrayString}'; then console.log(DAYS); then it prints that json string above.
So...it can print more data then two.
It has to be put into a javascript variable loke this:
var DAYS = '${jsonArrayString}'; //That's what's on my console..and it comes from session into this jsp page
I think it has to be iterated through a foreach and print it in that format.
var USER_DAYS = [
{
id: value from jsonArrayString,
date: value from jsonArrayString,
title: value from jsonArrayString,
start: new Date(value from jsonArrayString),
end: new Date(value from jsonArrayString),
allDay: true,
className: 'done'
},
];
I tried to put the values manually and it works...like this:
var USER_DAYS = [
{
id: 1,
date: '2017-04-05',
title: 'CO',
start: new Date(2017, 3, 5),
end: new Date(2017, 3, 7),
allDay: true,
className: 'done'
},
I don't know hot to put the values from that json string(
Which can be anythong ... more than 2 records)...that why I need to iterate through that json string.
I want the values to be put only in that format, in that variable (var USER_DAYS)
I tried somthing like this, but it does't work:
<c:forEach items="${jsonArrayString}" var="jsonArrayString">
{
id: '${jsonArrayString.nrC}' ,
date: '${jsonArrayString.dataD}' ,
title: '${jsonArrayString.type}' ,
startDate: '${jsonArrayString.startDate}',
endDate: '${jsonArrayString.endDate}',
allDay: true,
className: 'done'
},
</c:forEach>
];
or like this:
var USER_DAYS = [
{
id: DAYS.nrC,
date: DAYS.dataD,
title: DAYS.type,
start: new Date(DAYS.startDate),
end: new Date(DAYS.endDate),
allDay: true,
className: 'done'
},
];
How to do this?
try parse to json string into json objects.
Example
var USER_DAYS = JSON.parse('${jsonArrayString}')
JavaScript code runs only on the client side, while JSP on the server. You cannot iterate over the JavaScript variable while the page is rendered at the server.
If you want to serve a page that already contains the data, you should pass the data to the JSP page as a model attribute. To do this, take a look at this post.
If you want to populate the page with data after it has been loaded to the browser, you have to use a JavaScript library, such as jQuery. In this case, you have to send a request to the server to get the data in JSON format, and then you can manipulate them on the client side.
I am trying to use tcomb and failing at the moment because I cannot wrap my head around how to define an instance function.
Say I have a type:
t.struct({
year: t.Integer,
monthIndex: t.Integer,
dayIndex: t.maybe(t.Integer),
indexInMonth: t.maybe(t.Integer),
title: t.Str,
subtitle: t.maybe(t.Str),
description: t.maybe(t.Str),
iconIdentifier: t.maybe(t.Str),
})
so far so good.
The problem
Now let's say I want to add a month instance method that can read this and get the right month name:
month() {
return MonthsInYear[this.monthIndex]
},
If I try adding that to the interior of the above, it just doesn't see it.
const b1 = CalEvent({
year: 2015,
monthIndex:2,
title: 'abc',
description: 'abc'
})
console.log(b1.month)
The same happens if I try to do mixin or really anything other than defining the function every single time.
I originally had the of syntax in there as with the function compare below...
t.struct({
year: t.Integer,
monthIndex: t.Integer,
compare: t.func([CalEvent], CalEventComparisonResult).of(
(toCompare) => CalEvent(compare(this,toCompare))
),
dayIndex: t.maybe(t.Integer),
indexInMonth: t.maybe(t.Integer),
title: t.Str,
subtitle: t.maybe(t.Str),
description: t.maybe(t.Str),
iconIdentifier: t.maybe(t.Str),
})
Still no dice.
I am beginning to think that what I want to do cannot be done within tcomb. And if that is the case I will be shocked that such a basic capability is not included...
From the README
const Person = t.struct({
name: t.String, // required string
surname: t.maybe(t.String), // optional string
age: Integer, // required integer
tags: t.list(t.String) // a list of strings
}, 'Person');
// methods are defined as usual
Person.prototype.getFullName = function () {
return `${this.name} ${this.surname}`;
};
I want to send to user my receipt with dummy data.
I use this library which simplifies message sending to Facebook.
The structure of my payload is this:
var payload = {
template_type: 'receipt',
recipient_name: '#' + user.name + ' ' + user.surname,
order_number: (new Date).getTime(),
currency: 'USD',
payment_method: 'Наличными',
order_url: 'http://www.example.com',
timestamp: (new Date).getTime() + '',
elements: [
{
title: title,
subtitle: subtitle,
quantity: 1,
price: 20,
currency: 'USD',
image_url: image_url
}
],
address: {
street_1:"Nurly tau",
street_2:"",
city:"Almaty",
postal_code:"050000",
state:"KZ",
country:"KZ"
},
summary: {
subtotal: 20,
shipping_cost: 0,
total_tax: 0,
total_cost: 20
},
adjustments: []
};
I have just filled receipt fields with simple fake data. Also, Facebook tracks the uniqueness of order_numbers of all sent recepts.
When I try to send this receipt I receive an error message:
{ message: '(#1200) Temporary send message failure. Please try again later',
type: 'OAuthException',
code: 1200,
fbtrace_id: 'BHmHRCEQUC4' }
What does this error mean? Facebook's error messages are so enigmatic?
I just had the same problem and after some fiddling I figured it out! The problem is that when you construct the timestamp using (new Date).getTime() it returns the amount of miliseconds since epoch. However, Facebook requires it to be in seconds.
I had the same problem, after a lot of tries, I figured out that the problem is with the timestamp parameter passed with the JSON payload.
I have no clue about what it could be, but it worked for me removing that. (Maybe, the timestamp should be for a moment before the API call, I don't know).
I am trying to push some things onto a Mongoose model. The model looks like this.
var ScheduleSchema = new mongoose.Schema({
hours: Number,
items: [{number: Number, minutes: Number, details: {description: String}, type: String}],
userId: Number
});
//later
ScheduleSchema.methods.createNew = function(hours, tasks, breathers) {
var schedule = makeSchedule(hours, tasks, breathers);
console.log(schedule);
this.items = schedule;
console.log(this.items);
}
I think that is enough code for my issue, but I can give more code if needed. Essentially, I've got a method for creating a schedule and then I want to assign the schedule to the object's 'items' property. I must admit I am still learning about mongoose so it is likely a problem there.
Anyway, I know my makeSchedule function is working, because I see this as the output from the first console message.
[{ number: 1,
minutes: 30,
details: {description: 'Task A'},
type: 'task'},
{ number: 2,
minutes: 45,
details: {description: 'Task B'},
type: 'task'},
etc...
]
However, when the console output from my second log statement, this.items, prints, I don't see the same structure. Instead, I see
["[object Object]", "[object Object]", "[object Object]", etc...]
Why am I not able to just assign the schedule variable to this.items? I believe I was even able to do it before, but I made some changes to my schedule code and now I cannot.
That would lead me to believe that the error is in my schedule code, but as you can see, it is creating the list of items just fine, based on the console output. Can anyone see a really obvious, potentially mongoose related mistake that I may have missed as a rookie?
My guess is that you recently added the type field to the embedded objects in items which is making Mongoose now think that items contains an array of strings instead of an array of objects like you have.
To fix it, use an object to define the type for type in your schema like so:
var ScheduleSchema = new mongoose.Schema({
hours: Number,
items: [{
number: Number,
minutes: Number,
details: {description: String},
type: {type: String}
}],
userId: Number
});