Giter Site home page Giter Site logo

react-native-custom-timer-notification's Introduction

react-native-custom-timer-notification

Custom timer notification for React Native Android ๐Ÿ””
Now version 0.8 Supports full size custom notifications

Installation

npm install react-native-custom-timer-notification

AndroidManifest

      <receiver android:name="com.reactnativecustomtimernotification.NotificationEventReceiver" />
      <receiver android:name="com.reactnativecustomtimernotification.OnClickBroadcastReceiver" />
      <!--
      if foreground service used add this line
      -->
      <uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
      <service android:name="com.reactnativecustomtimernotification.ForegroundService"/>

Usage

Timer notification

Only Timer notifiction with default Title and body

import { TimerNotification } from "react-native-custom-timer-notification";
Property Description
payload sent data will be received when click or canceled
title Title of the notification
body Body of the notification
id unique number
date Time at which zero comes

Example

  TimerNotification({
      payload: JSON.stringify('notification.data'),
      title: 'My notification',
      body: 'Much longer text that cannot fit one line... ',
      id: 1,
      remove: false, // optional
      foreground: false,
      date: new Date(Date.now() + 20000),
      isCountDown: true, // false for positive timer 
      setCustomContentView:true // optional
    });
    

Full custom notification

Full custom notifiction with custom image, text and cronometer.

import { CustomNotification, TYPES, FB_TYPE } from "react-native-custom-timer-notification";
Property Description
eventData sent data will be received when click or canceled
title Title of the notification
body Body of the notification
id unique number
View View that needs to be added (Array)

View Properties

Property Description
name text that needs to be displayed
size Size of text
type Type of view (Text,Image, Cronometer)
bold Font (NORMAL,BOLD,ITALIC,BOLD_ITALIC)
uri Image in base64
PaddingLeft Left Padding
PaddingTop PaddingTop
PaddingRight PaddingRight
PaddingBottom PaddingBottom
color Text color
ZeroTime Time at which zero comes

Example

    CustomNotification(
      {
        eventData: JSON.stringify('notificationOpen?.data'),
        title: 'notificationOpen.data.title',
        body: ' notificationOpen.data.body',
        id: 1,

        View: [
          {
            name: 'Limited Sales',
            size: 20,
            type: TYPES.Text,
            bold: FB_TYPE.BOLD_ITALIC,
            PaddingLeft: 10,
            PaddingTop: 50,
            PaddingRight: 0,
            PaddingBottom: 0,
            setViewVisibility: false,
            color: '#ed1a45',
          },
          {
            uri: image,
            type: TYPES.Image,
            PaddingLeft: 0,
            PaddingTop: 0,
            PaddingRight: 0,
            PaddingBottom: 0,
          },
          {
            name: 'Buy now',
            size: 30,
            type: TYPES.Text,
            bold: FB_TYPE.BOLD_ITALIC,
            PaddingLeft: 10,
            PaddingTop: 100,
            PaddingRight: 0,
            PaddingBottom: 0,
            setViewVisibility: false,
            color: '#fbd335',
          },
          {
            type: TYPES.Cronometer,
            size: 30,
            ZeroTime: new Date(Date.now() + 20000),
            PaddingLeft: 800,
            color: '#0000FF',
            PaddingTop: 0,
            PaddingRight: 0,
            PaddingBottom: 0,
          },
        ],
      },
      (e: any) => {
        console.log(e);
      }
    );
    

Remove Notifications

import { RemoveTimer } from "react-native-custom-timer-notification";

RemoveTimer(1);

onclick and cancel listner

import { onEvent } from "react-native-custom-timer-notification";

onEvent(event=>{
console.log(event)
});

Contributing

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

License

MIT

react-native-custom-timer-notification's People

Contributors

timotismjntk avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.