I have an application made in Flutter and supported by Firebase Firestore. When I created the app, I didn't care much about the app id (something.something.com), but now I need to change it. My question is, is ti possible to do this efficently, or the only way is to create a new project with a new id and copy paste everything to it?
You can follow this tutorial:
https://medium.com/#skyblazar.cc/how-to-change-the-package-name-of-your-flutter-app-4529e6e6e6fc
You also have to create a new app configuration in Firebase with your new package name.
Related
How can I set the sender id when requesting a registration token for Firebase messaging in Android?
I need this, because I have to have different FB projects for the apps and the server that is sending the notifications. It's described here, but I think the doc is missing something. Searching StackOverflow results in answers that are not up-to-date, also. Can't find the way to do it with the latest version of the API.
I suggest having a read on controlling your Firebase registration/instance it also explains not only how to manually initialise your own firebase with custom options/name but also how firebase initialises itself automatically using the Google plugin and json file which will help you better understand what solution may be best for you.
Essentially you need to manually initialise your Firebase service in your Android apps Application class and provide a FirebaseOptions.Builder class to the Firebase.initializeApp, which allows you to call setGcmSenderId among other things like api key etc.
This official link shows how to configure mutliple projects in your application which may be an option too.
I wanted to keep using the google-services.json, so I didn't want to do the manual init. Then when I read how the Google Services Gradle Plugin works, I was going to make the manual init by using the values from the file - more info here: https://developers.google.com/android/guides/google-services-plugin#processing_the_json_file
In the end, I ended up not changing anything in the code and just changing project_info/project_number in the google-services.json. It's used for gcm_defaultSenderId. Everything looks good, now. Hope it's not used for anything, else. We are using FCM, only, so I think it will be ok. I don't like this, but it will do.
the sender id and project details are set using configuration file "google-services.json",it reads this file from app folder of your android project.
to get google-services.json for your firebase project in firebase console, open project settings and select your app and download the file and place it inside app folder of your android project.
I have an app that sync data with my API.
I want this app have a dynamic "google-service.json", I want to pass the google-service.json after the app.APK is ready and the app is installed on the device through my API.
Is possible ?
I did a generic "google-service.json" that change the values when I send data from my API to the installed app on the device but the Firebase connection is not working.
Any ideas ?
What you're asking isn't possible. The values from google-services.json are read at build time and added to your APK. There's no way to go back and changes those values later.
If you want to initialize Firebase based on values that can only be known when the app is launched, then you should NOT apply the google-sevices plugin in build.gradle, and instead call FirebaseApp.initializeApp() manually and pass the correct values that you see in google-services.json.
Read:
https://firebase.googleblog.com/2017/03/take-control-of-your-firebase-init-on.html
https://developers.google.com/android/guides/google-services-plugin
I've been working on an app which displays a list of websites when click on it will be redirected to webview in the app itself, I'm unable to find a way how to update the links dynamically without updating the app. So, If I want users to interact with new links the new links should automatically be updated in the app without update and in the webview too. Is it possible to do that?
You should use firebase remote config feature, which best fits in your case.
Firebase Remote Config is a cloud service that lets you change the
behavior and appearance of your app without requiring users to
download an app update.
Well to do that you first need to create a project in firebase console
In remote config feature you can add data in key-value pair. Like in this image:
I have added two key-value pair, as can add as much as you want. Now in the app side you have to add dependency:
implementation ‘com.google.firebase:firebase-config:11.8.0’
And to fetch the values which you have added in firebase, you can easily get those url but first you need to follow some steps to do that. You can check this simple tutorial.
Note: To get the values from firebase remote config you must need to click on publish changes button(Which you can see in above image top right corner).
You can store that link to a server and return that link when the app hits a certain API of that server. But for doing that, you need to setup a server, build a server application if you haven't already. Which is a lot of work for just storing a website link.
Another option could be, you can use services like http://bit . ly and create a custom link from that service, like http://bit . ly/my_specific_domain and use this link in your app. When you need to point to a different website, you can just update where http://bit . ly/my_specific_domain redirects to.
But you best bet would be to use Firebase Remote Config, which is both reliable and easy to implement, but that is already described in previous answer.
I have developed my Android app using Firebase and I have developed an iOS app using Firebase. I created two different projects in Firebase, thinking I had to. Now, in order to get the two to talk to each other, I was told to put both in the same project.
I was referred to go to configuring multiple apps but after reading it, I am a bit confused. Any clarification would be greatly appreciated.
I want to connect my iOS project to the Android project I have.
I understand that I need to go the Overview and add another app and select IOS.
I am assuming once I do this, I get a new GoogleService-Info.plist file? And I am also assuming I replace the new plist file with the old, correct?
What I don't understand is the part below:
Use multiple projects in your application
Sometimes you need to access different projects using the same APIs - for example, accessing multiple database instances. In most cases there is a central Firebase application object that manages the configuration for all the Firebase APIs. This object is initialized as part of your normal setup. However, when you want to access multiple projects from a single application, you’ll need a distinct Firebase application object to reference each one individually. It’s up to you to initialize these other instances.
In both cases, you need to first create a Firebase options object to hold the configuration data for the Firebase application. Full documentation for the options can be found in the API reference documentation for the following classes:
The use of these classes to support multiple projects in an application is shown in the following examples:
iOS:
// Configure with manual options.
let secondaryOptions = FirebaseOptions(googleAppID: "1:27992087142:ios:2a4732a34787067a", gcmSenderID: "27992087142")
secondaryOptions.bundleID = "com.google.firebase.devrel.FiroptionConfiguration"
secondaryOptions.apiKey = "AIzaSyBicqfAZPvMgC7NZkjayUEsrepxuXzZDsk"
secondaryOptions.clientID = "27992087142-ola6qe637ulk8780vl8mo5vogegkm23n.apps.googleusercontent.com"
secondaryOptions.databaseURL = "https://myproject.firebaseio.com"
secondaryOptions.storageBucket = "myproject.appspot.com"
Android:
// Manually configure Firebase Options
FirebaseOptions options = new FirebaseOptions.Builder()
.setApplicationId("1:27992087142:android:ce3b6448250083d1") // Required for Analytics.
.setApiKey("AIzaSyADUe90ULnQDuGShD9W23RDP0xmeDc6Mvw") // Required for Auth.
.setDatabaseUrl("https://myproject.firebaseio.com") // Required for RTDB.
.build();
After you have initialized this options object, you can use it to configure an additional Firebase application instance. Note that in all the examples shown below we use the string secondary. This name is used to retrieve the application instance, and to distinguish it from other instances, including the default instance (named [DEFAULT]). You should pick a string appropriate to the intended use of the other Firebase project.
The following snippets demonstrate connecting to an alternative Realtime Database (the APIs for other Firebase features follow the same pattern).
iOS:
// Configure an alternative FIRApp.
FirebaseApp.configure(name: "secondary", options: secondaryOptions)
// Retrieve a previous created named app.
guard let secondary = FirebaseApp.app(name: "secondary")
else { assert(false, "Could not retrieve secondary app") }
// Retrieve a Real Time Database client configured against a specific app.
let secondaryDb = Database.database(app: secondary)
Android:
// Initialize with secondary app.
FirebaseApp.initializeApp(this /* Context */, options, "secondary");
// Retrieve secondary app.
FirebaseApp secondary = FirebaseApp.getInstance("secondary");
// Get the database for the other app.
FirebaseDatabase secondaryDatabase = FirebaseDatabase.getInstance(secondary);
I just don't know if I have to put the code in for both the Android and IOS project or just the IOS (where this is the one I will be adding to the Android project in Firebase).
The documentation page you're referring to describes how to connect a single app to multiple Firebase projects. Your scenario is the exact opposite: you have multiple apps that you want to connect to a single Firebase project.
To do this, you simply:
Create an Android app in your Firebase project, download the google-services.json, and add it to your Android project.
Create an iOS app in your Firebase project, download the google-services.plist, and add it to your iOS project.
So... ignore the documentation page you quoted, and instead just add an Android app, and an iOS app to the same project. They can then access the same back-end services.
I decided to change my app's package name and changed it using this tactic: https://stackoverflow.com/a/29092698/6144372 and then manually changed the package name defined in google-services.json file under this tag: "package_name": "com.xxx.xxx", but when I saw the package name in the Settings section of Firebase Console, it still shows the old one there.
So, I wanted to know that will it cause some bad effect on my app's performance in future or will it not do any harm? Please let me know
And if there is some way of changing the package name in Firebase Console settings too, let me know that too.
You should consider creating a new Firebase project. Just delete the old project and create a new one, with your new package name. I am not sure about the performance issues of just changing the old google-services.json file, but creating a new project is certainly more secure to prevent any future issues.
UPDATE: Thanks to TommieC.'s comment, a better way would be to add a new app to the project and just delete the old app. The new app will have your updated package name. Then download the google-services.json and replace it with the old file.
This method would be safer, in case your firebase project already has different integrations and deleting it is not really an option.
The problem arises when your firebase package name and application ID doesnot match. There is no any rename features in firebase project. You should create the new firebase project that matches the application Id and delete the old project. Then just import respective firebase project json to your code project. That should do the trick