How to use the react-native-background-timer.start function in react-native-background-timer

To help you get started, we’ve selected a few react-native-background-timer examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github textileio / photos / App / Services / PhotosTask.js View on Github external
export default async function photosTask (dispatch, failedImages) {
  // console.log('FAILED IMAGES:', failedImages)
  console.log('running photos task')
  BackgroundTimer.start() // This requests some background time from the OS

  // Start IPFS
  const path = RNFS.DocumentDirectoryPath
  await IPFS.createNodeWithDataDir(path)
  await IPFS.startNode()

  // Get a list of the jobs already in the queue
  // const existingJobs = await queue.getJobs(true)

  // Query for any new photos, add jobs to queue
  const photos = await queryPhotos()
  // PushNotificationIOS.presentLocalNotification({
  //   alertBody: 'fetch of ' + photos.length + ' photos',
  //   userInfo: {}
  // })
  for (const photo of photos) {
github AOSSIE-Org / CarbonFootprint-Mobile / app / actions / ActivityDetectionAction.js View on Github external
function startTimer(dispatch, getState) {
    if (Platform.OS === 'android') {
        this.intervalId = BackgroundTimer.setInterval(() => {
            dispatch(setDuration(getState().activity.duration + 1));
        }, 1000);
    } else {
        // Not tested for iOS
        BackgroundTimer.start();
        setInterval(() => {
            dispatch(setDuration(getState().activity.duration + 1));
        }, 1000);
    }
}
github textileio / react-native-sdk / src / Textile / index.ts View on Github external
private backgroundTaskRace = async () => {
    // This race cancels whichever effect looses the race, so a foreground event will cancel stopping the node
    //
    // Using the race effect, if we get a foreground event while we're waiting
    // to stop the node, cancel the stop and let it keep running
    await BackgroundTimer.start()
    try {
      const ms = 20000
      let cancelled = false

      const foregroundEvent = DeviceEventEmitter.addListener(TextileEvents.privateEvents.appNextState, (payload) => {
        if (payload.nextState === 'active' && !cancelled) {
          TextileEvents.stopNodeAfterDelayCancelled()
          cancelled = true
        }
      })

      while (!cancelled) {
          TextileEvents.stopNodeAfterDelayStarting()
          await API.cafes.checkMessages() // do a quick check for new messages
          await delay(ms / 2)
          if (cancelled) { // cancelled by event, so abort sequence
github textileio / photos / App / SDK / index.ts View on Github external
private backgroundTaskRace = async () => {
    // This race cancels whichever effect looses the race, so a foreground event will cancel stopping the node
    //
    // Using the race effect, if we get a foreground event while we're waiting
    // to stop the node, cancel the stop and let it keep running
    await BackgroundTimer.start()
    const ms = 20000
    let cancelled = false

    const foregroundEvent = DeviceEventEmitter.addListener('@textile/appNextState', (payload) => {
      if (payload.nextState === 'active' && !cancelled) {
        TextileEvents.stopNodeAfterDelayCancelled()
        cancelled = true
      }
    })

    cancelSequence:
    while (!cancelled) {
        TextileEvents.stopNodeAfterDelayStarting()
        await this.api.checkCafeMessages() // do a quick check for new messages
        await delay(ms / 2)
        if (cancelled) { // cancelled by event, so abort sequence
github rizvanrzayev / react-native-verto / src / verto / Call.js View on Github external
/**
 * react-native-verto
 * Author: Rizvan Rzayev
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
 * And see https://github.com/rizvanrzayev/react-native-verto for the full license details.
 */
import VertoRTC from '../webrtc/VertoRTC';
import {printError, printWarning} from '../common/utils';
import {generateGUID, ENUM} from './utils';
import {Clipboard} from 'react-native';
import BackgroundTimer from 'react-native-background-timer';

BackgroundTimer.start();

export default class Call {
  constructor(direction, verto, params, mediaHandlers = {}) {
    this.direction = direction;
    this.verto = verto;
    this.params = {
      callID: generateGUID(),
      useVideo: verto.options.useVideo,
      useStereo: verto.options.useStereo,
      screenShare: false,
      useCamera: false,
      useMic: verto.options.deviceParams.useMic,
      useSpeak: verto.options.deviceParams.useSpeak,
      remoteVideo: verto.options.remoteVideo,
      remoteAudioId: verto.options.remoteAudioId,
      localVideo: verto.options.localVideo,
github react-native-webrtc / react-native-callkeep / example / App.js View on Github external
import React, { useState, useEffect } from 'react';
import { Platform, StyleSheet, Text, View, TouchableOpacity, ScrollView } from 'react-native';
import uuid from 'uuid';
import RNCallKeep from 'react-native-callkeep';
import BackgroundTimer from 'react-native-background-timer';
import DeviceInfo from 'react-native-device-info';

BackgroundTimer.start();

const hitSlop = { top: 10, left: 10, right: 10, bottom: 10};
const styles = StyleSheet.create({
  container: {
    flex: 1,
    marginTop: 20,
    backgroundColor: '#fff',
    alignItems: 'center',
    justifyContent: 'center',
  },
  button: {
    marginTop: 20,
    marginBottom: 20,
  },
  callButtons: {
    flexDirection: 'row',
github rizvanrzayev / react-native-verto / src / webrtc / FSRTCPeerConnection.js View on Github external
/**
 * react-native-verto
 * Author: Rizvan Rzayev
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
 * And see https://github.com/rizvanrzayev/react-native-verto for the full license details.
 */

import {RTCPeerConnection, RTCSessionDescription} from 'react-native-webrtc';
import BackgroundTimer from 'react-native-background-timer';

BackgroundTimer.start();

export default class FSRTCPeerConnection {
  constructor(options) {
    this.options = options;
    const {
      constraints,
      iceServers,
      onICEComplete,
      type,
      onICESDP,
      onICE,
      onRemoteStream,
      attachStream,
      onPeerStreamingError,
      onOfferSDP,
      onAnswerSDP,
github thousight / react-native-draggable-switch / src / utils.ts View on Github external
export const startSessionTimer = (cb: any, interval: number) => {
  const duration = interval || backgroundDuration
  if (!cb) {
    backgroundTimerEndTime = getCurrentTimeStamp() + duration
    currentCallback = defaultCallback
  } else {
    currentCallback = cb
  }

  if (!currentCallback) {
    return
  }

  stopSessionTimer()
  BackgroundTimer.start()
  timeout = BackgroundTimer.setInterval(currentCallback, duration)
}