1.0.7 • Published 4 months ago

notification-to-route v1.0.7

Weekly downloads
-
License
-
Repository
-
Last release
4 months ago

firstly publish project on firebase and and build using expo

notification-to-route

it is a react-native package to notification to route to screen

Installation

Use the package manager npm to install notification-to-route.

npm install notification-to-route

Dependencies

npm install -g expo-cli
expo install expo-notifications expo-device expo-constants expo-router

Usage

import React, { useEffect, useState } from "react";
import { View, Text, Button } from "react-native";
import { usePushNotification, sendPushNotification } from "./usePushNotification";

const NotificationExample = () => {
const { expoPushToken, notification } = usePushNotification();
const [message, setMessage] = useState("");

useEffect(() => {
if (notification) {
setMessage(`Received notification: ${notification.request.content.body}`);
}
}, [notification]);

const handleSendNotification = async () => {
if (expoPushToken) {
await sendPushNotification(expoPushToken, "your_screen_name");
} else {
alert("Push token is not available!");
}
};

return (
<View style={{ flex: 1, justifyContent: "center", alignItems: "center" }}>
<Text>Your Push Token: {expoPushToken || "Loading..."}</Text>
<Text>{message}</Text>
<Button title="Send Notification" onPress={handleSendNotification} />
</View>
);
};
export default NotificationExample

Usage

directly use Push notifications tool