How to add Admin SDK api to android project

2019-08-25 03:34发布

问题:

I am currently working in an Android application that requires to have Admin and regular users. To illustrate, the admin has the ability to manage the regular users like delete , modify their contents. According to my reserch that firebase provide Admin SDK API that can be realy sutiable for this issue but according to thier documention that Admin SDK cannot be used in the Android project itself and should be placed in the server-side of the project. In addition, i was tried to add the Admin SDK debendence to my project dependences but there is conflict between the libraries . I know what i was did is wrong to add the Admin SDK to the Bulid.gradle (app) but i did not manage to figure out how i can add the Admin SDK to my project.

回答1:

What you've found is correct. Your case seems to be suitable for using Firebase Admin SDK.

Firebase Admin SDK needs a server app, on which it will be initialized.

Here you can find a full list of the prerequisites for setting-up Firebase Android SDK.

You can set-up Firebase Functions, which will hold your server-side code. Inside those functions you can also initialize the Firebase Admin SDK.

Please refer here for more information on Firebase Functions.

Here you can find a sample Firebase application which uses the Admin SDK. The sample shows how to authenticate access to a JSON API to only allow access to data for a specific Firebase user.

Firebase Functions are built to serve as serverless code, as you develop your server-side logic, then deploy it to a managed environment on Google's cloud. Those functions can contain all the logic that you would like to have using Admin SDK.