To connect to Frappe's WebSocket and receive real-time updates when a document of a particular DocType is saved, you can use the socket.io-client
library in your React Native app. Here's an example of a single-component app that demonstrates how to connect to the WebSocket, authenticate with an API key, and receive updates for a specific DocType:
import React, { useState, useEffect } from 'react';
import { StyleSheet, Text, View } from 'react-native';
import io from 'socket.io-client';
const API_KEY = 'your_api_key'; // Replace with your actual API key
const SITE_NAME = 'your_site_name'; // Replace with your site name
const DOCTYPE = 'your_doctype'; // Replace with the DocType you want to monitor