-
Notifications
You must be signed in to change notification settings - Fork 60
/
Copy pathquerier.js
22 lines (20 loc) · 1.16 KB
/
querier.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
var AV = require('leancloud-storage');
var { Query } = AV;
AV.init({
appId: "p02Iwq6diOAtL0s7NNsYx8Uf-MdYXbMMI",
appKey: "Qrqz9Td7Iz39xHAi1PIzXqmo",
});
var pushNotifications = new AV.Query('notifications');
pushNotifications.descending('createdAt');
pushNotifications.limit(3);
pushNotifications.find().then(function (notifications) {
notifications.forEach(function (notification) {
if (notification.get('targetVersion') == null || notification.get("targetVersion") == "" || notification.get("targetVersion") == require("./package.json").version.toString()) {
var content = store.get("i18n") == 'zh' ? notification.get('notificationContentChinese') : notification.get('notificationContentEnglish');
var title = store.get("i18n") == 'zh' ? notification.get('notificationTitleChinese') : notification.get('notificationTitleEnglish');
var link = store.get("i18n") == 'zh' ? notification.get('notificationLinkChinese') : notification.get('notificationLinkEnglish');
var id = notification.get('objectId');
ipc.send("push-notification", { content: content, title: title, link: link, id: id })
}
})
})