@ethora/chat-component 26.2.8 → 26.2.10

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 CHANGED
@@ -108,6 +108,36 @@ export default function App() {
108
108
  }
109
109
  ```
110
110
 
111
+ `XmppProvider` also accepts a `pushNotifications` prop for headless push setup (works even if `Chat` is not rendered yet):
112
+
113
+ ```tsx
114
+ import { XmppProvider } from '@ethora/chat-component';
115
+
116
+ export default function App() {
117
+ return (
118
+ <XmppProvider
119
+ config={{ baseUrl: 'https://api.ethoradev.com/v1', initBeforeLoad: true }}
120
+ pushNotifications={{
121
+ enabled: true,
122
+ softAsk: false,
123
+ vapidPublicKey: 'PLACEHOLDER_VAPID_PUBLIC_KEY',
124
+ firebaseConfig: {
125
+ apiKey: 'PLACEHOLDER_API_KEY',
126
+ authDomain: 'PLACEHOLDER_AUTH_DOMAIN',
127
+ projectId: 'PLACEHOLDER_PROJECT_ID',
128
+ storageBucket: 'PLACEHOLDER_STORAGE_BUCKET',
129
+ messagingSenderId: 'PLACEHOLDER_MESSAGING_SENDER_ID',
130
+ appId: 'PLACEHOLDER_APP_ID',
131
+ },
132
+ }}
133
+ >
134
+ {/* Chat can be mounted later or omitted */}
135
+ <div>App shell</div>
136
+ </XmppProvider>
137
+ );
138
+ }
139
+ ```
140
+
111
141
  ### 3. Run
112
142
 
113
143
  ```bash
@@ -11,6 +11,7 @@ interface XmppContextType {
11
11
  interface XmppProviderProps {
12
12
  children: ReactNode;
13
13
  config?: IConfig;
14
+ pushNotifications?: IConfig['pushNotifications'];
14
15
  }
15
16
  export declare const XmppProvider: React.FC<XmppProviderProps>;
16
17
  export declare const useXmppClient: () => XmppContextType;
@@ -2,5 +2,6 @@ export declare const ethoraLogger: {
2
2
  log: (...args: unknown[]) => void;
3
3
  info: (...args: unknown[]) => void;
4
4
  debug: (...args: unknown[]) => void;
5
+ error: (...args: unknown[]) => void;
5
6
  always: (...args: unknown[]) => void;
6
7
  };
@@ -36,6 +36,21 @@ interface UsePushNotificationsOptions {
36
36
  * Default: false (immediate request after login).
37
37
  */
38
38
  softAsk?: boolean;
39
+ /**
40
+ * Optional push click handler. When provided, has priority over
41
+ * config.pushNotifications.onClick from Redux config.
42
+ */
43
+ onClick?: (params: {
44
+ roomJID?: string;
45
+ messageId?: string;
46
+ url?: string;
47
+ data?: Record<string, any>;
48
+ notification?: {
49
+ title?: string;
50
+ body?: string;
51
+ };
52
+ source?: 'service_worker' | 'foreground';
53
+ }) => void | Promise<void>;
39
54
  }
40
55
  interface UsePushNotificationsResult {
41
56
  /** Manually trigger the permission + subscription flow (for soft-ask UIs). */