@dnotifier-realtime/dnotifier 1.0.0 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +50 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -20,4 +20,53 @@
|
|
|
20
20
|
## 📦 Installation
|
|
21
21
|
|
|
22
22
|
```bash
|
|
23
|
-
npm
|
|
23
|
+
npm i @dnotifier-realtime/dnotifier
|
|
24
|
+
|
|
25
|
+
import { DNotifier } from "@dnotifier-realtime/dnotifier";
|
|
26
|
+
|
|
27
|
+
const notifier = new DNotifier({
|
|
28
|
+
appId: "YOUR-APP-ID",
|
|
29
|
+
secret: "YOUR-APP-SECRET",
|
|
30
|
+
transport: "ws", // or "http"
|
|
31
|
+
userId: "YOUR-UNIQUE-USERID",
|
|
32
|
+
onConnected: () => {
|
|
33
|
+
console.log("✅ Connected successfully.");
|
|
34
|
+
},
|
|
35
|
+
onMessage: (data) => {
|
|
36
|
+
console.log("📩 Incoming message:");
|
|
37
|
+
console.log("Metadata:", data.metadata);
|
|
38
|
+
console.log("Message:", data.payload.toJSON());
|
|
39
|
+
console.log("Message:", data.payload.toString());
|
|
40
|
+
console.log("Message:", data.payload.raw());
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
await notifier.connect();
|
|
45
|
+
|
|
46
|
+
// Send single message
|
|
47
|
+
notifier.send({
|
|
48
|
+
senderId: "YOUR-UNIQUE-USERID",
|
|
49
|
+
receiverId: "RECEIVER-UNIQUE-USERID",
|
|
50
|
+
code: 200,
|
|
51
|
+
data: {
|
|
52
|
+
text: "Hello from DNotifier SDK 🚀"
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
// Broadcast message
|
|
57
|
+
notifier.send({
|
|
58
|
+
senderId: "YOUR-UNIQUE-USERID",
|
|
59
|
+
receiverIds: ["user_2", "user_3"],
|
|
60
|
+
code: 200,
|
|
61
|
+
data: "Broadcast test message"
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
// Send Binary Data (files, images , media)
|
|
65
|
+
const buffer = Buffer.from("Hello Binary");
|
|
66
|
+
|
|
67
|
+
notifier.sendBinary({
|
|
68
|
+
senderId: "YOUR-UNIQUE-USERID",
|
|
69
|
+
receiverIds: ["user_1"],
|
|
70
|
+
buffer
|
|
71
|
+
});
|
|
72
|
+
|