コガネブログ

平日更新を目標に Unity や C#、Visual Studio、ReSharper などのゲーム開発アレコレを書いていきます

【Unity】オフラインの時に FirebaseRemoteConfig.FetchAsync で発生するエラーや例外

概要

  • Unity エディタ
    • fetching failure: http code 0
    • FirebaseException
  • iOS
    • FirebaseException: インターネット接続がオフラインのようです。
    • FirebaseException: Failed to get installations token.
  • Android
    • FirebaseException: The client had an error while calling the backend!
    • FirebaseException: Firebase Installations failed to get installation auth token for fetch.

オフラインで例外を握りつぶす例

using System;
using Firebase;
using Firebase.RemoteConfig;
using UnityEngine;

public class Example : MonoBehaviour
{
    private async void Start()
    {
        var message = string.Empty;

        try
        {
            var remoteConfig = FirebaseRemoteConfig.DefaultInstance;
            await remoteConfig.FetchAsync();
            var configValue = remoteConfig.GetValue( "message" );
            message = configValue.StringValue;
        }
        catch ( FirebaseException )
        {
        }

        Debug.Log( message );
    }
}