Firebase Analytics events on iOS - test and production - ios

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.

Related

Flutter. Applying a different configuration for Testflight and the App Store

The task is to use different API URLs inside the Flutter application for the app installed through the Testflight and for the app installed through the App Store.
Libraries like: store_checker and detect_testflight
do not give 100% results, and I cannot be sure that they will not stop correctly detecting the installation source after the next update.
I also cannot rely on the kReleaseMode constant, since there is no way to create a build that compiled in debug mode and uploads it on a Testflight. This can only be done in release mode.
Using custom configuration files and setting up the .gitattributes file also seems like a perversion, and is not suitable because, besides the local repositories of many developers, bitbucket is used, in which I cannot add my merge driver. Also, there is no guarantee that other developers will use this driver.
Tell me a simple and concise way to implement this? Didn't Apple come up with the idea that developers would need to use different settings for builds in Testflight and in App Store?

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

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

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

How to use fabric when having multiple target in project

I have an iOS project with 2 targets, I am trying to integrate fabric to the project. After following through their documentation I was able to implement crashlytics for first target and I am able to see the crash log in the dashboard also. Everything is working fine.
In the second target I used same API key and script which was used for first target then I tested the second app, in the dashboard I am able to see two different app reports.
Is it the right way to do it. I mean to use same API key for multiple targets.
Hope you understand the problem.
Mike from Fabric here.
API keys are set per organization within Fabric, so multiple apps or targets within the same Fabric organization would use the same key.

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