패키지, 저장소 및 앱 카테고리 검색

패키지 상세v2.0.1+1

foreground_service

Android 포그라운드 서비스를 통해 Dart 코드를 실행하기 위한 Flutter 플러그인입니다. Android O에서는 거의 테스트되었고, M에서는 약간만 테스트되었습니다. iOS 지원은 계획되어 있지 않습니다.

30일 다운로드
25
좋아요
52
Pub 점수
30

패키지 설치

flutter pub add foreground_service

패키지 개요

공개 정보를 바탕으로 생성한 선택 가이드입니다.

Dart 코드가 Android 포그라운드 서비스에서 실행되도록 허용하는 플러터 플러그인으로, 앱이 백그라운드에 있을 때도 장시간 실행 작업이 계속되도록 보장합니다. 주로 Android O 이상 버전을 대상으로 하며, 이전 버전에서는 최소한의 테스트만 수행되었습니다. iOS 지원은 계획되어 있지 않습니다. 이 플러그인은 Android의 포그라운드 서비스 라이프사이클과 통합되어 위치 추적이나 오디오 재생과 같은 중요한 작업을 시스템에 의해 종료되지 않도록 유지할 수 있습니다. Android 매니페스트에서 적절한 구성 및 권한 설정이 필요합니다.

사용 사례

  • 백그라운드 위치 추적
  • 장기간 실행되는 데이터 처리
  • 백그라운드 오디오 재생
  • 지속적인 네트워크 연결
  • 실시간 모니터링 서비스

주요 기능

  • Android 프론트그라운드 서비스 통합
  • 프론트그라운드 컨텍스트에서 Dart 코드 실행
  • 시스템 수준의 지속성
  • 최소한의 iOS 지원
  • 매니페스트 구성이 필요합니다

적합한 대상

  • 백그라운드 작업의 신뢰성을 필요로 하는 앱
  • 위치 기반 서비스
  • 미디어 플레이어
  • 사물인터넷 장치 컨트롤러
  • 실시간 데이터 동기화

고려 사항

  • iOS 지원 없음
  • 이전 Android 버전에서 제한적인 테스트 수행
  • Android 매니페스트 설정이 필요합니다
  • 포그라운드 서비스 알림 필요
  • 배터리 사용 영향

원본 README

연결된 소스 저장소의 README 원문 스냅샷입니다. 최신 내용은 저장소에서 확인하세요.

foreground_service (Flutter v.1.12.x or later)

Create Android foreground service/notification

Prep (Android side):

Android foreground services require a notification to be displayed,
and notifications require an icon.

For this plugin to work, the icon needs to be in this specific location:

res/drawable/org_thebus_foregroundserviceplugin_notificationicon

(take a look at the /example app if you're confused)


-- NOTE FOR PLUGIN VERSION 2.0.0 and above --
compileSdkVersion & targetSdkVersion need to be 29 or above, or the build will fail
these values are set/can be changed in the build.gradle for the app

Use (Flutter/Dart side):

To start the service, call ForegroundService.startForegroundService([serviceFunction])

serviceFunction will then be executed periodically, but "minimum/best-effort"
i.e. it will try to make the interval between function executions *at least* that long

Doesn't work?

As long as you're calling ForegroundService.startForegroundService,
"flutter run" should show error messages that indicate what's wrong/missing

i.e. messages beginning with E/ForegroundServicePlugin indicate an error from the plugin

Caution:

ForegroundService.notification.get* methods may give unexpected values.

Once notifications are sent out, there's no way to retrieve the "current" data.

To work around this, the plugin keeps a version of the notification around.
This version may not have been "sent out" yet, however.

Disclaimer:

Most of the fancy stuff is shamelessly pilfered from the android_alarm_manager plugin

카테고리

소스 저장소

이 패키지를 사용하는 프로젝트

아직 데이터가 없습니다.