1.0.3 • Published 5 years ago

react-native-offline-notifications v1.0.3

Weekly downloads
-
License
ISC
Repository
-
Last release
5 years ago

react-native-offline-notifications

Simple service for registering offline push notifications for specific date and time with simple title and message

Usage

Place service as component in your application, pass listener for taking notification events and register events via ref

Example

import React, { useRef, useCallback, useEffect } from "react";
import { View } from "react-native";
import PushService from "react-native-offline-notifications";

export default function Index() {
  const refPush = useRef();
  
  useEffect(() => {
    const ussubscribe = refPush.current.registerMessage({
      title: 'notification title',
      message: 'notification body',
      when: new Date(5, 5, 2020, 15, 30, 46),
    });
  }, []);
  
  const onMessage = useCallback((data) => {
    // will fire event with your given date/time with data you've passed
    console.log(data);
  }, []);
  
  return (
    <View>
      <PushService onMessage={onMessage} ref={refPush} />
      {/* Your code */}
    </View>
  );
}