> ## Documentation Index
> Fetch the complete documentation index at: https://docs.auxia.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Flutterサンプルセットアップ

> このセクションでは、プッシュ通知および対応する通知イベントを統合するためのサンプルFlutter Androidアプリケーションのセットアップに役立つリンクを紹介します。

<Note>
  日本語版はAIによる翻訳です。正確な情報については[英語版](/deploying-auxia/delivery-integrations/firebase-push-notifications-integration-manual/sample-flutter-set-up)をご参照ください。
</Note>

[完全な実装はこちらを参照](/ja/deploying-auxia/delivery-integrations/firebase-push-notifications-integration-manual/sample-flutter-set-up/sample-flutter-client-implementation)。

### **ステップ1: 初期化**

[Flutter for Androidでクライアントをセットアップ](https://firebase.google.com/docs/flutter/setup?platform=android)します。

### **ステップ2: プラグイン**

以下のプラグインを追加します:

1. [Google Analytics](https://firebase.google.com/docs/analytics/get-started?platform=flutter)
2. [Firebase Cloud Messaging](https://firebase.google.com/docs/cloud-messaging/flutter/client)

### **ステップ3: FCMトークン**

開発者のデバイスのFCMトークンを取得するためのコード変更を行います。

```protobuf theme={null}
  @override
  void initState() {
    super.initState();
    _initializeFirebaseMessaging();
  }

  /// Initializes Firebase Messaging and retrieves the FCM token.
  Future<void> _initializeFirebaseMessaging() async {
    FirebaseMessaging messaging = FirebaseMessaging.instance;

    await messaging.requestPermission(
      alert: true,
      badge: true,
      sound: true,
      provisional: true,
    );

    // Get the initial FCM token
    String? token = await messaging.getToken();
    _updateFcmToken(token);

    // Handle token refresh
    FirebaseMessaging.instance.onTokenRefresh.listen(_updateFcmToken);
  }

  /// Updates the FCM token and prints it for debugging.
  void _updateFcmToken(String? token) {
    setState(() => _fcmToken = token);
    debugPrint("FCM Token: $_fcmToken");
  }
```
