or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

Files

docs

advertising-monetization.mdapplication-lifecycle.mdauthentication.mdcore-bridge.mddevice-features.mdgeolocation.mdindex.mdlaunch-parameters.mdmiddleware.mdpayments-commerce.mdqr-barcode-scanning.mdsocial-features.mdstorage-data.mdui-display.mduser-data.md

device-features.mddocs/

0

# Device Features & Sensors

1

2

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

3

4

## Capabilities

5

6

### Haptic Feedback

7

8

Provide tactile feedback through device vibration with different intensity levels.

9

10

```typescript { .api }

11

/**

12

* Trigger haptic impact feedback

13

* @param props.style - Feedback intensity level

14

*/

15

function send(method: 'VKWebAppTapticImpactOccurred', props: {

16

style: TapticVibrationPowerType;

17

}): Promise<{ result: true }>;

18

19

/**

20

* Trigger haptic notification feedback

21

* @param props.type - Notification feedback type

22

*/

23

function send(method: 'VKWebAppTapticNotificationOccurred', props: {

24

type: TapticNotificationType;

25

}): Promise<{ result: true }>;

26

27

/**

28

* Trigger haptic selection feedback

29

*/

30

function send(method: 'VKWebAppTapticSelectionChanged'): Promise<{ result: true }>;

31

32

type TapticVibrationPowerType = 'light' | 'medium' | 'heavy';

33

type TapticNotificationType = 'error' | 'success' | 'warning';

34

```

35

36

### Camera Flash

37

38

Control device camera flash functionality.

39

40

```typescript { .api }

41

/**

42

* Get flash information and availability

43

*/

44

function send(method: 'VKWebAppFlashGetInfo'): Promise<{

45

is_available: boolean;

46

level: number;

47

}>;

48

49

/**

50

* Set flash brightness level

51

* @param props.level - Flash brightness (0-1)

52

*/

53

function send(method: 'VKWebAppFlashSetLevel', props: {

54

level: number;

55

}): Promise<{ result: true }>;

56

```

57

58

### Motion Sensors

59

60

Access device accelerometer, gyroscope, and motion sensors.

61

62

```typescript { .api }

63

/**

64

* Start accelerometer data collection

65

* @param props.refresh_rate - Data refresh rate (optional)

66

*/

67

function send(method: 'VKWebAppAccelerometerStart', props?: {

68

refresh_rate?: string;

69

}): Promise<{ result: true }>;

70

71

/**

72

* Stop accelerometer data collection

73

*/

74

function send(method: 'VKWebAppAccelerometerStop'): Promise<{ result: true }>;

75

76

/**

77

* Start gyroscope data collection

78

*/

79

function send(method: 'VKWebAppGyroscopeStart'): Promise<{ result: true }>;

80

81

/**

82

* Stop gyroscope data collection

83

*/

84

function send(method: 'VKWebAppGyroscopeStop'): Promise<{ result: true }>;

85

86

/**

87

* Start device motion data collection

88

*/

89

function send(method: 'VKWebAppDeviceMotionStart'): Promise<{ result: true }>;

90

91

/**

92

* Stop device motion data collection

93

*/

94

function send(method: 'VKWebAppDeviceMotionStop'): Promise<{ result: true }>;

95

```

96

97

### Audio Control

98

99

Control audio playback state.

100

101

```typescript { .api }

102

/**

103

* Pause currently playing audio

104

*/

105

function send(method: 'VKWebAppAudioPause'): Promise<{ result: true }>;

106

```

107

108

### Clipboard Operations

109

110

Copy text content to device clipboard for user convenience.

111

112

```typescript { .api }

113

/**

114

* Copy text to device clipboard

115

* @param props.text - Text content to copy

116

*/

117

function send(method: 'VKWebAppCopyText', props: {

118

text: string;

119

}): Promise<{ result: true }>;

120

```

121

122

**Usage Examples:**

123

124

```typescript

125

// Copy text to clipboard

126

await bridge.send('VKWebAppCopyText', {

127

text: 'Hello, VK Bridge!'

128

});

129

130

// Copy dynamic content

131

const shareText = `Check out this app: ${window.location.href}`;

132

await bridge.send('VKWebAppCopyText', { text: shareText });

133

134

// Copy with user feedback

135

try {

136

await bridge.send('VKWebAppCopyText', {

137

text: 'Copied content'

138

});

139

console.log('Text copied to clipboard');

140

} catch (error) {

141

console.error('Failed to copy text:', error);

142

}

143

```

144

145

### Contact Access

146

147

Access device contacts with user permission.

148

149

```typescript { .api }

150

/**

151

* Open contacts picker for user selection

152

* @returns Selected contact information

153

*/

154

function send(method: 'VKWebAppOpenContacts'): Promise<{

155

phone?: string;

156

first_name?: string;

157

last_name?: string;

158

}>;

159

```

160

161

**Usage Examples:**

162

163

```typescript

164

// Open contacts picker

165

try {

166

const contact = await bridge.send('VKWebAppOpenContacts');

167

console.log('Selected contact:', contact);

168

169

if (contact.phone) {

170

console.log('Phone:', contact.phone);

171

}

172

if (contact.first_name || contact.last_name) {

173

console.log('Name:', contact.first_name, contact.last_name);

174

}

175

} catch (error) {

176

if (error.error_data?.error_code === 4) {

177

console.log('User cancelled contact selection');

178

} else {

179

console.error('Contact access error:', error);

180

}

181

}

182

183

// Check availability before using

184

const canAccessContacts = await bridge.supportsAsync('VKWebAppOpenContacts');

185

if (canAccessContacts) {

186

const contact = await bridge.send('VKWebAppOpenContacts');

187

processSelectedContact(contact);

188

} else {

189

showManualContactEntry();

190

}

191

```