Create multiple environment with same bundle id using firebase iOS swift? - ios

We are working on fabric for a crash report. We have four environments debug, dev, prod, and staging. So based on the environment we have created the organization in fabric setting and get API key. So that we can able to use API key for different environments with the same bundle id.
For Fabric i have followed this link : Fabric Crashlytics multiple environments for iOS app
But now we have to move the fabric to firebase. We have created the project for my one environment. But I want to create multiple environments with same bundle id in firebase. Can anyone give me an idea?
Ref link : In this link they have created the dev and production for different bundle id. https://medium.com/bam-tech/setup-firebase-on-ios-android-with-multiple-environments-ad4e7ef35607

In Firebase, you can use multiple projects to support different environments.
The Firebase Console will not prevent you from creating multiple projects having apps with the same bundle id (there is some subtlety when doing this on Android around SHA1 keys but it doesn't apply to iOS).
It is up to you if you want to use the same bundle id or not:
Use the same bundle id if you are okay with overwriting the prod app when testing on devices
Use a different bundle id (e.g. append ".staging" or ".test") if you want to test side-by-side
Be mindful that you will have to manage different GoogleService-Info.plist files since you are using two different Firebase projects, and be extra careful when deploying to App Store - you do not want to publish an app that points to your staging or test environments!
Additional reading: https://firebase.google.com/docs/projects/multiprojects

Related

Firebase dynamic link not opening correct app when multiple flavors are installed on iOS

We developed a flutter app for Android and iOS, with different flavors: dev, test and prod, so we have 6 apps in total. To on-board the user, we send a firebase dynamic link via Email (with a deep link inside it) to navigate the user to a specific screen when it is tapped.
The expected behavior is that when the user taps on a dynamic link of - say - the dev app, it opens a screen in the dev app. Similar for the other flavors.
Now this works just fine on Android.
On iOS it works fine if only one app is installed, but if for example the dev and the test apps are installed, then tapping on the dynamic links always opens the test app. This is also true when dev, test and prod are installed: test is opened.
This is a development issue and not relevant for production as the user will never have the test or dev app installed, but it is annoying us as we have to uninstall and reinstall flavors all the time.
Our dynamic links have the following format (values in '<>' are placeholders):
Dev: https://<app_id>.page.link/?link=http://dev.<mydomain>.com/reset?token=token1&apn=<mypackage>.dev&isi=<isiNumber1>&ibi=<mypackage>.dev
Test: https://<app_id>.page.link/?link=http://test.<mydomain>.com/reset?token=token2&apn=<mypackage>.test&isi=<isiNumber2>&ibi=<mypackage>.test
Prod: https://<app_id>.page.link/?link=http://<mydomain>.com/reset?token=token3&apn=<mypackage>&isi=<isiNumber3>&ibi=<mypackage>
The behavior is the same for all iOS versions I could get my hands on on real devices, i.e. iOS 11, 12 and 13.
We're using Flutter 1.9.1-hotfix6 and firebase_dynamic_links 0.5.0+1
Any ideas what this might be caused by?
Firebase Dynamic Links do not support using the same URL prefix for multiple iOS apps/targets contained in the same Firebase project.
You can workaround this in multiple ways though:
Using multiple (sub)domains (as already suggested by Janmenjaya)
Use a custom domain
Using multiple Firebase projects (as already suggested by Aleksandr)
On Android it works out of the box, because you are in charge of matching paths with particular apps within the Manifest file. On iOS it doesn't work, because Firebase is in charge of such matches within the hosted apple-app-site-association file.
For further information, I've written an extensive answer here.
Do not use one project in the firebase console, it is better to split and use different url in <key>com.apple.developer.associated-domains</key>
In Firebase under dynamic link, we can create multiple url domain. And these url domain we need to add in the associated domain of different target.
Steps
Let’s assume I have two target test and production.
I created two domain link like “test.page.link” and production.page.link
In test target in Xcode under Signing & Capabilities -> Associated Domain, use the “test.page.link”
And for production target set the production.page.link

Firebase Analytics events on iOS - test and production

The iOS app I am working on uses Firebase Analytics to report events. It works as expected, but the app is not in production yet. Once it is it would be preferable to have the events logged by real users separate from these logged when debugging.
What is the best way to have Firebase Analytics events logged separately for test and production?
First you will probably want to create a separate Firebase project for staging/debug.
Then you will have to configure your app to be able to use different resources based on build type. For Android we solved this using build flavors, not sure what the iOS equivalent is.
From docs (https://firebase.google.com/docs/projects/multiprojects):
By default, FirebaseApp.configure() will load the GoogleService-Info.plist file bundled with the application. If your development and production environments are configured as separate targets in XCode, you can:
Download both GoogleService-Info.plist files
Store the two files in different directories
Add both to your XCode project
Associate the
different files with the different targets using the Target
Membership panel.
If the builds are part of a single target, the best option is to give both configuration files unique names (e.g. GoogleService-Info-Free.plist and GoogleService-Info-Paid.plist). Then choose at runtime which plist to load.

Using Firebase Dynamic Links for dev bundle id on iOS

For my iOS app, the dev project has a different bundle id than the prod app.
Because the dev app isn't published, and therefore has no Store ID, the Dynamic Links SDK returns an error:
Your project does not own Dynamic Links domain
Is there any way to use test the Firebase Dynamic Links SDK with my dev bundle ID?
You have to enable the Dynamic Link first through Firebase Console for you to create Dynamic Links programmatically. See this link for more info.

Setup Facebook for both Xcode configurations

I have a successfully released app with some Facebook integration like login, share etc. After release I need to have two separate apps: the first one works with production server and another one works with testing server. I made four Xcode configurations: debug for testing, release for testing, debug for prod and release for prod. In Build Settings I change their bundle ids and everything works great. Except Facebook login.
I have created another FB app with new FBAppID, new Bundle ID. In Run Script I set the correct FBAppID in Info.plist depending on testing or production environment. But logInWithReadPermissions:fromViewController:handler: returns an error:
remote_app_id does not match stored id.
What do I do wrong? Is it possible to make facebook work in both configurations?

Deploy two seperate iOS apps via PhoneGap with the same certificate/provisioning file

We'd like to deploy two apps onto our iPad, using the same code base and configuration. The only difference being one points to our test environment, and the other to our production environment.
I'm using the build.phonegap.com service (this may or may not be relevant), and so far I've tried to change the Name and Id (i.e. com.company.app) in the config.xml file, but everything I deploy and download, the app overwrites itself. As mentioned above, we want two apps at the same time on the device, pointing to different environments.
I have a hunch that I may need to use a different certificate for each app (so that it is built with a different bundle id i.e. com.company.app)
Any thoughts?
You definitely need to build each app with a different BundleID if you want them to show up as separate apps on the device. However, you can use the same certificate/profile as long as you set up the profile to contain both BundleIDs, or some wildcard that will match both BundleIDs.

Resources