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

expo-alarm-module

v1.1.16

Published

Provides an alarm module for expo bare workflow (tested with version 0.64 to 0.72 of RN). Currently, only works for android.

Downloads

55

Readme

expo-alarm-module

Alarm library to use with expo bare workflow. Tested in versions 0.64 to 0.72 of RN.

Installation

NPM

npm install expo-alarm-module

Yarn

yarn add expo-alarm-module

NOTE: For Android, you will still have to manually update the AndroidManifest.xml (as below) in order to use Scheduled Notifications.

Android manual Installation

In your android/app/src/main/AndroidManifest.xml

    .....
    <uses-permission android:name="android.permission.SCHEDULE_EXACT_ALARM" />
    <uses-permission android:name="android.permission.VIBRATE" />
    <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
    <uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
    <uses-permission android:name="android.permission.WAKE_LOCK" />
    <uses-permission
        android:name="android.permission.FOREGROUND_SERVICE_MEDIA_PLAYBACK"
        android:minSdkVersion="34" 
    />
    <uses-permission android:name="android.permission.POST_NOTIFICATIONS" />

    <application ....>
        <receiver
            android:name="com.expoalarmmodule.receivers.AlarmReceiver"
            android:enabled="true"
            android:exported="true"
            />
        <receiver
            android:name="com.expoalarmmodule.receivers.BootReceiver"
            android:exported="true"
        >
            <intent-filter>
                <action android:name="android.intent.action.BOOT_COMPLETED" />
            </intent-filter>
        </receiver>
        
        <service 
            android:name="com.expoalarmmodule.AlarmService" 
            android:foregroundServiceType="mediaPlayback"
        />
     .....

IOS manual Installation

In your info.plist, you need to add background mode for sound and remote notifications capabilities. You also need to obtain permissions for notifications beforehand (the library asks permission when setting the notification for the first time, but if you get permission before it is better).

Expo Installation

Since this library has a config plugin for expo, you only need to install it with expo install expo-alarm-module for it to work and add the config plugin to the plugins array of your app.json or app.config.js:

{
  "expo": {
    "plugins": ["expo-alarm-module"]
  }
}

Next, rebuild your app as described in the "Adding custom native code" guide.

Usage

For a more detailed example of usage, clone this repository and run the example application, installing the dependencies of this native module using "yarn" in the root folder and running "yarn example android" or "yarn example ios" according to your OS. Don't forget to run "pod install" in the example/ios folder for configuring the ios files.

// App.js
import React, { useEffect } from 'react';
import { View, Text, Button } from 'react-native';

import AlarmModule, { removeAlarm, scheduleAlarm, stopAlarm } from "expo-alarm-module";

const App = () => {
    const alarmIn60 = () => {
        var newDate = new Date();
        newDate.setSeconds(newDate.getSeconds() + 60);

        scheduleAlarm(
        {
            uid: "alarm1",
            day: newDate,
            title: "Title of alarm",
            description: "Alarm Description",        
            snoozeInterval: 5,
            repeating: true,
            active: true
        } as any
        );

    };

    /* Create a new alarm 60 seconds after the current date.*/
    const onStopAlarmButton = () => {
        // Stops any alarm that is playing
        stopAlarm();
        
        // Removes the alarm. Also stops any alarm that is playing, so the above function stopAlarm is redundant.
        removeAlarm("alarm1");

    };

    return (
        <View style={{ flex: 1, justifyContent: 'center', alignItems: 'center' }}>
            <Text>React Native Alarm Test</Text>
            <Button title="Alarm in 60 seconds" onPress={alarmIn60} />
            <Button title="Stop Alarm" onPress={onStopAlarmButton} />
        </View>
    );
};

export default App;

Contributing

See the contributing guide to learn how to contribute to the repository and the development workflow.

License

MIT


Made with create-react-native-library

Build


To build, it is necessary to run .\gradlew clean & .\gradlew build in the android folder. Afterwards, run "npx bob build" in the root directory. After that, just publish the app with npm publish.