React Native SDK
Installation
npm install @moontraze/react-nativeQuick Start
import MoonSDK from '@moontraze/react-native';
const moon = new MoonSDK({
projectId: 'YOUR_PROJECT_ID',
apiKey: 'YOUR_API_KEY',
});
// Auth
const result = await moon.auth.register('user@example.com', 'secret123', 'John');
moon.setToken(result.token!);
await moon.auth.login('user@example.com', 'secret123');
moon.auth.logout();
await moon.auth.changePassword('oldSecret', 'newSecret');
// Database
await moon.db.set('users/user_123', { name: 'John' });
const user = await moon.db.get('users/user_123');
await moon.db.updateField('users/user_123', 'status', 'verified');
await moon.db.deleteField('users/user_123', 'phone');
await moon.db.delete('users/user_123');
// Storage
await moon.storage.upload({
uri: 'file:///path/to/photo.jpg',
name: 'photo.jpg',
type: 'image/jpeg',
});
const files = await moon.storage.list();
await moon.storage.createFolder('My Folder');
await moon.storage.delete(fileId);
await moon.storage.deleteFolder(folderId);
const quota = await moon.storage.getQuota();
// Notifications
await moon.notifications.registerToken(fcmToken, { platform: 'android' });
await moon.notifications.sendToProject('project_id', { title: 'Hello', body: 'World' });
await moon.notifications.sendToUser('user_id', { title: 'Hi', body: 'There' });
await moon.notifications.sendToTopic({ topic: 'premium', title: 'Hi', body: 'There' });
const history = await moon.notifications.getHistory(50);