public void CommitSettings()
 {
     if (File.Exists(AppCenterResourcesPath))
     {
         File.Delete(AppCenterResourcesPath);
     }
     XmlResourceHelper.WriteXmlResource(AppCenterResourcesPath, _resourceValues);
 }
Exemple #2
0
 public void CommitSettings(string filePath)
 {
     if (File.Exists(filePath))
     {
         File.Delete(filePath);
     }
     XmlResourceHelper.WriteXmlResource(filePath, _resourceValues);
 }
    static void UpdateJson()
    {
#if UNITY_ANDROID
        var bundleId            = ApplicationIdHelper.GetApplicationId();
        var projectDir          = Path.Combine(Application.dataPath, "..");
        var googleServicesFiles = FindGoogleServicesFiles();
        if (googleServicesFiles == null)
        {
            return;
        }
        if (googleServicesFiles.Length > 1)
        {
            Debug.LogWarning("More than one " + GoogleServicesInputFile + " file found, using first one.");
        }
        var inputPath  = Path.Combine(projectDir, googleServicesFiles[0]);
        var outputPath = Path.Combine(projectDir, GoogleServicesOutputPath);
        var outputDir  = Path.Combine(projectDir, GoogleServicesOutputDirectory);
        if (!Directory.Exists(outputDir))
        {
            try
            {
                Directory.CreateDirectory(outputDir);
            }
            catch (Exception ex)
            {
                Debug.LogException(ex);
                return;
            }
        }
        if (File.Exists(outputPath) &&
            File.GetLastWriteTime(outputPath).CompareTo(File.GetLastWriteTime(inputPath)) >= 0)
        {
            return;
        }
        var json               = File.ReadAllText(inputPath);
        var googleServices     = JsonUtility.FromJson <GoogleServices>(json);
        var resolvedClientInfo = googleServices.GetClient(bundleId);
        if (resolvedClientInfo == null)
        {
            Debug.LogWarning("Failed to find client_info in " + GoogleServicesInputFile + " matching package name: " + bundleId);
        }
        var valuesItems = new Dictionary <string, string> {
            { DefaultWebClientIdKey, googleServices.GetDefaultWebClientId(bundleId) },
            { FirebaseDatabaseUrlKey, googleServices.GetFirebaseDatabaseUrl() },
            { GATrackingIdKey, googleServices.GetGATrackingId(bundleId) },
            { GSMDefaultSenderIdKey, googleServices.GetDefaultGcmSenderId() },
            { GoogleAPIKey, googleServices.GetGoogleApiKey(bundleId) },
            { GoogleAppIdKey, googleServices.GetGoogleAppId(bundleId) },
            { CrashReportingApiKey, googleServices.GetCrashReportingApiKey(bundleId) },
            { GoogleStorageBucketKey, googleServices.GetStorageBucket(bundleId) },
            { ProjectIdKey, googleServices.GetProjectId() },
        };
        XmlResourceHelper.WriteXmlResource(outputPath, valuesItems);
        // Update editor project view.
        AssetDatabase.Refresh();
#endif
    }