PubNub
APIManaged realtime pub/sub with presence, history, chat SDKs and mobile push
- Erişim
- Publish and subscribe keys
Hakkında
Managed realtime network: apps publish and subscribe to channels through SDKs or a REST API, with presence, message history, user and channel metadata, access tokens and Functions. Chat SDKs and APNs and FCM push build on it. Billing is by monthly active users; the free plan covers 200.
Neler yapabilirsin
- Stream live updates, game state or device events to apps over channels
- Add chat with threads, reactions, typing indicators and read receipts
- Forward channel messages to phones as APNs and FCM push notifications
Başlarken
- Sign up in the Admin Portal and copy the publish and subscribe keys
- Install an SDK, for example npm install pubnub
- Subscribe to a channel, then publish messages to it
Örnek kod
// npm install pubnub
const PubNub = require('pubnub');
const pubnub = new PubNub({
publishKey: 'YOUR_PUBLISH_KEY',
subscribeKey: 'YOUR_SUBSCRIBE_KEY',
userId: 'quickstart-user',
});
const channel = pubnub.channel('quickstart-channel');
const subscription = channel.subscription();
subscription.onMessage = (event) => {
console.log('Message received:', event.message.text);
};
// Publish only once the subscription is connected
pubnub.addListener({
status: (event) => {
if (event.category === 'PNConnectedCategory') {
pubnub
.publish({ channel: 'quickstart-channel', message: { text: 'Hello, PubNub!' } })
.catch((error) => console.error('Publish failed:', error));
}
},
});
subscription.subscribe();Ayrıntılar
- Barındırma
- Hazır hizmet (bulut)
- Kullanılabildiği yerler
- Tüm dünya
- Resmi SDK'lar
- JavaScript/TypeScript, Python, Java, Kotlin, Swift, C#, Go, PHP, Ruby, Rust, Dart
- MCP sunucusu
- Uzak sunucu
- Entegrasyonlar
- Unity, Unreal