![](/img/trans.png)
[英]how to get Firebase Analytics App Instance Id for Web App?
[英]Create a web app project that is linked to firebase analytics in C#
我創建了一個 web 應用程序,並希望在 C# 庫中使用 api 啟用分析。 我實現如下:
public static void CreateWebProject()
{
var body = new WebApp()
{
DisplayName = "mywebapp-fromapi5",
};
var operationWeb1 = _firebaseManagementService.Projects.WebApps.Create( body, "projects/" + CloudManager.ProjectId).Execute();
var analytics = new AddGoogleAnalyticsRequest {
AnalyticsAccountId = "248540946"
};
var operationWeb2 = _firebaseManagementService.Projects.AddGoogleAnalytics(analytics, "projects/" + CloudManager.ProjectId).Execute();
WaitOperation(operationWeb1, nameof(WebApp));
WaitOperation(operationWeb2, nameof(WebApp));
}
但是當我運行代碼時,出現以下錯誤:
Unhandled exception. The service firebase has thrown an exception.
HttpStatusCode is BadRequest.
Google.Apis.Requests.RequestError
Request contains an invalid argument. [400]
Errors [
Message[Request contains an invalid argument.] Location[ - ] Reason[badRequest] Domain[global]
]
Google.GoogleApiException: The service firebase has thrown an exception. HttpStatusCode is BadRequest. Request contains an invalid argument.
at Google.Apis.Requests.ClientServiceRequest`1.ParseResponse(HttpResponseMessage response)
at Google.Apis.Requests.ClientServiceRequest`1.Execute()
首次調用該方法時,它啟用了分析並為我使用的特定 firebase 項目鏈接了 Firebase 的默認帳戶。 但是,當我嘗試通過再次調用該方法來鏈接同一 Firebase 項目下新創建的 firebae 應用程序時,它引發了錯誤,因為它已為 firebase 項目/父項目啟用,而無需為其他項目啟用它如果它們在同一個 firebase. 項目下,則創建 firebase apps/child。
為了清楚起見,我正在嘗試使用 .NET 谷歌庫和 firebase 以編程方式設置谷歌雲項目、firebase 項目、firebase web 啟用分析的應用程序。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.