I am using Firestore and Redux. As such, I have a firestore_service.dart file that is the sole interface to Firestore and this same file updates the Redux store. For testing purposes I have created firestore_service_mock.dart along with a mock data file in the project test folder. My question is related to directory structuring and importing for testing purposes.
main.dart is the only file that imports firestore_service.dart. If I have firestore_service_mock.dart in the project test folder, then how do I import it into main.dart for integration testing? Not sure I am explaining myself clearly, so I hope this makes some sense.
With
import 'package:my_flutter_app/main.dart`;
lib/main.dart can be imported from everywhere inside your project (like with all files in lib/.
Related
The Firebase docs provide several ways to import SDK in service worker, which confused me. Here are the methods I discovered in the documentation:
https://firebase.google.com/docs/cloud-messaging/js/receive#web-version-9
import { initializeApp } from 'firebase/app';
import { getFirestore, collection, getDocs } from 'firebase/firestore/lite';
I can't utilize the method since I can't process my service worker because my project still uses webpack version 1. So I'm going to concentrate on the 'importScripts' techniques I discovered.
https://firebase.google.com/docs/cloud-messaging/js/receive#web-version-8
importScripts('https://www.gstatic.com/firebasejs/8.10.0/firebase-app.js');
importScripts('https://www.gstatic.com/firebasejs/8.10.0/firebase-messaging.js');
This is a working approach that I've tested; nevertheless, I have some questions about it:
Is it okay to use this gstatic domain in production?
This official SDK differs from the quickstart-js that they gave.
https://github.com/firebase/quickstart-js/blob/master/messaging/firebase-messaging-sw.js
importScripts('/__/firebase/9.2.0/firebase-app-compat.js');
importScripts('/__/firebase/9.2.0/firebase-messaging-compat.js');
importScripts('/__/firebase/init.js');
This is from the official example quickstart-js, however I still have a lot of questions about it:
It appears that they automatically updated the sample SDK, but the current version of Firebase is 9.6.1, not 9.2.0; should I remain with 9.2.0?
This approach only works in projects hosted by Firebase, and I can't find the init.js file matching to gstatic at the third line; is there a way to directly access that file?
Which approach should I utilize?
And I'm currently using Firebase 9.6.1 outside of my service worker; would utilizing Version 8 within my service worker cause any issues?
I think I'll stick to this:
importScripts('https://www.gstatic.com/firebasejs/9.6.1/firebase-app-compat.js')
importScripts(
'https://www.gstatic.com/firebasejs/9.6.1/firebase-messaging-compat.js'
)
I am new at Swift. I am creating my own framework that will use Firebase for in-app messages.
I tried to install Firebase through Cocoa pods, but it has issues: when I do that for my framework, then for sample project I have to install Firebase again. And then I get the numbers of warnings like this:
Class Firebase is implemented in both /private/var/containers/Bundle/Application/AD85D7EC-2652-4019-94FB-C799D0FBA69B/MyFrameworkExampleApp.app/Frameworks/MyFramework.framework/MyFramework (0x1019a0438) and /var/containers/Bundle/Application/AD85D7EC-2652-4019-94FB-C799D0FBA69B/MyFrameworkExampleApp.app/MyFrameworkExampleApp (0x10107c558). One of the two will be used. Which one is undefined.
my app crashes at runtime due to these warnings
So I don't want to use cocoa pods in Framework but need Firebase in my project.)
.
I follow the steps:
"https://firebase.google.com/docs/ios/setup#frameworks"
I just download the firebase file and import it into my project. after this I try to:
import Firebase
at the top of my swift class but the compiler is giving me an error.
No such module 'Firebase'
I am using Xcode 9. swift 4.
All of the framework files are in
"Targets > FrameworkName > General > Linked Frameworkd and Libraries".
also in the
"Targets > FrameworkName > Build Phases > Link Binary with Libraries".
I also followed this tutorial:
http://www.mokacoding.com/blog/setting-up-firebase-without-cocoapods/
but nothing happened.
Where am I wrong and What should I do?
Try adding following #import to framework's public header file "YourCocoaTouchFrameworkNameSwift.h"
#import <YourCocoaTouchFrameworkName/Firebase.h>
Check this link, if you need more information.
in firebase we have not a .framework file for import firebase. As we know that firebase is a combination of different frameworks, so we were unable to import firebase directly. thats why we
import required framework and dependent framework separately.
Dont try to import whole firebase.
I want to duplicate an existing app but run into errors when doing so. I am able to rename an app just fine (both in file structure and app configuration screen) but after renaming and importing same app again it throws error.
I have tried importing FAQ app, renaming it (successfully), exporting this renamed app, then re importing FAQ app again, and trying to import my custom exported app into the new FAQ app but due to existing uploaded content it fails?
What is the best practice to duplicate an existing app? Thx
This is a rare scenario and there's a feature request to do this, but ATM you'll have to do it manually. These are the "pain points":
folder where the app is
app GUID
Since this is a rare scenario, I would
quickly import the app into another portal
change the app-folder in the DNN file management
change the app-folder in the app-settings
export the app again - and make sure you check the box "reset GUID" as it will set the GUID to 00000-0000-... which will make the import generate a new guid for you
Hope this helps.
I would like to know how to import config sync files in my functional tests for modules I am testing. For instance, I have some custom content types I would like to test against, and there are a number of files in config/sync that pertain to the node modules that defines the custom content type.
class ArticleControllerTest extends BrowserTestBase {
protected static $modules = ['node', 'dist_source'];
}
At the top of my test I define the modules which do succesfully import, but it doesn't include the config sync settings so none of my custom content types are present. How can I import these into my test environment?
At the beginning of testing for Drupal 8, I had the same question. After reading some documents and tutorials, I tried and know several methods:
$this->configImporter() helps import the configurations from sync to active
$this->configImporter() exits in Drupal\Tests\ConfigTestTrait. And the trait has been used in some based test classes, like BrowserTestBase.
However, the method doesn't work for me. Because, I used thunder installation profile. The default content exists after the profile installation was completed. Once the $this->configImporter() starts to import sync configurations, it encounters errors that some entity types fail to be updated, because the entities already exists.
Create a testing profile
(Haven't tried)
If the Drupal site installed by standard profile, you may try to put the sync configurations into a testing profile. And Install Profile Generator module may helps you create the testing profile. There is a related issue #2788777 with config and profile
Put the configurations which depend on module into config/install or config/optional
(Work for me)
Contributed modules always put the config into config/install and config/optional. Once the module is installed, the configurations will also write into database or active storage. Documentation - Include default configuration in your Drupal 8 module
When developing configurations in module, Configuration development helps export the config into config/install of the developed module.
If anyone has the same experience, look forward to share with us.
I do it in my testing base class (extends BrowserTestBase) in setUp() like this:
// import config from sync
$config_path = '/home/rainer/src/asdent/config/sync';
$config_source = new FileStorage($config_path);
\Drupal::service('config.installer')->installOptionalConfig($config_source);
works great.
It's just like a drush cim sync
And provides the production config to my end-2-end automated phpunit tests in gitlab CI.
I would like to use Firebase analytics for one of my library modules. I would like to program in such a way that configuration file (google-services.json) should be accessible from either client app folder or configure the same from the client side.
Is there a way I could implement the above mentioned scenario?
Thanks in advance.
You can initialize your library project configurations manually as below,
For more info, kindly refer working-with-multiple-firebase-projects-in-an-android-app
Also go-through how-does-firebase-initialize-on-android to understand; how the Firebase module is getting initialized by itself.
For Android apps using Firebase, there is a central FirebaseApp object
that manages the configuration for all the Firebase APIs. This is
initialized automatically by a content provider when your app is
launched, and you typically never need to interact with it. However,
when you want to access multiple projects from a single app, you'll
need a distinct FirebaseApp to reference each one individually. It's
up to you to initialize the instances other than the default that
Firebase creates for you.
FirebaseOptions options = new FirebaseOptions.Builder()
.setApplicationId("1:530266078999:android:481c4ecf3253701e") // Required for Analytics.
.setApiKey("AIzaSyBRxOyIj5dJkKgAVPXRLYFkdZwh2Xxq51k") // Required for Auth.
.setDatabaseUrl("https://project-1765055333176374514.firebaseio.com/") // Required for RTDB.
.build();
FirebaseApp.initializeApp(this /* Context */, options, "secondary");
Hope I've answered your question.
I've found interesting workaround. Try the following:
put your google-services.json to any sample app google provides for Firebase integration. Compile it.
Take a look on path app/build/generated/res/google-services/debug/values/ there should be generated values.xml file with bunch of strings mentioned in errors you described. Copy these strings to value.xml file of your project. That's it.