All Projects → liplylie → react-native-simple-alarm

liplylie / react-native-simple-alarm

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

Programming Languages

javascript
184084 projects - #8 most used programming language
typescript
32286 projects
java
68154 projects - #9 most used programming language
objective c
16641 projects - #2 most used programming language
ruby
36898 projects - #4 most used programming language
Starlark
911 projects

Projects that are alternatives of or similar to react-native-simple-alarm

apiservices
.NET API services - Managed Push Notifications, Email Engine (Templates, loading, & sending), & Localization Abstractions
Stars: ✭ 25 (-43.18%)
Mutual labels:  push-notifications
spontit-api-python-wrapper
Send functional, flexible push notifications to iOS, Android, and desktop devices (without your own app or website).
Stars: ✭ 35 (-20.45%)
Mutual labels:  push-notifications
ejabberd mod apns
An ejabberd module to send PUSH messages to iOS devices through APNS
Stars: ✭ 31 (-29.55%)
Mutual labels:  push-notifications
MMM-AlarmClock
Alarm Clock Module for MagicMirror²
Stars: ✭ 46 (+4.55%)
Mutual labels:  alarm-clock
hms-react-native-plugin
This repo contains all of React-Native HMS plugins.
Stars: ✭ 167 (+279.55%)
Mutual labels:  push-notifications
xinge
腾讯信鸽push Golang lib
Stars: ✭ 25 (-43.18%)
Mutual labels:  push-notifications
apns2
Node client for connecting to Apple's Push Notification Service using the new HTTP/2 protocol with JSON web tokens
Stars: ✭ 66 (+50%)
Mutual labels:  push-notifications
Android-Firebase-Notification-With-PHP-Backend
This is a practice repository of Android Firebase Push Notification with PHP Backend. I wrote a blog post about this topic on my Bengali blog site.
Stars: ✭ 51 (+15.91%)
Mutual labels:  push-notifications
abp-push
Push Notification System for ASP.NET Boilerplate
Stars: ✭ 16 (-63.64%)
Mutual labels:  push-notifications
push-notifications-php
Pusher Beams PHP Server SDK
Stars: ✭ 31 (-29.55%)
Mutual labels:  push-notifications
aioapns
An efficient APNs Client Library for Python/asyncio
Stars: ✭ 60 (+36.36%)
Mutual labels:  push-notifications
perfecty-push-wp
WordPress plugin for self-hosted Web Push Notifications ⚡️
Stars: ✭ 32 (-27.27%)
Mutual labels:  push-notifications
ionic-push-php
ionic-push-php is a library that allows you to consume the Ionic Cloud API for sending push notifications (normal and scheduled), get a paginated list of sending push notifications, get information of registered devices, remove registered devices by token, ...
Stars: ✭ 20 (-54.55%)
Mutual labels:  push-notifications
SEPA
Get notifications about changes in your SPARQL endpoint.
Stars: ✭ 21 (-52.27%)
Mutual labels:  push-notifications
azure-notificationhubs-java-backend
Azure Notification Hubs SDK for Java
Stars: ✭ 31 (-29.55%)
Mutual labels:  push-notifications
SwiftSimctl
Swift client-server tool to call xcrun simctl from your simulator. Automate push notification testing!
Stars: ✭ 50 (+13.64%)
Mutual labels:  push-notifications
alarm-clock-v3
Alarm clock (v3)
Stars: ✭ 17 (-61.36%)
Mutual labels:  alarm-clock
apprise-api
A lightweight REST framework that wraps the Apprise Notification Library
Stars: ✭ 147 (+234.09%)
Mutual labels:  push-notifications
node-apn-http2
Communicate with Apple Push Notification Service via native Node.js v8.8.1+ HTTP2 module (node-apn drop-in)
Stars: ✭ 25 (-43.18%)
Mutual labels:  push-notifications
mod push appserver
Simple and extendable appserver for XMPP pushes (aka. XEP-0357)
Stars: ✭ 24 (-45.45%)
Mutual labels:  push-notifications

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)

Under the hood this library is using react-native-push-notification, @react-native-community/async-storage, and @react-native-community/push-notification-ios. These libraries will need to be installed as well.

npm install --save react-native-simple-alarm @react-native-community/async-storage @react-native-community/push-notification-ios react-native-push-notification

or

yarn add react-native-simple-alarm @react-native-community/async-storage @react-native-community/push-notification-ios react-native-push-notification

For iOS using cocoapods, run:

$ cd ios/ && pod install

Installing (React Native <= 0.59.x)

npm install --save react-native-simple-alarm @react-native-community/async-storage @react-native-community/push-notification-ios react-native-push-notification

or

yarn add react-native-simple-alarm @react-native-community/async-storage @react-native-community/push-notification-ios react-native-push-notification

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: new Date().toISOString();,
        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) {}
}

Note to self:

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].