You can access the Firebase project from multiple Android apps, but, if my intent is to be able to access multiple projects within the same Android app?
For example, 3 projects hosted each on their own proprietary accounts and a common Android app that can access them all.
Thanks in advance for any answer!
You have to initialize multiple FirebaseApp instances yourself(this is done by google services plugin by reading google-services.json)
//This builder may call more functions depending on features being used
val secondProjectOptions = FirebaseOptions.Builder()
.setApplicationId("app id")
.setApiKey("api key")
.build()
FirebaseApp.initializeApp(this, secondProjectOptions, "secondProject")
//Use this app instance to access various features such as db
val secondProjectApp = FirebaseApp.getInstance("secondProject")
Related
You are my only hope solving this problem. I have 1 firebase project, and two android applications, one is for the users, and one is for the coaches. I store data in firebase firestore, and my plan is the coaches can upload trainings to firestore and that list appears on the users app, the users then can sign up for training etc etc...but with the second application connected to the firebase project, this error pops up in both applications:
java.lang.IllegalStateException: Default FirebaseApp is not initialized in this process [package name]. Make sure to call FirebaseApp.initializeApp(Context) first.
I have found some infos on internet that says I must use FirebaseOptions.Builder() to initialise one-one separate FirebaseApp instance in each android app, but I tried it and didnt work. This was the code for it:
private fun firebaseInit() {
val options = FirebaseOptions.Builder()
.setProjectId("qrtrainertruck-adminapp")
.setApplicationId("1:221722591872:android:b3964eb554e10b6251dc65")
.setApiKey("AIzaSyCfjNCD5kHb-LnB5FZXKPxi1t0lXJQASB4")
.build()
FirebaseApp.initializeApp(this, options, "adminapp")
}
Maybe just the api key is wrong, or I dont know...If this is the solution then where can I find these attributes (projectId, ApplicationId, ApiKey) for the function?
Thank you for all the help!
you can add multiple apps in one firebase project.
I have registered an app in the Azure AD portal and given Microsoft Graph API permissions to fetch user data (user.read.) and yammer feeds.
Note: the app is also registered with the yammer portal.
App auth is working fine if I have used a single scope but it fails in case of multiple scopes.
cases :
Working fine in single scope case
val SCOPES = arrayOf("https://graph.microsoft.com/.default")
Not Working in multiple scope case
val SCOPES = arrayOf("https://graph.microsoft.com/.default", "https://api.yammer.com/user_impersonation")
We are using Graph SDK in Android.
Thanks in Advance.
please suggest a way to achieve the solution.
You have set two scopes from different resources, which is not supported.
Because, finally you will get an Azure AD access token. However, the aud claim in the token can only represents one resource.
Conclusion:
You can add more than one scopes from one resource. For example: https://graph.microsoft.com/User.Read.All, https://graph.microsoft.com/Mail.ReadWrite and other scopes from Microsoft Graph.
If you want to get token for more than one resource, you need to get tokens for them separately.
I think we can add just user.read.all, mail.readwrite etc too without prefixing with entire graph URL, just that it needs to be comma separated.
We are starting to migrate from Google Analytics to Firebase Analytics as it is going to be deprecated in a year. We have a need of initializing the firebase project runtime in our iOS application and we are following the steps mentioned here: https://firebase.google.com/docs/projects/multiprojects?authuser=0
Why do we need to initialize the firebase manually and at runtime? The details are in this issue: Switching between different firebase projects (runtime) in one single APK file
I posted that issue when we encountered a similar problem for push notifications on Android because at that time the documentation was not sufficient. It is really good to know that firebase documentation has been updated to reflect how to manually initialize the sdk for various platforms.
Problem: The problem that we are facing today is that once we initialize the SDK manually for say a "secondary" application and we try to use the firebase analytics, it fails with following error:
2018-12-20 17:14:33.526757-0800 App Name[9218:675367] 5.2.0 - [Firebase/Analytics][I-ACS025018] Event not logged. Call +[FIRApp configure]: AppLaunch
Below is the sample piece of code:
FIROptions *firoptions = [[FIROptions alloc] initWithGoogleAppID:#"Actual_GoogleAppId" GCMSenderID:#"Actual_GCMSenderId"];
firoptions.bundleID = #"actual.bundle.id";
firoptions.APIKey = #"actual-api-key";
firoptions.clientID = #"actual.client.id";
firoptions.databaseURL = #"https://actual.url";
firoptions.storageBucket = #"actualapp.appspot.com";
[FIRApp configureWithName:#"testApp" options:firoptions];
if ([FIRApp appNamed:#"testApp"]) {
[FIRAnalytics logEventWithName:#"AppLaunch" parameters:nil];
}
Looking at the error it tells us to use [FIRApp configure] which configures the default application from the GoogleService-Info.plist in the project. But we do not have GoogleService-Info.plist in our project as suggested in https://firebase.google.com/docs/projects/multiprojects?authuser=0.
TL;DR: We are initializing the firebase app manually in our iOS application using the API [FIRApp configureWithName:#"testApp" options:firoptions]; and the Firebase Analytics gives an error asking us to use default [FIRApp configure] which defeats the purpose of manual initialization.
Any help is greatly appreciated.
Firebase Analytics requires the file to be named GoogleService-Info.plist. Note the first paragraph of https://firebase.google.com/docs/projects/multiprojects?authuser=0 recommends differentiating multiple versions of it by putting them in different directories.
More details about FirebaseAnalytics and multiple plist files at https://github.com/firebase/firebase-ios-sdk/issues/230
Is it possible to create new hosting projects by API, or another non-interactive method on Google Firebase?
I already tried Firebase tools with a token, but it says that it is only possible to create a new project on Firebase Console.
Some context:
My project allows users to create static websites online and we are searching for solutions to host these sites. Firebase would be a great solution, but only if I could integrate the user's new project into my system, with Firebase projects.
Updated (2018-11-07)
It is now possible to create with the Firebase Management API. Through this same API you can get a list of projects, add an app to an existing project, and list the apps in a project.
Hi!
public static void AddFirebase()
{
var request = new AddFirebaseRequest();
var operationFirebase1 = _firebaseManagementService.Projects.AddFirebase(request,
"projects/" + CloudManager.ProjectId).Execute();
WaitOperation(operationFirebase1, "Firebase");
}
My sample creating a new Firebase project by API:https://github.com/Denys2211/Firebase-cloud-messaging
How do apps update internally automatically without updating from playstore?
I mean the internal data of app is changed (via internet) without updating from playstore. For eg any Contest app, or Facebook app. Here the newsfeed is updated automatically.
What is the technical term for that?
Any tutorial on it?
If you would like to check if you app has updates (without interacting with Google Play), you'd have to poll a server (providing your current version) and let the server check if there is a newer version available. If that is the case, let the server respond with a changelog and an url to the newer version.
Luckily, there are libraries to do this:
AppUpdater. Android Library that checks for updates on your own server (or Google Play, Github, etc). Great documentation. This library notifies your apps' updates by showing a Material dialog, Snackbar or notification.
Android Auto Update. Chinese library, but should do the trick, one of the most popular libraries to do this, but this can be just because Google Play is not available in China.
AppUpdateChecker A simple non-Market way to keep your app updated.
All it requires to set up is a URL pointing to a JSON document describing your app's changes.
Auto Updater This project allows to automatically update a running APK application using a private update server (see apk-updater) instead of Google Play updater. Also comes with a server script.
SmartUpdates. Older library, but instructions in English and also provides a server script.
WVersionManager. Checks for updates, but actual update has to be downloaded from the Play Store.
Answer from Mdlc is about updating the app itself but not the content.
What initially asked is how to create an App with dynamic content such Facebook or any other newsfeed app.
Any kind of such apps has 2 parts:
Server
Client
Server stores the whole information you need and client make requests to that server and displays information.
Let's say server stores in DB one entry called News#1. Client requests list of news and get back array[News#1] as response and show one tile on screen. Then somebody creates new entry News#2. On next request to the server client will get array of 2 elements: array[News#1, News#2] and displays this dynamic content.
REST Api Client is what to start with.
https://github.com/bitstadium/HockeySDK-Android/blob/develop/hockeysdk/src/main/java/net/hockeyapp/android/tasks/DownloadFileTask.java#L194 has the perfect and still working implementation on opening a downloaded APK file...
private fun install(downloadedAPK: File, context: Context) {
val intent = Intent(Intent.ACTION_INSTALL_PACKAGE)
intent.setDataAndType(Uri.fromFile(downloadedAPK),
"application/vnd.android.package-archive")
intent.flags = Intent.FLAG_ACTIVITY_NEW_TASK
var oldVmPolicy: StrictMode.VmPolicy? = null
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
oldVmPolicy = StrictMode.getVmPolicy()
val policy = StrictMode.VmPolicy.Builder()
.penaltyLog()
.build()
StrictMode.setVmPolicy(policy)
}
context.startActivity(intent)
if (oldVmPolicy != null) {
StrictMode.setVmPolicy(oldVmPolicy)
}
}
Also have a look on AppCenter (Former HockeyApp) in-app updates https://learn.microsoft.com/en-us/appcenter/distribution/inappupdates
Here is the alternate
https://developer.android.com/guide/app-bundle/in-app-updates#update_readiness
try this google library to update from the application
dependencies {
implementation 'com.google.android.play:core:1.5.0'
...}
You can try this library: implementation 'com.github.vermat516:HelperLibrary:1.0.1'
This is best from my view we only have to write is:
new UniversalHelper(this).updateApp();
Rest of the work will automatically done by the library
This is response how your app will look like[This]