//using Firebase.Auth;
//using Google;
using System.Collections;
using TMPro;
using UnityEngine;
using UnityEngine.U2D;

#if UNITY_ANDROID
using UnityEngine.Android;
#endif

public class TitleInfo : MyCoroutine
{
    public TextMeshProUGUI label_msg, t_ver;

    IEnumerator Start()
    {
        t_ver.text = DSUtil.Format("{0}({1})", Application.version, "E or G or O");
        label_msg.text = "";

        // TODO 정인호 : 테이블 로드
        //// 테이블 로딩 기다리기
        //while (!TableChecker.Ins.CheckAllLoad()) yield return null;
        //label_msg.text = table_localtext.Ins.Get_Text(1);
        // UI 아틀라스 로드
        yield return AddrResourceMgr.Ins.LoadObjectSequential<SpriteAtlas>("MainUI/UIAtlas.spriteatlasv2", atlas => { UIAtlasMgr.Ins.Set(atlas); });

        yield return null;

        //#if FGB_LIVE
        //        SRDebug.Instance.IsTriggerEnabled = false;
        //#else
        //        SRDebug.Instance.IsTriggerEnabled = true;
        //#endif

#if !UNITY_EDITOR && UNITY_ANDROID && !FGB_OneStore
        if (!Application.version.Equals("9.9.9"))
            if (Application.installerName != "com.android.vending")
            {
                Popup.Ins.Set(ePopupType.One, 2,
                                 () => { Application.OpenURL("market://details?id=" + Application.identifier); DSUtil.Quit(); },
                                 () => { Application.OpenURL("market://details?id=" + Application.identifier); DSUtil.Quit(); });
                yield break;
            }
#endif
#if UNITY_ANDROID
        if (!Permission.HasUserAuthorizedPermission("android.permission.POST_NOTIFICATIONS"))
            Permission.RequestUserPermission("android.permission.POST_NOTIFICATIONS");
#endif
#if !UNITY_EDITOR
        // 파이어 베이스 초기화
        Firebase.FirebaseApp.CheckAndFixDependenciesAsync().ContinueWith(task => {
            var dependencyStatus = task.Result;
            if (dependencyStatus == Firebase.DependencyStatus.Available)
            {
                //FirebaseAnalytics.SetAnalyticsCollectionEnabled(true);
            }
            else
            {
                Debug.LogError(DSUtil.Format( "Could not resolve all Firebase dependencies: {0}", dependencyStatus));
                // Firebase Unity SDK is not safe to use here.
            }
        });
#endif

        // 인앱 결제 정보 받아오기
        //label_msg.text = table_localtext.Ins.Get_Text(3);
        yield return new WaitForSeconds(0.1f);
        
    }
}