How to implement Schedule local notifications of React native push notification in react native - react-native

I am using react-native-push-notifications npm library to implement notifications feature in my app. However, I want to schedule the notifications before 5 miniutes at specific time and I am using PushNotification.localNotificationSchedule so how to implement this pls help , thanks in Advance!

This code is scheduling a notification for 5 minutes before 4:00 PM, 21st January 2023.
import PushNotification from 'react-native-push-notifications'
const time = new Date(2023, 1, 21, 16, 0, 0)
const fiveMinutesBefore = new Date(time.getTime() - 5 * 60 * 1000)
PushNotification.localNotificationSchedule({
message: "Notification message",
date: fiveMinutesBefore,
repeatType: 'minute',
repeatTime: 5,
number: 1,
});

Related

rightnow-crm and unavailable hours

we have recently implemented rightnow proactive chat on our website, we have the chat widget set up by our central IT department to work off hours of availability for chat. I've got the widget working to an OK standard using this example
http://cxdeveloper.com/article/proactive-chat-intercepting-chat-events
However, coming from Zendesk I was hoping to replicate the 'out of hours' or 'offline' modes of the Zendesk widget where it changes its behaviour when chat is offline.
After looking around I notice the widget can take a value for 'label_unavailable_hours:' however I cannot work out if this is available to the both the ConditionalChatLink and ProactiveChat modules. Does anyone have any experience with creating such functionality? I've also had a look at trying to pull data using chatAvailability but I am not doing that right either.
If anyone has an insight on how to get some kind of out of hours smarts working or if I am wasting my time try Id love to hear. My code is as below
$(document).ready(function() {
RightNow.Client.Controller.addComponent({
instance_id: "spac_0",
avatar_image: "",
label_question: "A team member is available to help, would you like to start a chat?",
label_avatar_image: "",
label_dialog_header: "",
logo_image: "",
seconds: 2,
enable_polling: "yes",
div_id: "proactiveChatDiv",
module: "ProactiveChat",
//module: "ConditionalChatLink",
min_agents_avail: 0, //remove this when live (when set to 0, no agents have to be free)
min_sessions_avail: 1,
label_unavailable_busy_template: "'All team members are busy. please email is us' + <a href='urlForEmail'>' + 'this place' + '</a>'", //out of hours
label_unavailable_hours: "'Outside of hours' + <a href='urlForEmail'>' + 'this place' + '</a>'",
type: 2
},
"https://ourWidgetCode"
);
//Widget loaded callback - this doesn't seem to work correctly hence the code below
RightNow.Client.Event.evt_widgetLoaded.subscribe(function(event_name, data) {
if (data[0].id == "spac_0") {
//Initialization
console.log('widget loaded');
}
/* this wont work
spac_0.prototype.chatAvailability = spac_0.chatAvailability;
spac_0.chatAvailability = function()
{
console.log(spac_0.chatAvailability);
{}
};*/
//Reset prototype
spac_0.prototype = {};
//Handle Chat Offered
spac_0.prototype.chatOffered = spac_0.chatOffered;
spac_0.chatOffered = function() {
console.log("Chat Offered Handled");
spac_0.prototype.chatOffered.call(this);
//animate the widget to popup from bottom
setTimeout(function() {
$('div.yui-panel-container').addClass('animate');
}, 2000)
//delete the annoying session cookie that only allows the chat to appear once per session by default
RightNow.Client.Util.setCookie("noChat", '', -10, '/', '', '');
};
//if the 'Do not ask again' is selected
spac_0.prototype.chatRefused = spac_0.chatRefused;
spac_0.chatRefused = function () {
console.log("Do not ask again Selected");
spac_0.prototype.chatRefused.call(this);
//Reset the Cookie to be valid only for the session
RightNow.Client.Util.setCookie("noChat",'RNTLIVE',0,'/',true,'');
};
});
});

expo notification how set start time

The challenge is: how can I set up the start date for notification in the new expo API. In the old API (which is depricated today) it was feasible but I can't see the solution in the new doc
For example: set up a notification on every 2nd day start from a user given date (e.g. 12th of Jan).
I went through on these types
export type SchedulableNotificationTriggerInput =
| DateTriggerInput
| TimeIntervalTriggerInput
| DailyTriggerInput
| WeeklyTriggerInput
| CalendarTriggerInput;
but no success so far.
As far as I can tell you should be able to set the start date this way:
const dateString = "21/01/2021"; // Jan 21
const trigger = new Date(dateString);
trigger.setMinutes(0);
trigger.setSeconds(0);
Notifications.scheduleNotificationAsync({
content: {
title: 'Happy new hour!',
},
trigger,
});
You should play around with trigger.setMinutes and trigger.setSeconds to set a specific hour on your specific day.

Google calendar API free slots

i am really new to the coding and would like to ask for some advice regarding calendar API.
I managed to created a list of the events and and show a busy time in the calendar, but i cant figure out how to show output of the free slots between the events.
# Call the Calendar API
now = datetime.datetime.utcnow().isoformat() + 'Z' # 'Z' indicates UTC time
print('Getting the upcoming 10 events')
events_result = service.events().list(calendarId='<email>', timeMin=now,
maxResults=10, singleEvents=True,
orderBy='startTime').execute()
events = events_result.get('items', [])
if not events:
print('No upcoming events found.')
for event in events:
start = event['start'].get('dateTime', event['start'].get('date'))
#print(start, event['summary'])"""
cst = timezone('UTC')
the_datetime_start = cst.localize(datetime.datetime(2020, 6, 10, 0))
print(the_datetime_start)
the_datetime_end = cst.localize(datetime.datetime(2020, 6, 10, 16))
print(the_datetime_end)
body = {
"timeMin": the_datetime_start.isoformat(),
"timeMax": the_datetime_end.isoformat(),
"timeZone": 'UK',
"items": [{"id": '<email>'}]
}
eventsResult = service.freebusy().query(body=body).execute()
print(eventsResult)
Hard to give you a code answer with your information, but if you want to show your free slots, you just have to:
Get all the tasks you have on your planning
Order it
Compare the first end date/hour task with the second start date/hour task
The différence between is your free slot, so you have your free slot
Do it again for the second task and the third task, and repeat for the other task

Exchange Api send incorrect invitation in Israel timezone

I faced to following problem with sending invitation in .net using exchange API
Send invitation in Israel timezone with start time =09/09/2013 4.30 Israel.
But it is displayed in outlook 09/09/2013 6.30 Israel.
It works properly for other time zones for example for EST.
Does anybody has any idea how to fix this?
Sample:
service.AutodiscoverUrl(loginForm.tbEmailAddress.Text, f);
TimeZoneInfo timeZoneInfo = TimeZoneInfo.FindSystemTimeZoneById("Israel Standard Time");
Appointment appointment = new Appointment(service);
appointment.Subject = "subj";
appointment.Body = new MessageBody(BodyType.Text, "body");
appointment.StartTimeZone = timeZoneInfo;
appointment.Start = GetDateTime(new DateTime(2013, 09, 09, 04, 0, 0));
appointment.EndTimeZone = timeZoneInfo;
appointment.End = GetDateTime(new DateTime(2013, 09, 09, 04, 30, 0));
appointment.IsAllDayEvent = false;
appointment.Importance = Importance.Normal;
appointment.RequiredAttendees.Add("Lena", "email...");
appointment.Save(SendInvitationsMode.SendOnlyToAll);
...
private static DateTime GetDateTime(DateTime dateTime)
{
return new DateTime(dateTime.Year, dateTime.Month, dateTime.Day, dateTime.Hour, dateTime.Minute,
dateTime.Second, dateTime.Millisecond, DateTimeKind.Unspecified
);
}
I use Microsoft.Exchange.WebServices.dll 15.0.516.14
it's actually a known issue with Exchange EWS itself. Developer can only trust the date time returned without the timezone information, and the correct timezone for that time should be UTC always.

Strophe.attach not working - I am using openfire locally

I am trying to implment the XMPP Client. I am using BOSH Connection manager and can run the Strophe.connect but not Strophe.Attach. I have tried incrementing the RID, but no effect.. Any help please ? There is no error here, but the Strophe.Status.CONNECTED is never reached via the attach method and so I cannot send IQ or Presence.
Here is my code
try
{
var cookieJid = $.cookie("jid");
var cookieSid = $.cookie("sid");
var cookieRid = $.cookie("rid");
var connt = new Strophe.Connection("http://localhost:7070/http-bind/");
connt.attach(cookieJid, cookieSid, cookieRid + 1, function(status)
{
if (status === Strophe.Status.CONNECTED)
{
alert ("hola connected");
$("#userName").append("hola connected : " + connt.jid );
var iq = $iq({type: 'get'}).c('query', {xmlns: 'jabber:iq:roster'});
connt.sendIQ(iq, handleRoster);
connt.send($pres());
}
});
}
catch (e)
{
$("#userName").append("Pinky error is " + e);
}
Edit
Thanks Eric and Charlie.
So I took the latest Strophe.js and now Attached status does work.
But the connection disconnects instantaneously. I am not even able to fetch the Roster.
We can possibly do every thing with Connection.attach() as we would with connection.connect(), right?
Any thoughts?
Change the line:
if (status === Strophe.Status.CONNECTED)
...to...
if (status === Strophe.Status.CONNECTED || status === Strophe.Status.ATTACHED)
Are you using the latest Strophe library? In the version I'm using, I see that the status can be these values:
Status: {
ERROR: 0,
CONNECTING: 1,
CONNFAIL: 2,
AUTHENTICATING: 3,
AUTHFAIL: 4,
CONNECTED: 5,
DISCONNECTED: 6,
DISCONNECTING: 7,
ATTACHED: 8
}
Make sure you convert your cookieRid to a Number by using new Number(cookieRid). Otherwise, when you do +1 on it, you will get "####1".
You can test this out for yourself in Javascript:
var s = "123";
alert(s+1); // "1231" and not "124"
Also, as Eric answered, there is a status ATTACHED so you need to handle that event.