Skip to content

Androidでnotifeeのフォアグラウンドサービスを使用してバックグラウンド位置情報更新を改善 - #5186

Merged
TinyKitten merged 2 commits into
devfrom
claude/fix-android-background-location-kQPpL
Jan 27, 2026
Merged

TinyKitten merged 2 commits into
devfrom
claude/fix-android-background-location-kQPpL

Conversation

@TinyKitten

@TinyKitten TinyKitten commented Jan 27, 2026 •

Copy link
Copy Markdown
Member

https://claude.ai/code/session_01VMProqHPQHxetFrF8R1jnp

#5133

Summary by CodeRabbit

  • New Features

    • Androidでロケーション更新中に常時表示されるフォアグラウンド通知を追加しました(省エネモード下でも継続)。
    • バックグラウンドでの通知イベント処理を実装しました。
  • Dependencies

    • Notifee(通知管理)を追加しました。
  • Tests

    • テスト環境向けのモックを拡充し、安定したテスト動作を確保しました。

✏️ Tip: You can customize this high-level summary in your review settings.

@github-actions github-actions Bot added the react label Jan 27, 2026
@coderabbitai

coderabbitai Bot commented Jan 27, 2026 •

Copy link
Copy Markdown
Contributor
📝 Walkthrough

Walkthrough

Notifee を導入し、Android フォアグラウンドサービス用のネイティブモジュールとバックグラウンドイベントハンドラを追加。位置情報更新フローに Android 専用の start/stop 処理を組み込み、テスト用モックと依存を追加しました。

Changes

コホート / ファイル(s) 概要
エントリ/依存追加
index.js, package.json
@notifee/react-native を依存に追加し、notifee.onBackgroundEvent(onBackgroundEvent) をアプリ起動時に登録。
Android ネイティブ前景サービス実装
src/utils/native/android/foregroundServiceModule.ts
通知チャネル作成、フォアグラウンドサービスの開始/停止、実行状態確認、バックグラウンドイベント処理(通知押下/破棄イベント対応)を提供する公開 API を追加。
位置情報フック統合
src/hooks/useStartBackgroundLocationUpdates.ts
Platform 分岐を追加し、Android では Notifee の start/stopForegroundService を位置情報更新ライフサイクルに統合。iOS 側は既存の expo-location 設定を適用。
テストセットアップの拡張
jest.setup.js
@notifee/react-native のモック、追加フック/reanimated フックのスタブ、isTablet と react-native-localize のモックを追加。

Sequence Diagram(s)

sequenceDiagram
    participant App as App 起動
    participant Notifee as Notifee
    participant Foreground as ForegroundService モジュール
    participant Location as 位置情報フック
    participant Android as Android ネイティブ

    App->>Notifee: onBackgroundEvent(handler) 登録
    App->>Location: useStartBackgroundLocationUpdates 起動

    Location->>Foreground: createNotificationChannel()
    Foreground->>Notifee: createChannel()
    Notifee-->>Foreground: チャネル作成完了

    Location->>Foreground: startForegroundService()
    Foreground->>Notifee: displayNotification(ongoing)
    Notifee->>Android: ネイティブ通知表示
    Android-->>Foreground: 通知表示完了

    Location->>Android: startLocationUpdates()
    Android-->>Location: 位置情報更新開始

    Android->>Notifee: ユーザ操作(PRESS/DISMISS)イベント発生
    Notifee->>Foreground: onBackgroundEvent 発火
    Foreground-->>Location: 必要に応じて再起動 / デフォルト処理
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 分

Possibly related PRs

Suggested labels

android

詩

🐰 Notifee が来たよ、通知を立てて
背景でも歩む僕の位置を見守るよ
Android の夜に灯る小さな光
サービスは止まらず、旅は続くよ ✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed このプルリクエストのタイトルは、Androidでnotifeeのフォアグラウンドサービスを使用してバックグラウンド位置情報更新を改善することを説明しており、実際の変更内容と一致しています。
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

Comment @coderabbitai help to get the list of available commands and usage tips.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants