npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

react-native-basic-alarm

v1.0.4

Published

Alarm clock functionality for react native ios and android using react-native-push-notification and react-native-async-storage/async-storage

Downloads

5

Readme

react-native-simple-alarm

Alarm clock functionality for react native ios and android built using react-native-push-notification and react-native-community/async-storage.

ReactNativeChatImageAudio

Installing (React Native >= 0.60.0)

npm install --save react-native-simple-alarm

or

yarn add react-native-simple-alarm

For iOS using cocoapods, run:

$ cd ios/ && pod install

Installing (React Native <= 0.59.x)

npm install --save react-native-simple-alarm

or

yarn add react-native-simple-alarm

Use react-native link to add the library to your project:

Please follow the installation for react-native-push-notification as well.

Example

$ cd example
$ yarn install

if ios:

$ cd ios/ && pod install
$ yarn ios

if android:

$ yarn android

You may come across these issues while running the example: https://github.com/oblador/react-native-vector-icons/issues/1074 https://github.com/oblador/react-native-vector-icons/issues/328

createAlarm

| Prop | Description | Default | | -------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------- | | date | Required: - Date for alarm to get triggered. ISO Format. example: 1996-10-15T00:05:32.000Z [string] | None | | active | Set to true when a push notification is scheduled. Setting to true schedules an alarm notification [boolean] | false | | message |Notification Message on Push Notification [string] | "Alarm" | | snooze | Sets snooze time for alert. In minutes [number] | 1 | | userInfo | Any data that is needed for the alarm. [Object] | {} |

Also includes the props from react-native-push-notification Local Notifications except for repeatType.

ID is created by the react-native-simple-alarm. ID is uuid for ios, and number for android. OID is a property created by react-native-simple-alarm that is used to cancel ios alarms/scheduled push notifications.

import { createAlarm } from 'react-native-simple-alarm';
import moment from 'moment'

createAlarm = async () => {
  try {
    await createAlarm({
        active: false,
        date: moment().format(),
        message: 'message',
        snooze: 1,
      });
  } catch (e) {}
}

getAlarms

Returns an array of all alarms.

import { getAlarms } from 'react-native-simple-alarm';

getAlarms = async () => {
  try {
    const alarms = await getAlarms();
  } catch (e) {}
}

getAlarmById

Returns alarm object given its id. If trying to get an id that does not exist, it will return null and throw an error.

import { getAlarmById } from 'react-native-simple-alarm';

getAlarms = async () => {
  let id = '07699912-87d9-11ea-bc55-0242ac130003';
  
  try {
    const alarm = await getAlarmById(id);
  } catch (e) {}
}

editAlarm

Given alarm object, edits the alarm. If alarm active prop is set to true, it will create a scheduled push notification for alarm based on the date. If alarm active prop is set to false, it will cancel scheduled push notifications for alarm. Returns edited alarm. If alarm id does not exist, it will return null and throw an error.

import { editAlarm } from 'react-native-simple-alarm';
import moment from 'moment';

editAlarm = async () => {
  let id = '07699912-87d9-11ea-bc55-0242ac130003';
  
  try {
    await editAlarm({
        id,
        date: moment().add(1, 'days')format();,
        snooze: 1,
        message: 'Message',
        active: true
      });
  } catch (e) {}
}

activateAlarmById

Given alarm id, sets alarm active prop to true, and creates scheduled push notification for alarm based on the date. Use this instead of editAlarm if you simply want to set the alarm active prop to true. If trying to get an id that does not exist, it will return null and throw an error.

import { activateAlarmById } from 'react-native-simple-alarm';

activateAlarm = async () => {
  let id = '07699912-87d9-11ea-bc55-0242ac130003';
  
  try {
    await activateAlarmById(id);
  } catch (e) {}
}

cancelAlarmById

Given alarm id, sets alarm active prop to false, and cancels scheduled push notification for alarm based on the date. Call this when you want to cancel the alarm, and keep the alarm as well. Sets active prop to false. If trying to get an id that does not exist, it will return null and throw an error.

import { cancelAlarmById } from 'react-native-simple-alarm';

cancelAlarmById = async () => {
  let id = '07699912-87d9-11ea-bc55-0242ac130003';
  
  try {
    await cancelAlarmById(id);
  } catch (e) {}
}

deleteAlarmById

Given alarm id, deletes alarm and cancels the scheduled push notification. Returns array of alarms after deletion. If trying to get an id that does not exist, it will return null and throw an error.

import { deleteAlarmById } from 'react-native-simple-alarm';
deleteAlarmById = async () => {
  let id = '07699912-87d9-11ea-bc55-0242ac130003';
  
  try {
    await deleteAlarmById(id);
  } catch (e) {}
}

deleteAllAlarms

Deletes all alarms and cancels all alarm scheduled push notifications. Returns array of alarms after deletion (which will be empty array).

import { deleteAllAlarms } from 'react-native-simple-alarm';
deleteAllAlarms = async () => {
  try {
    await deleteAllAlarms();
  } catch (e) {}
}