2

私は別のプロジェクトに統合したいFCM google-service.json、同じファイルに統合する方法異なるプロジェクトキー私はこのような2つのプロジェクトを試しましたが、私たちのプロジェクトに追加する必要はありません。複数のgoogle-services.jsonファイルを同じプロジェクト内の異なるGoogle FCMサービス用に統合する方法

{ 
      "project_info": { 
      "project_number": "60554696754247", 
      "firebase_url": "https://project-1fca7.firebaseio.com", 
      "project_id": "project-1fca7", 
      "storage_bucket": "project-1fca7.appspot.com" 
      }, 
      "client": [ 
      { 
       "client_info": { 
       "mobilesdk_app_id": "xxxxxxxxxxxxx", 
       "android_client_info": { 
        "package_name": "com.company.project1" 
       } 
       }, 
       "oauth_client": [ 
       { 
        "client_id": "xxxxxxxxxxxxxxxx", 
        "client_type": 3 
       } 
       ], 
       "api_key": [ 
       { 
        "current_key": "" 
       } 
       ], 
       "services": { 
       "analytics_service": { 
        "status": 1 
       }, 
       "appinvite_service": { 
        "status": 1, 
        "other_platform_oauth_client": [] 
       }, 
       "ads_service": { 
        "status": 2 
       } 
       } 
      } 
      ], 
      "project_info": { 
      "project_number": "13052496681", 
      "firebase_url": "https://project-2ebf8.firebaseio.com", 
      "project_id": "project-2ebf8", 
      "storage_bucket": "project-2ebf8.appspot.com" 
      }, 
      "client": [ 
      { 
       "client_info": { 
       "mobilesdk_app_id": "xxxxxxxxxxxxxxx", 
       "android_client_info": { 
        "package_name": "com.company.project2" 
       } 
       }, 
       "oauth_client": [ 
       { 
        "client_id": "xxxxxxxxxxxxxx", 
        "client_type": 3 
       } 
       ], 
       "api_key": [ 
       { 
        "current_key": "xxxxxxxxxxxxxxxx" 
       } 
       ], 
       "services": { 
       "analytics_service": { 
        "status": 1 
       }, 
       "appinvite_service": { 
        "status": 1, 
        "other_platform_oauth_client": [] 
       }, 
       "ads_service": { 
        "status": 2 
       } 
       } 
      } 
      ], 

      "configuration_version": "1" 
     } 
+0

、それは***強くないことをお勧め***:

あなたが複数のアプリケーションを使用したい場合は、あなたが言ったように、手動でこのようなFirebaseAppを初期化する必要がありますgoogle-services.jsonファイルこれをやりたい理由は何ですか? –

答えて

0

それはあなたのユースケースがあるまさに明確ではないが、それはgoogle-services.jsonファイルを使用して、完全にオプションであることは注目に値しますし、あなたのケースでは、あなたがそれをスキップしてアプリを手動で設定することもできます。

documentation hereは、プラグインがJSONファイルをどのように処理するかを説明しています。

は、基本的にはプラグインがこのようになりますstrings.xmlファイル作成:あなたはFCMの話をしているので

<?xml version="1.0" encoding="utf-8"?> 
<resources> 

    <! -- Present in all applications --> 
    <string name="google_app_id" translatable="false">1:1035469437089:android:73a4fb8297b2cd4f</string> 

    <! -- Present in applications with the appropriate services configured --> 
    <string name="gcm_defaultSenderId" translatable="false">1035469437089</string> 
    <string name="default_web_client_id" translatable="false">337894902146-e4uksm38sne0bqrj6uvkbo4oiu4hvigl.apps.googleusercontent.com</string> 
    <string name="ga_trackingId" translatable="false">UA-65557217-3</string> 
    <string name="firebase_database_url" translatable="false">https://example-url.firebaseio.com</string> 
    <string name="google_api_key" translatable="false">AIzbSyCILMsOuUKwN3qhtxrPq7FFemDJUAXTyZ8</string> 
    <string name="google_crash_reporting_api_key" translatable="false">AIzbSyCILMsOuUKwN3qhtxrPq7FFemDJUAXTyZ8</string> 

</resources> 

を、関連部分はgoogle_app_idgcm_defaultSenderId、およびgoogle_api_keyです。これらの名前の文字列をアプリケーションに作成すると、Firebaseは自動的に正しく初期化されます。変更するには、一般的には

FirebaseApp customApp = FirebaseApp.initializeApp(this, 
     new FirebaseOptions.Builder() 
      .setApplicationId(...) 
      .setApiKey(...) 
      .setGcmSenderId(...) 
      .build(), 
     "custom-app-name"); 
関連する問題