CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/npm-vkontakte--vk-bridge

Bridge library for VK Mini Apps to communicate with VK clients across iOS, Android, and Web platforms

Pending
Overview
Eval results
Files

device-features.mddocs/

Device Features & Sensors

Access to device capabilities including haptic feedback, camera flash, sensors, hardware features, and device-specific functionality.

Capabilities

Haptic Feedback

Provide tactile feedback through device vibration with different intensity levels.

/**
 * Trigger haptic impact feedback
 * @param props.style - Feedback intensity level
 */
function send(method: 'VKWebAppTapticImpactOccurred', props: {
  style: TapticVibrationPowerType;
}): Promise<{ result: true }>;

/**
 * Trigger haptic notification feedback
 * @param props.type - Notification feedback type
 */
function send(method: 'VKWebAppTapticNotificationOccurred', props: {
  type: TapticNotificationType;
}): Promise<{ result: true }>;

/**
 * Trigger haptic selection feedback
 */
function send(method: 'VKWebAppTapticSelectionChanged'): Promise<{ result: true }>;

type TapticVibrationPowerType = 'light' | 'medium' | 'heavy';
type TapticNotificationType = 'error' | 'success' | 'warning';

Camera Flash

Control device camera flash functionality.

/**
 * Get flash information and availability
 */
function send(method: 'VKWebAppFlashGetInfo'): Promise<{
  is_available: boolean;
  level: number;
}>;

/**
 * Set flash brightness level
 * @param props.level - Flash brightness (0-1)
 */
function send(method: 'VKWebAppFlashSetLevel', props: {
  level: number;
}): Promise<{ result: true }>;

Motion Sensors

Access device accelerometer, gyroscope, and motion sensors.

/**
 * Start accelerometer data collection
 * @param props.refresh_rate - Data refresh rate (optional)
 */
function send(method: 'VKWebAppAccelerometerStart', props?: {
  refresh_rate?: string;
}): Promise<{ result: true }>;

/**
 * Stop accelerometer data collection
 */
function send(method: 'VKWebAppAccelerometerStop'): Promise<{ result: true }>;

/**
 * Start gyroscope data collection
 */
function send(method: 'VKWebAppGyroscopeStart'): Promise<{ result: true }>;

/**
 * Stop gyroscope data collection
 */
function send(method: 'VKWebAppGyroscopeStop'): Promise<{ result: true }>;

/**
 * Start device motion data collection
 */
function send(method: 'VKWebAppDeviceMotionStart'): Promise<{ result: true }>;

/**
 * Stop device motion data collection
 */
function send(method: 'VKWebAppDeviceMotionStop'): Promise<{ result: true }>;

Audio Control

Control audio playback state.

/**
 * Pause currently playing audio
 */
function send(method: 'VKWebAppAudioPause'): Promise<{ result: true }>;

Clipboard Operations

Copy text content to device clipboard for user convenience.

/**
 * Copy text to device clipboard
 * @param props.text - Text content to copy
 */
function send(method: 'VKWebAppCopyText', props: {
  text: string;
}): Promise<{ result: true }>;

Usage Examples:

// Copy text to clipboard
await bridge.send('VKWebAppCopyText', {
  text: 'Hello, VK Bridge!'
});

// Copy dynamic content
const shareText = `Check out this app: ${window.location.href}`;
await bridge.send('VKWebAppCopyText', { text: shareText });

// Copy with user feedback
try {
  await bridge.send('VKWebAppCopyText', { 
    text: 'Copied content' 
  });
  console.log('Text copied to clipboard');
} catch (error) {
  console.error('Failed to copy text:', error);
}

Contact Access

Access device contacts with user permission.

/**
 * Open contacts picker for user selection
 * @returns Selected contact information
 */
function send(method: 'VKWebAppOpenContacts'): Promise<{
  phone?: string;
  first_name?: string;
  last_name?: string;
}>;

Usage Examples:

// Open contacts picker
try {
  const contact = await bridge.send('VKWebAppOpenContacts');
  console.log('Selected contact:', contact);
  
  if (contact.phone) {
    console.log('Phone:', contact.phone);
  }
  if (contact.first_name || contact.last_name) {
    console.log('Name:', contact.first_name, contact.last_name);
  }
} catch (error) {
  if (error.error_data?.error_code === 4) {
    console.log('User cancelled contact selection');
  } else {
    console.error('Contact access error:', error);
  }
}

// Check availability before using
const canAccessContacts = await bridge.supportsAsync('VKWebAppOpenContacts');
if (canAccessContacts) {
  const contact = await bridge.send('VKWebAppOpenContacts');
  processSelectedContact(contact);
} else {
  showManualContactEntry();
}

Install with Tessl CLI

npx tessl i tessl/npm-vkontakte--vk-bridge

docs

advertising-monetization.md

application-lifecycle.md

authentication.md

core-bridge.md

device-features.md

geolocation.md

index.md

launch-parameters.md

middleware.md

payments-commerce.md

qr-barcode-scanning.md

social-features.md

storage-data.md

ui-display.md

user-data.md

tile.json