<commit_before>import { 
  Platform,
  Vibration,
  AppState,
} from 'react-native';

import _ from 'lodash';
import Parse from 'parse/react-native';
import Store from '../data/Store';
import realm from '../data/Realm';
import pubsub from 'pubsub-js';

import Color from '../styles/Color';
import {ToastAddresses, ToastMessage} from '../models/ToastMessage';
import { loadForms } from './Forms';

import PushNotification from 'react-native-push-notification';


// Finds and returns a list of pending Notifications from Realm
export function loadNotifications() {
  return realm.objects('Notification')
    .filtered(`completed == false`)
    .sorted('datetime', true)
}

// Creates a new notification for an active Time Trigger
export function addTimeTriggerNotification( surveyId, formId, title, description, time ) {
  try {
    realm.write(() => {
      realm.create('Notification', {
        surveyId: surveyId,
        formId: formId,
        title: title,
        description: description,
        datetime: time,
      }, true)
    })
  } catch(e) {
    console.error(e)
  }
}

/**
 * Shows a toast at the bottom of the screen.
 * @param  {string} title    Title text to be displayed on the toast
 * @param  {string} message  Description text to be displayed on the toast
 * @param  {string} icon     FA icon to be shown on the toast
 * @param  {number} duration Time to keep the toast up
 * @param  {function} action Callback function to be executed when tapping the toast
 */
export function showToast(title, message, icon, duration, action) {
  const toastMessage = ToastMessage.createFromObject({
    title: title,
    message: message,
    icon: icon,
    iconColor: Color.faded,
    duration: duration,
    action: action,
  });
  pubsub.publish(ToastAddresses.SHOW, toastMessage);
}



export function notifyOnBackground(message, vibrate) {
  if (AppState.currentState != 'active') {
    if (Store.userSettings.notifyOnGeofence) {
      PushNotification.localNotification({
        message: message,
      });
    }
    
    if (vibrate && Store.userSettings.vibrateOnGeofence) {
      Vibration.vibrate([0, 500, 200, 500]);
    }
  }
}
<commit_msg>Removes vibration patterns from iOS version.<commit_after>import { 
  Platform,
  Vibration,
  AppState,
} from 'react-native';

import _ from 'lodash';
import Parse from 'parse/react-native';
import Store from '../data/Store';
import realm from '../data/Realm';
import pubsub from 'pubsub-js';

import Color from '../styles/Color';
import {ToastAddresses, ToastMessage} from '../models/ToastMessage';
import { loadForms } from './Forms';

import PushNotification from 'react-native-push-notification';


// Finds and returns a list of pending Notifications from Realm
export function loadNotifications() {
  return realm.objects('Notification')
    .filtered(`completed == false`)
    .sorted('datetime', true)
}

// Creates a new notification for an active Time Trigger
export function addTimeTriggerNotification( surveyId, formId, title, description, time ) {
  try {
    realm.write(() => {
      realm.create('Notification', {
        surveyId: surveyId,
        formId: formId,
        title: title,
        description: description,
        datetime: time,
      }, true)
    })
  } catch(e) {
    console.error(e)
  }
}

/**
 * Shows a toast at the bottom of the screen.
 * @param  {string} title    Title text to be displayed on the toast
 * @param  {string} message  Description text to be displayed on the toast
 * @param  {string} icon     FA icon to be shown on the toast
 * @param  {number} duration Time to keep the toast up
 * @param  {function} action Callback function to be executed when tapping the toast
 */
export function showToast(title, message, icon, duration, action) {
  const toastMessage = ToastMessage.createFromObject({
    title: title,
    message: message,
    icon: icon,
    iconColor: Color.faded,
    duration: duration,
    action: action,
  });
  pubsub.publish(ToastAddresses.SHOW, toastMessage);
}


/**
 * Sends a local notification to the user. Triggers only when the phone is in a background state.
 * @param  {string} message Message to appear in the local push notificaiton.
 * @param  {bool}   vibrate If set to true, the notification will also vibrate the user's device.
 */
export function notifyOnBackground(message, vibrate) {
  if (AppState.currentState != 'active') {
    if (Store.userSettings.notifyOnGeofence) {
      PushNotification.localNotification({
        message: message,
      });
    }
    
    if (vibrate && Store.userSettings.vibrateOnGeofence) {
      if (Platform.OS === 'android') {
        Vibration.vibrate([0, 500, 200, 500]);
      } else {
        Vibration.vibrate();
      }
    }
  }
}

{'fraction_non_alphanumeric': 0.11134586942742447, 'fraction_numerical': 0.0042256496936403974, 'mean_word_length': 3.3351648351648353, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3064630', 'n_tokens_mistral': 1398, 'n_tokens_neox': 1362, 'n_words': 453}