简体   繁体   中英

How to check connection to Firebase servers from Admin SDK?

I am using Firebase Cloud Messaging to send push notifications to the users of my app. I have successfully set up and established the Firebase Admin SDK for .NET and I have written code that successfully sends the push notifications.

This is my code to create and authorize my server app for sending messages.

Dim Options As New AppOptions
Options.Credential = GoogleCredential.FromFile("./path/to/file.json")
FirebaseApp.Create(Options)

This is according to documentation as stated here: https://firebase.google.com/docs/cloud-messaging/auth-server

However when I run the above code Without an internet connection it does not tell me if the connection to Firebase servers has been established, or if there is any connection at all.

In my Admin code logic, I need to know if there is a connection to Firebase Servers and keep checking it multiple times so as to keep real time track of it. I went through the Admin SDK docs to find out if there is anything related but I found nothing.

Does anyone know how can I achieve this ? How can I know in my Admin code logic that Firebase connection is okay and i am ready to initialize the FirebaseApp and start sending messages.

If there is no official way of doing it, is there any way I can ping the Firebase servers for achieving the same ?

The code in your question doesn't create any connection to a server yet. It merely configures what credentials to use, and what project to connect to once it does.

Firebase is a set of 18 (and counting) products, and most of them have their own backend services. So how to detect if the connection is established varies from product to product.

When using the Firebase Admin SDK for .NET to send messaging through Firebase Cloud Messaging, the SDK communicates with the backend services through regular HTTPS calls. Each time you call one of the Send... methods, the SDK performs a HTTPS call on your behalf. The only way to find out whether there are connection problems is once you perform such a Send... call.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM