How to set up Firebase with PhoneGap? - firebase

I'm trying to build an application with three text fields for a name, email, and contact. When the form is submitted, the data should be saved to Firebase.
I've followed the following steps to set up the environment:
I created an account on Firebase.
I set up a new project over there.
I provided the package name of my personal project (which is created by using command prompt by entering the command 'phonegap create TestProject com.testproject.app')
Then, I selected 'Add Firebase to your Android App' on the website, and downloaded the google-services.json file.
I have pasted that file in the root folder of my project.
Now, according to the cordova-plugin-firebase docs, I should enter a command in the command prompt to add the Firebase plugin to my project, but it returns an error.
As an alternative, I've also tried to add the plugin to the config.xml file manually (as mentioned on the website above). But still, it's not working.
I have also followed this YouTube tutorial. but I'm still stuck at the same stage.
Can anyone please help me to fix this issue?

Related

how to implement ios & android google login in capacitor?

I am using capacitor-firebase-auth to set up my app. Already follow below guide line to setup, but the result still return
"CapacitorFirebaseAuth" plugin is not implemented on ios
URL: undefined
is anyone know what is problem?
Add custom URL schemes to your Xcode project:
Open your project configuration: double-click the project name in the left tree view. Select your app from the TARGETS section, then select the Info tab, and expand the URL Types section.
Click the + button, and add a URL scheme for your reversed client ID. To find this value, open the GoogleService-Info.plist configuration file, and look for the REVERSED_CLIENT_ID key. Copy the value of that key, and paste it into the URL Schemes box on the configuration page. Leave the other fields blank.
You need to add the URL that is requested in the info.plist file of your project, you will find this in the main target of your app [1]: https://i.stack.imgur.com/PLLgf.png
Btw, you will probably also need to add GoogleService-Info.plist to your project as well if you haven't already, you can find this in the project settings of your firebase panel (cog icon top left on firebase dashboard) and setup the SDK for iOS etc.
If you don't know your reversed-client ID, follow the instructions above to get the GoogleService-Info.plist, it is located in that file. Firebase will also give you instructions as to how to configure your project.

How can I prevent somebody who has my google-services.json from accessing my project?

I would like to know how can I prevent somebody who has my google-services.json file associated with one of my Firebase Firestore projects from accessing my project.
you don't need to create a new google-service.json after you make any changes to console,
it will be automatically created,
you just need to download it from
settings -> Project settings -> select your package/bundle-id -> click the download icon
I don't there's a way to you can change those credentials for the same project. Even if you delete that app and recreate it in Firebase project, it'll change the mobilesdk_app_id only. Creating a new project maybe the only way to get a completely new google-services.json
I'm not sure which SSH keys you are referring to but if you are just re-configuring your application then you can visit https://console.firebase.google.com/project/_/settings/general and then select the app name you are looking for. You'll have an option to download google-services.json there. The rest of configuration process should remain the same.

my NativeScript app dosent display the google maps

here is my code :
https://github.com/jonny720/do-here-client/tree/master/do-here
i took the map component code from here :
https://github.com/dapriett/nativescript-google-maps-sdk/tree/master/ng-demo/app/map
the map component should display the google maps but nothing is shown.
*i installed google maps sdk, and setup the api key in the android platform.
its the first time i'm working with api in my app.
can someone light my eyes and tell me what is the problem?
The api key is missing and you should register custom element in main.ts file, and the 2 files to copy from the nativescript-google-map module were missing from your app folder
and as well as the key too.
I forked your repo and update the app, also created a .gitignore file to exclude unnecessary files and folder from repo.
I tested and it works fine.
You will have to update these files with your appropriate Google API key
> do-here/app/main.ts
> do-here/app/App_Resources/Android/values/nativescript_google_maps_api.xml
> do-here/app/App_Resources/Android/src/main/res/values/nativescript_google_maps_api.xml
and update this file to redirect all unauthorized access back to login page, changed it to test the map page
do-here/app/#shared/services/auth-guard.service.ts
ok first thank you a lot KielSoft
i solved it by typing in the cli :
tns tun android --clean

How do I host on Firebase?

I want to host a website in Firebase. I followed the instruction Firebase gave me and there is an instruction says: Add your static files to your deploy directory (the default is public). I don't know what it means, so I just entered the code under this instruction, which is: firebase deploy, and the command prompt responded with: Error: Cannot understand what targets to deploy. Check that you specified valid targets if you used the --only or --except flag. Otherwise, check your firebase.json to ensure that your project is initialized for the desired features. Do I need to create a static file? I don't really know what to do next. The link to the instruction is here: https://console.firebase.google.com/project/example-website/hosting , you need to sign into Google in order to access it.
Try initializing your project with the CLI as explained here: https://firebase.google.com/docs/cli/
As mentioned there "The init command steps you through setting up your project directory, including asking which Firebase features you want to use." With the features correctly declared you will be able to run firebase deploy without any error
The error you are getting because JSON file is missing. which mean you have not correctly initialize firebase project. Follow these steps to do it correctly:
After installing firebase, from your console enter 'firebase login' and login with your gmail account.
Now enter 'firebase init' and select hosting option by using
Space key and press enter and also select your project.(don't forget to press space tab on correct option) It will ask about public folder, just press enter.
Then will ask if your app is single page app. Press Y or N
and enter.
Now you will get a public folder, inside will be a
index.html file. Open it and do some changes if you want. Now from
console enter 'firebase deploy'
It's time to connect your domain, if you have any. Under hosting, now you will see new option 'Connect Domain'. Click on it and follow the instructions. I have connected my domain parimeo same way to firebase. If you don't want to connect any domain then firebase will also provide you a link to your web app.

How do I remove a hosted site from firebase

I have a hosted site on firebase which I am not using anymore. I still want to keep the project but want to remove the hosted site. Is there any way to do this or do I just need to upload an empty directory. Doesn't seem to be an option in the UI
It can be deleted.
Run firebase hosting:disable through the firebase-tools CLI first.
Go to Firebase Console and select Hosting from the menu of the left.
You will see the deployed project with a list of your historical actions like Deployed, disabled, etc.
Only after you have disabled the site, the "three vertical dots" menu will be available for you to choose the action to delete the deployment.
If you have multiple site hosted in same project, then use -s flag to specify the site you want to disable.
firebase hosting:disable -s yoursitename
You don't need to upload empty directory.
Just open your project's root directory and enter the following command
firebase hosting:disable
CLI Response :
$ firebase hosting:disable
? Are you sure you want to disable Firebase Hosting for the site xyz
This will immediately make your site inaccessible! Yes
✔ Hosting has been disabled for xyz. Deploy a new version
to re-enable.
This will instantly disable running website also adds a Disabled status in release history. Tested on firebase CLI version 9.20.0
It's a bit hidden, but here are the steps:
Go to the Firebase Hosting console for your project, you will see your domain.
Hover over your domain. There's an overflow menu (⋮ three vertical dots) on the right.
From the overflow menu select Delete Domain
[Update]
For multiple site hosted !! use command
firebase hosting:disable --project yoursitename
for me it work!! Can your try?
You can use the following command:
firebase hosting:disable -s <firebase_project_name>
replace <firebase_project_name> with the name of your firebase project. This allows you to unsubscribe from the current project and place it in disable mode and you cannot receive traffic from the published web page. When you want to re-enable it, you can do it from the visual platform. I leave an image attached so that you can be guided.
Manually
You can easily go to the console, and click on the 3 vertical dots and delete the site.
Using CLI
Disable only
Stops serving Firebase Hosting traffic for the active Firebase
project.
Your project's Hosting URL will display a "Site Not Found" message
after running this command.
If you want to disable, as the other answers are saying use this command:
firebase hosting:disable
If you're using multi-sites, you have to specify the project name:
firebase hosting:disable --project yoursitename
Delete forever
Deletes the specified Hosting site.
Deleting a site is a permanent action. If you delete a site, Firebase doesn't maintain records of deployed files or deployment history, and the site cannot be reactivated by you or anyone else.
(Optional) Skip the confirmation prompt by passing the following flags: -f or --force
To delete this site (similar to when you go to the console > delete manually) run this command:
firebase hosting:sites:delete yoursitename -f
Be careful when using the -f, but if you're running this as a script command, it might be required.
I spent too much time on this and hopefully this can be helpful. I did deploy my stuff using firebase deploy however I was not able to see in on the firebase console. When I tried firebase hosting:disable I got this Error: HTTP Error: 400, Invalid project ID specified.
The steps below helped me delete my project.
To find the project, you have to get the output of firebase
deploy which will have a console url that looks like this:
Project Console:
https://console.firebase.google.com/project/<your-project-id>/overview.
Follow this link and go to project settings. You should be able to
delete your project in there.
I had to spend several hours removing the default website on Firebase hosting.
The way that I found was :
Enter "firebase init database" in Terminal. It initialize all websites including the default one so that you can set up a new one.
I hope it helps you.
As of now there is no proper way to bulk delete all the previous deployments in a project.
However the best thing you can do is to empty the firebase hosting folder and then deploy it using firebase deploy
This option has been given as a feature request to firebase. Lets hope its get implemented soon :)
1.Sign in to Firebase, then open your project.
2.Click the Settings icon near project Overview button, then select Project settings.
3.In the Your apps card, select the app that you want to delete.
4.Find the Delete Project button from bottom of the page , click Delete Project.
5.Check the points , then click Remove app permanently.

Resources