Plugin EcosystemSystem & OS
Push Notifications
Register for and handle incoming push notifications.
The Push plugin integrates with APNs and FCM to deliver push notifications reliably to your application.
Installation
npm install @easycord/pushAPI Reference
register()
Registers the device with the push notification service to receive a unique token.
import { Push } from '@easycord/push';
import { useEffect } from 'react';
export function PushNotificationHandler() {
useEffect(() => {
async function setupPush() {
try {
const token = await Push.register();
console.log('Device push token:', token);
// Send this token to your backend server
} catch (e) {
console.error('Failed to register for push notifications', e);
}
}
setupPush();
const listener = Push.addListener('pushReceived', (notification) => {
console.log('Received notification:', notification.title);
});
return () => listener.remove();
}, []);
return null;
}