搜尋套件、儲存庫與 APP 分類

phone_state 封面
套件詳情v4.0.1

phone_state

此外掛程式可讓您快速且輕鬆地了解您的 Android 或 iOS 裝置是否正在接收來電,以及通話狀態。

AndroidiOS
近 30 天下載
1.5萬
喜歡數
141
Pub 分數
160

安裝套件

flutter pub add phone_state

套件介紹

根據套件公開資料產生的選型評估,僅供參考。

phone_state 套件提供了一種簡單的方式,用於在 Android 和 iOS 設備上檢測來電並監控通話狀態。該外掛程式可讓應用程式在收到電話時動態回應,例如暫停媒體播放或調整應用行為。此外掛程式利用原生裝置 API 來提供即時通話狀態更新,設定簡單。非常適合需要感知語音通訊事件的應用程式,例如音樂播放器、訊息應用或需要在通話期間進行調整的生產力工具。

適用情境

  • 檢測來電
  • 通話期間暫停媒體
  • 調整通話期間的應用行為
  • 即時監控通話狀態
  • 與電話感知功能整合

主要特色

  • 即時通話狀態偵測
  • 跨平台支援(Android 與 iOS)
  • 最小設定
  • 原生 API 集成
  • 輕量且高效

適合對象

  • 媒體播放應用
  • 生產力工具
  • 訊息應用
  • 整合電話功能的服務
  • 需要通話事件感知的應用程式

使用建議

  • 兩個平台都需要適當的權限
  • 僅限呼叫狀態,無法實現完整的電話控制
  • 可能需要處理背景執行
  • 行為在 Android 和 iOS 之間略有差異
  • 不適用於撥打或管理電話

原始 README

以下為關聯原始碼儲存庫的 README 原文快照,最新內容請造訪原始碼儲存庫。

DESCRIPTION

This plugin allows you to know quickly and easily if your Android or iOS device is receiving a call and to know the status of the call.

PAY ATTENTION

  • In the iOS simulator doesn't work
  • The caller phone number is only available on Android, not iOS
  • This plugin reports phone call state only. It does not answer, reject, end, or record calls, and it does not change whether other packages can capture call audio.
  • Android detects system telephony call state only. Third-party VoIP calls from apps such as Telegram or WhatsApp are not supported. iOS CallKit behavior can differ by app.
  • The iOS implementation uses CallKit. For apps distributed in regions where CallKit is restricted, including China App Store review contexts, confirm availability and territory rules with Apple before submission.
  • PhoneState.stream requires the app process to be running with an active Flutter engine and listener. It does not send callbacks after the app is terminated.
  • On Android, if PhoneState.stream does not emit, confirm READ_PHONE_STATE is declared and granted at runtime. Some OEM battery or background restrictions, including MIUI settings on Xiaomi devices, can also delay or block callbacks.

Buy Me A Coffee

HOW TO INSTALL

Flutter

Note: This version requires Flutter >= 3.44.0 and Dart >= 3.12.2. Add phone_state to your app's pubspec.yaml, not to this package's pubspec.yaml. Your app/package name must be different from phone_state.

dependencies:
  flutter:
    sdk: flutter
  phone_state: 4.0.1
Android: Added permission on manifest
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.READ_CALL_LOG" />

READ_PHONE_STATE is required. READ_CALL_LOG is optional and only needed for caller phone numbers.

Warning: Adding READ_CALL_LOG permission, your app will be removed from the Play Store if you don't have a valid reason to use it. Read more.

iOS: Not needed permissions on info.plist

HOW TO USE

Get stream phone state status
StreamBuilder<PhoneState>(
  stream: PhoneState.stream,
  ...
Troubleshooting package conflicts

If phone_state stops receiving updates after adding another package:

  • Confirm the required Android runtime permissions are granted before listening. READ_PHONE_STATE is required, and READ_CALL_LOG is only needed for caller phone numbers.
  • Keep a single active PhoneState.stream listener for each app flow. Cancel the previous subscription before starting another one when screens, services, or background handlers change.
  • When reporting a conflict, include the other package names, platform versions, a minimal reproduction, and the relevant Flutter, Logcat, or Xcode logs.

SCREENSHOT

Write me in the GitHub issues the new features you need and, if they are approved of course, I will implement them as soon as I can.

所屬分類

依賴

依賴清單 1 項

原始碼儲存庫

使用此套件的專案

暫無相關資料。