@capacitor/toast
トースト API はユーザーに重要な情報を表示するための通知ポップアップを提供します。本物のトーストと同じです!
インストール
npm install @capacitor/toast
npx cap sync
PWA 注
PWA 要素はトースト・プラグインを機能させるために必要です。
例
import { Toast } from '@capacitor/toast';
const showHelloToast = async () => {
await Toast.show({
text: 'Hello!',
});
};
API
show(...)
show(options: ShowOptions) => Promise<void>
画面にトーストを表示します
パラメータ | タイプ |
---|---|
options | ShowOptions |
バージョン 1.0.0
インターフェイス
ShowOptions
プロパティ | タイプ | 説明 | 既定 | バージョン |
---|---|---|---|---|
text | string | トーストに表示するテキスト | 1.0.0 | |
duration | 'short' | 'long' | トーストの表示時間、「short」(2000ms)または「long」(3500ms) | 'short' | 1.0.0 |
position | 'top' | 'center' | 'bottom' | トーストの位置。Android 12 以降では、すべてのトーストが下部に表示されます。 | 'bottom' | 1.0.0 |