moment#DurationInputArg1 TypeScript Examples

The following examples show how to use moment#DurationInputArg1. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: PushService.ts    From hamagen-react-native with MIT License 6 votes vote down vote up
registerLocalNotification = async (title: string, message: string, sendInAmount: DurationInputArg1, sendInUnits: DurationInputArg2) => {
  try {
    await initPushNotifications();

    // Build a channel
    const channel = new firebase.notifications.Android.Channel('LocalPush', 'CHANNEL_NAME', firebase.notifications.Android.Importance.Max,)
      .setSound('default')
      .enableVibration(true)
      .setVibrationPattern([100, 100, 100, 100]);

    // Create the channel
    await firebase.notifications().android.createChannel(channel);

    const notification = new firebase.notifications.Notification()
      .setNotificationId('LocalPush')
      .setTitle(title)
      .setBody(message)
      .setSound('default');

    if (!IS_IOS) {
      notification
        .android.setChannelId('LocalPush')
        .android.setSmallIcon('notification_small')
        .android.setLargeIcon('notification_big')
        .android.setAutoCancel(true)
        .android.setVibrate([100, 100, 100, 100]);
    }

    const fireDate = moment().add(sendInAmount, sendInUnits).valueOf();
    await firebase.notifications().scheduleNotification(notification, { fireDate });
  } catch (error) {
    onError({ error });
  }
}
Example #2
Source File: moment_wrapper.ts    From grafana-chinese with Apache License 2.0 5 votes vote down vote up
toDuration = (input?: DurationInput, unit?: DurationUnit): DateTimeDuration => {
  return moment.duration(input as DurationInputArg1, unit) as DateTimeDuration;
}