Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const currUser = this.service.loggedInUserObj;
for (let i = 0; i < msgs.length; i += 1) {
const inM = msgs[i];
console.log('Ezhil chatservice message ', inM);
let msgText = inM.msg;
if (inM.t && inM.t === 'mgcall_init') {
msgText = 'Started a Call!';
if (!(inM.u._id === currUser._id) && (group.findMessageById(inM._id) === null)) {
if (group && group.type === 'direct') {
msgText = 'Started a Call!';
this.incomingVC(currUser, inM.ts, inM.rid, group);
} else {
const msgTs = moment(inM.ts);
const currentTsDiff = moment().diff(msgTs, 'minutes');
if (currentTsDiff < 1) {
PushNotification.localNotificationSchedule({
message: `Video Call started in ${group.name}`, // (required)
playSound: true,
soundName: 'vcring.mp3',
date: new Date(Date.now()), // in 60 secs
});
}
}
}
}
const m = this.yap2message(inM._id, inM.rid, msgText, inM.ts, inM.u._id, inM.u.username, inM.u.name);
m.original = inM;
if (inM.attachments && inM.attachments.length > 0) {
const atM = inM.attachments[0];
if (m.text === '') {
if (atM.description) {
m.text = atM.description;
incomingVC(groupID, rUID, rUName) {
console.log('Kumar push VCUTIL invc ', groupID, rUID, rUName);
this._gid = groupID;
this._remoteuid = rUID;
this._remoteName = rUName;
PushNotification.cancelAllLocalNotifications();
PushNotification.localNotificationSchedule({
message: `Video Calling ${this._remoteName}`, // (required)
playSound: false,
autoCancel: false,
vcData: {
groupID,
rUID,
},
date: new Date(Date.now()), // in 60 secs
// actions: '["Accept", "Reject"]',
});
// InCallManager.startRingtone('_BUNDLE_');
// InCallManager.turnScreenOn();
// if (!this._net) {
// this._net = new Network();
// }
const result = await context.fetchLoginMessages()
const date = new Date(Date.now() + 1000)
// for each key
for (const key in result) {
// skip loop if the property is from prototype
if (!result.hasOwnProperty(key)) continue
const obj = result[key]
if (obj.otpResetPending) {
if (Platform.OS === Constants.IOS) {
PushNotification.localNotificationSchedule({
title: s.strings.otp_notif_title,
message: sprintf(s.strings.otp_notif_body, key),
date
})
} else {
PushNotification.localNotificationSchedule({
message: s.strings.otp_notif_title,
subText: sprintf(s.strings.otp_notif_body, key),
date
})
}
}
}
} catch (error) {
console.error(error)
}
})
await AsyncStorage.setItem(Constants.LOCAL_STORAGE_BACKGROUND_PUSH_KEY, now.toString())
scheduleNotif() {
this.lastId++;
PushNotification.localNotificationSchedule({
date: new Date(Date.now() + (30 * 1000)), // in 30 secs
/* Android Only Properties */
id: ''+this.lastId, // (optional) Valid unique 32 bit integer specified as string. default: Autogenerated Unique ID
ticker: "My Notification Ticker", // (optional)
autoCancel: true, // (optional) default: true
largeIcon: "ic_launcher", // (optional) default: "ic_launcher"
smallIcon: "ic_notification", // (optional) default: "ic_notification" with fallback for "ic_launcher"
bigText: "My big text that will be shown when notification is expanded", // (optional) default: "message" prop
subText: "This is a subText", // (optional) default: none
color: "blue", // (optional) default: system default
vibrate: true, // (optional) default: true
vibration: 300, // vibration length in milliseconds, ignored if vibrate=false, default: 1000
tag: 'some_tag', // (optional) add tag to message
group: "group", // (optional) add group to message
ongoing: false, // (optional) set whether this is an "ongoing" notification
for (let i = 0; i < msgs.length; i += 1) {
const inM = msgs[i];
let msgText = inM.msg;
if (inM.t && inM.t === 'mgcall_init') {
msgText = 'Started a Call!';
if (!(inM.u._id === currUser._id) && (groupObj.findMessageById(inM._id) === null)) {
this.incomingVC(currUser, inM.ts, inM.rid, groupObj);
}
}
if (inM.actionLinks && inM.actionLinks[0].method_id === 'joinMGVCCall') {
msgText = 'Started a Video Call!';
if (!(inM.u._id === currUser._id) && (groupObj.findMessageById(inM._id) === null)) {
const msgTs = moment(inM.ts);
const currentTsDiff = moment().diff(msgTs, 'minutes');
if (currentTsDiff < 1) {
PushNotification.localNotificationSchedule({
message: `Video Call started in ${groupObj.name}`, // (required)
playSound: true,
soundName: 'vcring.mp3',
date: new Date(Date.now()), // in 60 secs
});
}
}
}
const m = this.yap2message(inM._id, inM.rid, msgText, inM.ts, inM.u._id, inM.u.username, inM.u.name);
m.original = inM;
if (inM.attachments && inM.attachments.length > 0) {
const atM = inM.attachments[0];
if (m.text === '') {
if (atM.description) {
m.text = atM.description;
} else {
function createAndroidNotification(bird, index, date, alarm) {
PushNotification.localNotificationSchedule({
largeIcon: bird.images.face,
smallIcon: 'ic_notification',
title: 'Dawn Chorus Alarm',
alarmUUID: alarm.uuid,
userInfo: { alarmUUID: alarm.uuid },
message: `A ${bird.name} ${tweetyStrings[index]}!`,
subText: 'Tap to hear chorus',
date: date.toDate(),
soundName: bird.sound.androidNotification,
vibrate: false,
actions: '["Snooze", "Stop"]',
});
return;
}
export const sendNotifications = (message) => {
PushNotification.localNotificationSchedule({
foreground: true,
message,
date: new Date(Date.now() + (2 * 1000)),
});
};
android: data => {
if (this.notifications.enabled) {
PushNotification.cancelAllLocalNotifications();
PushNotification.localNotificationSchedule({
date: new Date(data.isostart),
message: `🚀 ${data.name} will launch in just ${
this.notifications.delay
} minutes!`
});
}
}
});