編輯

共用方式為


Device

Provides methods to use native device capabilities.

Important

If you want to use the device API methods, you need to declare the usage of these method in feature-usage node in the manifest file.

Available for

Model-driven and canvas apps

Syntax

context.device

Methods

Method Description
captureAudio Invokes the device microphone to record audio.
captureImage Invokes the device camera to capture the image.
captureVideo Invokes the device camera to record video.
getBarcodeValue Invokes the device camera to scan the barcode information, such as product number.
getCurrentPosition Returns the current location using the device geolocation capability.
pickFile Opens a dialog box to select files for the upload.

Example

 private onUploadButtonClick(event: Event): void {
    this._context.device.pickFile().then(this.processFile.bind(this), this.showError.bind(this));
  }

Sample controls

Device API component
Image upload component

Power Apps component framework API reference
Power Apps component framework overview