代码之家  ›  专栏  ›  技术社区  ›  Emil

用户或应用程序的firebase rest api设置语言?

  •  2
  • Emil  · 技术社区  · 8 年前

    firebase可以选择为当前用户设置语言代码或应用程序语言,以便获得验证,密码重置电子邮件的定义语言如下。下面是来自 Android SDK 实施

    此外,您还可以通过更新 发送电子邮件前验证实例上的语言代码。为了 例子:

    auth.setLanguagecode(“fr”);//应用默认的应用程序语言 而不是显式地设置它。//auth.useAppLanguage();

    但是我在我的uwp应用程序中使用rest api,这个选项没有在restapi中定义 documentation

    有人知道怎么做到这一点吗?

    1 回复  |  直到 8 年前
        1
  •  0
  •   Emil    8 年前

    其他人都在寻找解决办法。您需要将header添加为x-firebase-locale:'fr'。C代码如下所示。您可以找到完整的实现 here

    public async Task SendEmailVerificationAsync(string firebaseToken, string locale = null)
    {
        var content = $"{{\"requestType\":\"VERIFY_EMAIL\",\"idToken\":\"{firebaseToken}\"}}";
    
        var StringContent = new StringContent(content, Encoding.UTF8, "application/json");
        if (locale != null)
            StringContent.Headers.Add("X-Firebase-Locale", locale);
    
        var response = await this.client.PostAsync(new Uri(string.Format(GoogleGetConfirmationCodeUrl, this.authConfig.ApiKey)), StringContent).ConfigureAwait(false);
    
        response.EnsureSuccessStatusCode();
    }
    
    推荐文章