@solveo-ai/react-native 0.1.0 → 0.1.2
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 +116 -0
- package/dist/index.d.mts +199 -0
- package/dist/index.d.ts +199 -0
- package/dist/index.js +840 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +822 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +19 -10
- package/src/SolveoProvider.tsx +1 -1
- package/src/hooks/useChat.ts +10 -7
- package/src/hooks/usePushNotifications.ts +29 -12
package/README.md
CHANGED
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
React Native SDK for the Solveo AI platform. Build AI-powered chat experiences in your mobile apps.
|
|
4
4
|
|
|
5
|
+
**Supports both React Native CLI and Expo projects.**
|
|
6
|
+
|
|
5
7
|
## Installation
|
|
6
8
|
|
|
7
9
|
```bash
|
|
@@ -10,6 +12,57 @@ npm install @solveo-ai/react-native @solveo-ai/sdk-core
|
|
|
10
12
|
yarn add @solveo-ai/react-native @solveo-ai/sdk-core
|
|
11
13
|
```
|
|
12
14
|
|
|
15
|
+
### React Native CLI Setup
|
|
16
|
+
|
|
17
|
+
For projects created with `react-native init` or Expo Dev Clients:
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
# Install Firebase for push notifications
|
|
21
|
+
npm install @react-native-firebase/app @react-native-firebase/messaging
|
|
22
|
+
|
|
23
|
+
# Install AsyncStorage (already bundled with this SDK)
|
|
24
|
+
npm install @react-native-async-storage/async-storage
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
**Firebase Configuration:**
|
|
28
|
+
|
|
29
|
+
1. **Android:**
|
|
30
|
+
- Download `google-services.json` from Firebase Console
|
|
31
|
+
- Place it in `android/app/`
|
|
32
|
+
- Add the Google Services plugin to `android/app/build.gradle`:
|
|
33
|
+
```gradle
|
|
34
|
+
apply plugin: 'com.google.gms.google-services'
|
|
35
|
+
```
|
|
36
|
+
- Add classpath to `android/build.gradle`:
|
|
37
|
+
```gradle
|
|
38
|
+
classpath 'com.google.gms:google-services:4.3.15'
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
2. **iOS:**
|
|
42
|
+
- Download `GoogleService-Info.plist` from Firebase Console
|
|
43
|
+
- Place it in your Xcode project
|
|
44
|
+
- Enable "Push Notifications" capability in Xcode
|
|
45
|
+
- Add to `ios/YourProject/AppDelegate.m`:
|
|
46
|
+
```objc
|
|
47
|
+
#import <Firebase.h>
|
|
48
|
+
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
|
|
49
|
+
[FIRApp configure];
|
|
50
|
+
[UNUserNotificationCenter currentNotificationCenter].delegate = self;
|
|
51
|
+
[application registerForRemoteNotifications];
|
|
52
|
+
return YES;
|
|
53
|
+
}
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
### Expo Setup
|
|
57
|
+
|
|
58
|
+
For Expo projects (including Expo Go):
|
|
59
|
+
|
|
60
|
+
```bash
|
|
61
|
+
npx expo install expo-notifications
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
**Note:** For push notifications in production, you'll need to configure [Expo Application Services (EAS)](https://docs.expo.dev/push-notifications/overview/).
|
|
65
|
+
|
|
13
66
|
## Quick Start
|
|
14
67
|
|
|
15
68
|
```tsx
|
|
@@ -47,6 +100,69 @@ function ChatScreen() {
|
|
|
47
100
|
}
|
|
48
101
|
```
|
|
49
102
|
|
|
103
|
+
## Push Notifications
|
|
104
|
+
|
|
105
|
+
The SDK automatically detects which push notification system is available and uses the appropriate one.
|
|
106
|
+
|
|
107
|
+
### Setup for React Native CLI
|
|
108
|
+
|
|
109
|
+
Follow the Firebase configuration steps above, then use the `usePushNotifications` hook:
|
|
110
|
+
|
|
111
|
+
```tsx
|
|
112
|
+
import { usePushNotifications } from '@solveo-ai/react-native';
|
|
113
|
+
|
|
114
|
+
function ChatScreen() {
|
|
115
|
+
const { registerDevice } = usePushNotifications({
|
|
116
|
+
mode: 'widget',
|
|
117
|
+
conversationId: 'your-conversation-id',
|
|
118
|
+
autoRegister: true,
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
// Device will automatically register when permission is granted
|
|
122
|
+
}
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
### Setup for Expo
|
|
126
|
+
|
|
127
|
+
```tsx
|
|
128
|
+
import { usePushNotifications } from '@solveo-ai/react-native';
|
|
129
|
+
|
|
130
|
+
function ChatScreen() {
|
|
131
|
+
const { requestPermission, registerDevice } = usePushNotifications({
|
|
132
|
+
mode: 'widget',
|
|
133
|
+
conversationId: 'your-conversation-id',
|
|
134
|
+
});
|
|
135
|
+
|
|
136
|
+
useEffect(() => {
|
|
137
|
+
requestPermission().then(granted => {
|
|
138
|
+
if (granted) {
|
|
139
|
+
registerDevice();
|
|
140
|
+
}
|
|
141
|
+
});
|
|
142
|
+
}, [requestPermission, registerDevice]);
|
|
143
|
+
}
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
## Development
|
|
147
|
+
|
|
148
|
+
From the repo root (monorepo), install and build:
|
|
149
|
+
|
|
150
|
+
```bash
|
|
151
|
+
# From platform root
|
|
152
|
+
npm install
|
|
153
|
+
npm run build --workspace=@solveo-ai/react-native
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
Or from this package:
|
|
157
|
+
|
|
158
|
+
```bash
|
|
159
|
+
cd sdks/react-native
|
|
160
|
+
npm install
|
|
161
|
+
npm run build
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
This produces `dist/index.js`, `dist/index.mjs`, and `dist/index.d.ts`. Type declarations are included; `prepublishOnly` runs the build before publishing so published packages include `dist` and types.
|
|
165
|
+
|
|
50
166
|
## Documentation
|
|
51
167
|
|
|
52
168
|
See [full documentation](https://docs.solveoai.io/sdk/react-native).
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
import React, { ReactNode } from 'react';
|
|
2
|
+
import { SolveoClientConfig, SolveoSDK, Socket, CustomerSocketManager, AgentSocketManager, StreamingSocket, Conversation, Message, HumanAgent, Widget, WidgetConfig, Device, MessageAttachment, Agent, AgentCreateRequest, AgentUpdateRequest, ConversationMetrics, SentimentDistribution, FeedbackStats, TokenUsageMetrics } from '@solveo-ai/sdk-core';
|
|
3
|
+
export { Agent, Conversation, ConversationStatus, FeedbackType, Message, MessageAttachment, SentimentType, Widget } from '@solveo-ai/sdk-core';
|
|
4
|
+
|
|
5
|
+
interface SolveoContextValue {
|
|
6
|
+
sdk: SolveoSDK;
|
|
7
|
+
config: SolveoProviderConfig;
|
|
8
|
+
customerSocket: Socket | null;
|
|
9
|
+
customerSocketManager: CustomerSocketManager | null;
|
|
10
|
+
agentSocket: Socket | null;
|
|
11
|
+
agentSocketManager: AgentSocketManager | null;
|
|
12
|
+
streamingSocket: StreamingSocket | null;
|
|
13
|
+
connectCustomerSocket: (conversationId: string) => void;
|
|
14
|
+
disconnectCustomerSocket: () => void;
|
|
15
|
+
connectAgentSocket: (token: string) => void;
|
|
16
|
+
disconnectAgentSocket: () => void;
|
|
17
|
+
connectStreamingSocket: (conversationId: string) => void;
|
|
18
|
+
disconnectStreamingSocket: () => void;
|
|
19
|
+
}
|
|
20
|
+
interface SolveoProviderConfig extends Omit<SolveoClientConfig, 'platform'> {
|
|
21
|
+
user?: {
|
|
22
|
+
email?: string;
|
|
23
|
+
name?: string;
|
|
24
|
+
id?: string;
|
|
25
|
+
};
|
|
26
|
+
autoConnectCustomer?: boolean;
|
|
27
|
+
autoConnectAgent?: boolean;
|
|
28
|
+
conversationId?: string;
|
|
29
|
+
onError?: (error: Error) => void;
|
|
30
|
+
}
|
|
31
|
+
interface SolveoProviderProps {
|
|
32
|
+
children: ReactNode;
|
|
33
|
+
config: SolveoProviderConfig;
|
|
34
|
+
}
|
|
35
|
+
declare function SolveoProvider({ children, config }: SolveoProviderProps): React.JSX.Element;
|
|
36
|
+
declare function useSolveo(): SolveoContextValue;
|
|
37
|
+
|
|
38
|
+
interface UseChatOptions {
|
|
39
|
+
widgetId?: string;
|
|
40
|
+
agentId?: string;
|
|
41
|
+
persistConversation?: boolean;
|
|
42
|
+
}
|
|
43
|
+
declare function useChat(options?: UseChatOptions): {
|
|
44
|
+
conversation: Conversation | null;
|
|
45
|
+
messages: Message[];
|
|
46
|
+
isLoading: boolean;
|
|
47
|
+
isStreaming: boolean;
|
|
48
|
+
streamingContent: string;
|
|
49
|
+
error: Error | null;
|
|
50
|
+
createConversation: () => Promise<Conversation>;
|
|
51
|
+
sendMessage: (content: string) => Promise<void>;
|
|
52
|
+
loadMessages: (conversationId: string) => Promise<void>;
|
|
53
|
+
submitFeedback: (messageId: string, rating: "THUMBS_UP" | "THUMBS_DOWN") => Promise<void>;
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
declare function useRealtime(): {
|
|
57
|
+
isConnected: boolean;
|
|
58
|
+
agentTyping: boolean;
|
|
59
|
+
queuePosition: number | null;
|
|
60
|
+
estimatedWait: number | null;
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
declare function useEscalation(): {
|
|
64
|
+
escalationId: string | null;
|
|
65
|
+
assignedAgent: HumanAgent | null;
|
|
66
|
+
status: "idle" | "requesting" | "queued" | "active" | "resolved";
|
|
67
|
+
requestHuman: (conversationId: string) => void;
|
|
68
|
+
endChat: () => void;
|
|
69
|
+
submitCSAT: (rating: number) => void;
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
declare function useWidgetConfig(widgetId?: string): {
|
|
73
|
+
widget: Widget | null;
|
|
74
|
+
widgetConfig: WidgetConfig | null;
|
|
75
|
+
isLoading: boolean;
|
|
76
|
+
error: Error | null;
|
|
77
|
+
reload: () => Promise<void>;
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* Push notification event handlers
|
|
82
|
+
*/
|
|
83
|
+
interface PushNotificationHandlers {
|
|
84
|
+
onNotificationReceived?: (notification: any) => void;
|
|
85
|
+
onNotificationTapped?: (notification: any) => void;
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Hook options
|
|
89
|
+
*/
|
|
90
|
+
interface UsePushNotificationsOptions {
|
|
91
|
+
mode?: 'widget' | 'agent';
|
|
92
|
+
conversationId?: string;
|
|
93
|
+
autoRegister?: boolean;
|
|
94
|
+
handlers?: PushNotificationHandlers;
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Enhanced Push Notifications Hook for React Native
|
|
98
|
+
*
|
|
99
|
+
* Supports both customer (widget) and agent (dashboard) modes.
|
|
100
|
+
* Handles permissions, registration, and notification events.
|
|
101
|
+
*
|
|
102
|
+
* Works with both React Native CLI and Expo projects. Automatically detects
|
|
103
|
+
* which push notification system is available:
|
|
104
|
+
* - React Native CLI: Uses @react-native-firebase/messaging
|
|
105
|
+
* - Expo: Uses expo-notifications
|
|
106
|
+
*
|
|
107
|
+
* SETUP INSTRUCTIONS FOR REACT NATIVE CLI:
|
|
108
|
+
* 1. Install Firebase dependencies:
|
|
109
|
+
* npm install @react-native-firebase/app @react-native-firebase/messaging
|
|
110
|
+
*
|
|
111
|
+
* 2. Configure Firebase:
|
|
112
|
+
* - Android: Add google-services.json to android/app/
|
|
113
|
+
* Apply plugin in android/app/build.gradle: apply plugin: 'com.google.gms.google-services'
|
|
114
|
+
* - iOS: Add GoogleService-Info.plist to ios/ and configure APNs
|
|
115
|
+
* Add FirebaseAppDelegate methods in AppDelegate.m
|
|
116
|
+
*
|
|
117
|
+
* 3. Add permissions to manifests:
|
|
118
|
+
* - Android: INTERNET, VIBRATE, RECEIVE_BOOT_COMPLETED in AndroidManifest.xml
|
|
119
|
+
* - iOS: User Notifications capability in Xcode
|
|
120
|
+
*
|
|
121
|
+
* 4. For iOS, register for remote notifications in AppDelegate:
|
|
122
|
+
* - [UNUserNotificationCenter currentNotificationCenter].delegate = self;
|
|
123
|
+
* - [application registerForRemoteNotifications];
|
|
124
|
+
*
|
|
125
|
+
* SETUP INSTRUCTIONS FOR EXPO:
|
|
126
|
+
* 1. Install expo-notifications:
|
|
127
|
+
* npx expo install expo-notifications
|
|
128
|
+
*
|
|
129
|
+
* 2. Configure in app.config.js:
|
|
130
|
+
* Add appropriate configuration for notifications
|
|
131
|
+
*/
|
|
132
|
+
declare function usePushNotifications(options?: UsePushNotificationsOptions): {
|
|
133
|
+
requestPermission: () => Promise<boolean>;
|
|
134
|
+
registerDevice: (convId?: string, pushToken?: string, bundleId?: string) => Promise<Device | null>;
|
|
135
|
+
registerAgentDevice: (pushToken?: string, deviceName?: string) => Promise<any>;
|
|
136
|
+
unregisterDevice: () => Promise<void>;
|
|
137
|
+
device: Device | null;
|
|
138
|
+
isRegistered: boolean;
|
|
139
|
+
isInitialized: boolean;
|
|
140
|
+
permissionStatus: "granted" | "denied" | "undetermined";
|
|
141
|
+
};
|
|
142
|
+
|
|
143
|
+
declare function useAttachments(conversationId?: string): {
|
|
144
|
+
uploading: boolean;
|
|
145
|
+
uploadProgress: number;
|
|
146
|
+
uploadAttachment: (file: {
|
|
147
|
+
uri: string;
|
|
148
|
+
type?: string;
|
|
149
|
+
name?: string;
|
|
150
|
+
}, attachmentType: "IMAGE" | "AUDIO" | "VIDEO" | "DOCUMENT" | "VOICE_NOTE") => Promise<MessageAttachment>;
|
|
151
|
+
};
|
|
152
|
+
|
|
153
|
+
declare function useAgents(accountId?: string): {
|
|
154
|
+
agents: Agent[];
|
|
155
|
+
isLoading: boolean;
|
|
156
|
+
error: Error | null;
|
|
157
|
+
createAgent: (data: AgentCreateRequest) => Promise<Agent>;
|
|
158
|
+
updateAgent: (id: string, data: AgentUpdateRequest) => Promise<Agent>;
|
|
159
|
+
deleteAgent: (id: string) => Promise<void>;
|
|
160
|
+
reload: () => Promise<void>;
|
|
161
|
+
};
|
|
162
|
+
|
|
163
|
+
declare function useConversations(accountId?: string): {
|
|
164
|
+
conversations: Conversation[];
|
|
165
|
+
isLoading: boolean;
|
|
166
|
+
error: Error | null;
|
|
167
|
+
resolveConversation: (id: string) => Promise<void>;
|
|
168
|
+
reload: () => Promise<void>;
|
|
169
|
+
};
|
|
170
|
+
|
|
171
|
+
declare function useAnalytics(accountId?: string, days?: number): {
|
|
172
|
+
metrics: ConversationMetrics | null;
|
|
173
|
+
sentiment: SentimentDistribution | null;
|
|
174
|
+
feedback: FeedbackStats | null;
|
|
175
|
+
tokenUsage: TokenUsageMetrics | null;
|
|
176
|
+
isLoading: boolean;
|
|
177
|
+
error: Error | null;
|
|
178
|
+
reload: () => Promise<void>;
|
|
179
|
+
};
|
|
180
|
+
|
|
181
|
+
declare const storage: {
|
|
182
|
+
getConversationId(): Promise<string | null>;
|
|
183
|
+
setConversationId(id: string): Promise<void>;
|
|
184
|
+
clearConversationId(): Promise<void>;
|
|
185
|
+
getMessages(conversationId: string): Promise<any[]>;
|
|
186
|
+
setMessages(conversationId: string, messages: any[]): Promise<void>;
|
|
187
|
+
getUserIdentity(): Promise<{
|
|
188
|
+
email?: string;
|
|
189
|
+
name?: string;
|
|
190
|
+
} | null>;
|
|
191
|
+
setUserIdentity(identity: {
|
|
192
|
+
email?: string;
|
|
193
|
+
name?: string;
|
|
194
|
+
}): Promise<void>;
|
|
195
|
+
getWidgetConfig(widgetId: string): Promise<any | null>;
|
|
196
|
+
setWidgetConfig(widgetId: string, config: any): Promise<void>;
|
|
197
|
+
};
|
|
198
|
+
|
|
199
|
+
export { SolveoProvider, type SolveoProviderConfig, type SolveoProviderProps, storage, useAgents, useAnalytics, useAttachments, useChat, useConversations, useEscalation, usePushNotifications, useRealtime, useSolveo, useWidgetConfig };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
import React, { ReactNode } from 'react';
|
|
2
|
+
import { SolveoClientConfig, SolveoSDK, Socket, CustomerSocketManager, AgentSocketManager, StreamingSocket, Conversation, Message, HumanAgent, Widget, WidgetConfig, Device, MessageAttachment, Agent, AgentCreateRequest, AgentUpdateRequest, ConversationMetrics, SentimentDistribution, FeedbackStats, TokenUsageMetrics } from '@solveo-ai/sdk-core';
|
|
3
|
+
export { Agent, Conversation, ConversationStatus, FeedbackType, Message, MessageAttachment, SentimentType, Widget } from '@solveo-ai/sdk-core';
|
|
4
|
+
|
|
5
|
+
interface SolveoContextValue {
|
|
6
|
+
sdk: SolveoSDK;
|
|
7
|
+
config: SolveoProviderConfig;
|
|
8
|
+
customerSocket: Socket | null;
|
|
9
|
+
customerSocketManager: CustomerSocketManager | null;
|
|
10
|
+
agentSocket: Socket | null;
|
|
11
|
+
agentSocketManager: AgentSocketManager | null;
|
|
12
|
+
streamingSocket: StreamingSocket | null;
|
|
13
|
+
connectCustomerSocket: (conversationId: string) => void;
|
|
14
|
+
disconnectCustomerSocket: () => void;
|
|
15
|
+
connectAgentSocket: (token: string) => void;
|
|
16
|
+
disconnectAgentSocket: () => void;
|
|
17
|
+
connectStreamingSocket: (conversationId: string) => void;
|
|
18
|
+
disconnectStreamingSocket: () => void;
|
|
19
|
+
}
|
|
20
|
+
interface SolveoProviderConfig extends Omit<SolveoClientConfig, 'platform'> {
|
|
21
|
+
user?: {
|
|
22
|
+
email?: string;
|
|
23
|
+
name?: string;
|
|
24
|
+
id?: string;
|
|
25
|
+
};
|
|
26
|
+
autoConnectCustomer?: boolean;
|
|
27
|
+
autoConnectAgent?: boolean;
|
|
28
|
+
conversationId?: string;
|
|
29
|
+
onError?: (error: Error) => void;
|
|
30
|
+
}
|
|
31
|
+
interface SolveoProviderProps {
|
|
32
|
+
children: ReactNode;
|
|
33
|
+
config: SolveoProviderConfig;
|
|
34
|
+
}
|
|
35
|
+
declare function SolveoProvider({ children, config }: SolveoProviderProps): React.JSX.Element;
|
|
36
|
+
declare function useSolveo(): SolveoContextValue;
|
|
37
|
+
|
|
38
|
+
interface UseChatOptions {
|
|
39
|
+
widgetId?: string;
|
|
40
|
+
agentId?: string;
|
|
41
|
+
persistConversation?: boolean;
|
|
42
|
+
}
|
|
43
|
+
declare function useChat(options?: UseChatOptions): {
|
|
44
|
+
conversation: Conversation | null;
|
|
45
|
+
messages: Message[];
|
|
46
|
+
isLoading: boolean;
|
|
47
|
+
isStreaming: boolean;
|
|
48
|
+
streamingContent: string;
|
|
49
|
+
error: Error | null;
|
|
50
|
+
createConversation: () => Promise<Conversation>;
|
|
51
|
+
sendMessage: (content: string) => Promise<void>;
|
|
52
|
+
loadMessages: (conversationId: string) => Promise<void>;
|
|
53
|
+
submitFeedback: (messageId: string, rating: "THUMBS_UP" | "THUMBS_DOWN") => Promise<void>;
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
declare function useRealtime(): {
|
|
57
|
+
isConnected: boolean;
|
|
58
|
+
agentTyping: boolean;
|
|
59
|
+
queuePosition: number | null;
|
|
60
|
+
estimatedWait: number | null;
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
declare function useEscalation(): {
|
|
64
|
+
escalationId: string | null;
|
|
65
|
+
assignedAgent: HumanAgent | null;
|
|
66
|
+
status: "idle" | "requesting" | "queued" | "active" | "resolved";
|
|
67
|
+
requestHuman: (conversationId: string) => void;
|
|
68
|
+
endChat: () => void;
|
|
69
|
+
submitCSAT: (rating: number) => void;
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
declare function useWidgetConfig(widgetId?: string): {
|
|
73
|
+
widget: Widget | null;
|
|
74
|
+
widgetConfig: WidgetConfig | null;
|
|
75
|
+
isLoading: boolean;
|
|
76
|
+
error: Error | null;
|
|
77
|
+
reload: () => Promise<void>;
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* Push notification event handlers
|
|
82
|
+
*/
|
|
83
|
+
interface PushNotificationHandlers {
|
|
84
|
+
onNotificationReceived?: (notification: any) => void;
|
|
85
|
+
onNotificationTapped?: (notification: any) => void;
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Hook options
|
|
89
|
+
*/
|
|
90
|
+
interface UsePushNotificationsOptions {
|
|
91
|
+
mode?: 'widget' | 'agent';
|
|
92
|
+
conversationId?: string;
|
|
93
|
+
autoRegister?: boolean;
|
|
94
|
+
handlers?: PushNotificationHandlers;
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Enhanced Push Notifications Hook for React Native
|
|
98
|
+
*
|
|
99
|
+
* Supports both customer (widget) and agent (dashboard) modes.
|
|
100
|
+
* Handles permissions, registration, and notification events.
|
|
101
|
+
*
|
|
102
|
+
* Works with both React Native CLI and Expo projects. Automatically detects
|
|
103
|
+
* which push notification system is available:
|
|
104
|
+
* - React Native CLI: Uses @react-native-firebase/messaging
|
|
105
|
+
* - Expo: Uses expo-notifications
|
|
106
|
+
*
|
|
107
|
+
* SETUP INSTRUCTIONS FOR REACT NATIVE CLI:
|
|
108
|
+
* 1. Install Firebase dependencies:
|
|
109
|
+
* npm install @react-native-firebase/app @react-native-firebase/messaging
|
|
110
|
+
*
|
|
111
|
+
* 2. Configure Firebase:
|
|
112
|
+
* - Android: Add google-services.json to android/app/
|
|
113
|
+
* Apply plugin in android/app/build.gradle: apply plugin: 'com.google.gms.google-services'
|
|
114
|
+
* - iOS: Add GoogleService-Info.plist to ios/ and configure APNs
|
|
115
|
+
* Add FirebaseAppDelegate methods in AppDelegate.m
|
|
116
|
+
*
|
|
117
|
+
* 3. Add permissions to manifests:
|
|
118
|
+
* - Android: INTERNET, VIBRATE, RECEIVE_BOOT_COMPLETED in AndroidManifest.xml
|
|
119
|
+
* - iOS: User Notifications capability in Xcode
|
|
120
|
+
*
|
|
121
|
+
* 4. For iOS, register for remote notifications in AppDelegate:
|
|
122
|
+
* - [UNUserNotificationCenter currentNotificationCenter].delegate = self;
|
|
123
|
+
* - [application registerForRemoteNotifications];
|
|
124
|
+
*
|
|
125
|
+
* SETUP INSTRUCTIONS FOR EXPO:
|
|
126
|
+
* 1. Install expo-notifications:
|
|
127
|
+
* npx expo install expo-notifications
|
|
128
|
+
*
|
|
129
|
+
* 2. Configure in app.config.js:
|
|
130
|
+
* Add appropriate configuration for notifications
|
|
131
|
+
*/
|
|
132
|
+
declare function usePushNotifications(options?: UsePushNotificationsOptions): {
|
|
133
|
+
requestPermission: () => Promise<boolean>;
|
|
134
|
+
registerDevice: (convId?: string, pushToken?: string, bundleId?: string) => Promise<Device | null>;
|
|
135
|
+
registerAgentDevice: (pushToken?: string, deviceName?: string) => Promise<any>;
|
|
136
|
+
unregisterDevice: () => Promise<void>;
|
|
137
|
+
device: Device | null;
|
|
138
|
+
isRegistered: boolean;
|
|
139
|
+
isInitialized: boolean;
|
|
140
|
+
permissionStatus: "granted" | "denied" | "undetermined";
|
|
141
|
+
};
|
|
142
|
+
|
|
143
|
+
declare function useAttachments(conversationId?: string): {
|
|
144
|
+
uploading: boolean;
|
|
145
|
+
uploadProgress: number;
|
|
146
|
+
uploadAttachment: (file: {
|
|
147
|
+
uri: string;
|
|
148
|
+
type?: string;
|
|
149
|
+
name?: string;
|
|
150
|
+
}, attachmentType: "IMAGE" | "AUDIO" | "VIDEO" | "DOCUMENT" | "VOICE_NOTE") => Promise<MessageAttachment>;
|
|
151
|
+
};
|
|
152
|
+
|
|
153
|
+
declare function useAgents(accountId?: string): {
|
|
154
|
+
agents: Agent[];
|
|
155
|
+
isLoading: boolean;
|
|
156
|
+
error: Error | null;
|
|
157
|
+
createAgent: (data: AgentCreateRequest) => Promise<Agent>;
|
|
158
|
+
updateAgent: (id: string, data: AgentUpdateRequest) => Promise<Agent>;
|
|
159
|
+
deleteAgent: (id: string) => Promise<void>;
|
|
160
|
+
reload: () => Promise<void>;
|
|
161
|
+
};
|
|
162
|
+
|
|
163
|
+
declare function useConversations(accountId?: string): {
|
|
164
|
+
conversations: Conversation[];
|
|
165
|
+
isLoading: boolean;
|
|
166
|
+
error: Error | null;
|
|
167
|
+
resolveConversation: (id: string) => Promise<void>;
|
|
168
|
+
reload: () => Promise<void>;
|
|
169
|
+
};
|
|
170
|
+
|
|
171
|
+
declare function useAnalytics(accountId?: string, days?: number): {
|
|
172
|
+
metrics: ConversationMetrics | null;
|
|
173
|
+
sentiment: SentimentDistribution | null;
|
|
174
|
+
feedback: FeedbackStats | null;
|
|
175
|
+
tokenUsage: TokenUsageMetrics | null;
|
|
176
|
+
isLoading: boolean;
|
|
177
|
+
error: Error | null;
|
|
178
|
+
reload: () => Promise<void>;
|
|
179
|
+
};
|
|
180
|
+
|
|
181
|
+
declare const storage: {
|
|
182
|
+
getConversationId(): Promise<string | null>;
|
|
183
|
+
setConversationId(id: string): Promise<void>;
|
|
184
|
+
clearConversationId(): Promise<void>;
|
|
185
|
+
getMessages(conversationId: string): Promise<any[]>;
|
|
186
|
+
setMessages(conversationId: string, messages: any[]): Promise<void>;
|
|
187
|
+
getUserIdentity(): Promise<{
|
|
188
|
+
email?: string;
|
|
189
|
+
name?: string;
|
|
190
|
+
} | null>;
|
|
191
|
+
setUserIdentity(identity: {
|
|
192
|
+
email?: string;
|
|
193
|
+
name?: string;
|
|
194
|
+
}): Promise<void>;
|
|
195
|
+
getWidgetConfig(widgetId: string): Promise<any | null>;
|
|
196
|
+
setWidgetConfig(widgetId: string, config: any): Promise<void>;
|
|
197
|
+
};
|
|
198
|
+
|
|
199
|
+
export { SolveoProvider, type SolveoProviderConfig, type SolveoProviderProps, storage, useAgents, useAnalytics, useAttachments, useChat, useConversations, useEscalation, usePushNotifications, useRealtime, useSolveo, useWidgetConfig };
|