diff --git a/packages/cloud_firestore/cloud_firestore/example/ios/Flutter/AppFrameworkInfo.plist b/packages/cloud_firestore/cloud_firestore/example/ios/Flutter/AppFrameworkInfo.plist index 6c2de8086bcd..3a9c234f96d4 100755 --- a/packages/cloud_firestore/cloud_firestore/example/ios/Flutter/AppFrameworkInfo.plist +++ b/packages/cloud_firestore/cloud_firestore/example/ios/Flutter/AppFrameworkInfo.plist @@ -25,6 +25,6 @@ arm64 MinimumOSVersion - 8.0 + 9.0 diff --git a/packages/cloud_firestore/cloud_firestore/example/lib/firebase_config.dart b/packages/cloud_firestore/cloud_firestore/example/lib/firebase_config.dart new file mode 100644 index 000000000000..9a7e23a5538f --- /dev/null +++ b/packages/cloud_firestore/cloud_firestore/example/lib/firebase_config.dart @@ -0,0 +1,45 @@ +import 'dart:io'; + +import 'package:firebase_core/firebase_core.dart'; +import 'package:flutter/foundation.dart'; + +class DefaultFirebaseConfig { + static FirebaseOptions get platformOptions { + if (kIsWeb) { + // Web + return const FirebaseOptions( + apiKey: 'AIzaSyAgUhHU8wSJgO5MVNy95tMT07NEjzMOfz0', + authDomain: 'react-native-firebase-testing.firebaseapp.com', + databaseURL: 'https://react-native-firebase-testing.firebaseio.com', + projectId: 'react-native-firebase-testing', + storageBucket: 'react-native-firebase-testing.appspot.com', + messagingSenderId: '448618578101', + appId: '1:448618578101:web:772d484dc9eb15e9ac3efc', + measurementId: 'G-0N1G9FLDZE', + ); + } else if (Platform.isIOS || Platform.isMacOS) { + // iOS and MacOS + return const FirebaseOptions( + appId: '1:448618578101:ios:2bc5c1fe2ec336f8ac3efc', + apiKey: 'AIzaSyAHAsf51D0A407EklG1bs-5wA7EbyfNFg0', + projectId: 'react-native-firebase-testing', + messagingSenderId: '448618578101', + iosBundleId: 'io.flutter.plugins.firebase.firestore.example', + iosClientId: + '448618578101-ja1be10uicsa2dvss16gh4hkqks0vq61.apps.googleusercontent.com', + androidClientId: + '448618578101-2baveavh8bvs2famsa5r8t77fe1nrcn6.apps.googleusercontent.com', + storageBucket: 'react-native-firebase-testing.appspot.com', + databaseURL: 'https://react-native-firebase-testing.firebaseio.com', + ); + } else { + // Android + return const FirebaseOptions( + appId: '1:448618578101:android:3ad281c0067ccf97ac3efc', + apiKey: 'AIzaSyCuu4tbv9CwwTudNOweMNstzZHIDBhgJxA', + projectId: 'react-native-firebase-testing', + messagingSenderId: '448618578101', + ); + } + } +} diff --git a/packages/cloud_firestore/cloud_firestore/example/lib/main.dart b/packages/cloud_firestore/cloud_firestore/example/lib/main.dart index c02eb81764d5..961e076f69b9 100755 --- a/packages/cloud_firestore/cloud_firestore/example/lib/main.dart +++ b/packages/cloud_firestore/cloud_firestore/example/lib/main.dart @@ -2,6 +2,7 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. +import 'package:cloud_firestore_example/firebase_config.dart'; import 'package:cloud_firestore_example/movie.dart'; import 'package:flutter/material.dart'; import 'package:firebase_core/firebase_core.dart'; @@ -13,14 +14,7 @@ bool USE_FIRESTORE_EMULATOR = false; Future main() async { WidgetsFlutterBinding.ensureInitialized(); - await Firebase.initializeApp( - options: const FirebaseOptions( - apiKey: 'AIzaSyAHAsf51D0A407EklG1bs-5wA7EbyfNFg0', - appId: '1:448618578101:ios:2bc5c1fe2ec336f8ac3efc', - messagingSenderId: '448618578101', - projectId: 'react-native-firebase-testing', - ), - ); + await Firebase.initializeApp(options: DefaultFirebaseConfig.platformOptions); if (USE_FIRESTORE_EMULATOR) { FirebaseFirestore.instance.useFirestoreEmulator('localhost', 8080); @@ -218,9 +212,7 @@ class _MovieItem extends StatelessWidget { Widget get poster { return SizedBox( width: 100, - child: Center( - child: Image.network(movie.poster), - ), + child: Image.network(movie.poster), ); } @@ -255,7 +247,8 @@ class _MovieItem extends StatelessWidget { Widget get metadata { return Padding( padding: const EdgeInsets.only(top: 8), - child: Row( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, children: [ Padding( padding: const EdgeInsets.only(right: 8), @@ -299,6 +292,7 @@ class _MovieItem extends StatelessWidget { return Padding( padding: const EdgeInsets.only(bottom: 4, top: 4), child: Row( + crossAxisAlignment: CrossAxisAlignment.start, children: [ poster, Flexible(child: details), diff --git a/packages/cloud_firestore/cloud_firestore/example/macos/Runner.xcodeproj/project.pbxproj b/packages/cloud_firestore/cloud_firestore/example/macos/Runner.xcodeproj/project.pbxproj index f7409e7def98..c879768f04fa 100644 --- a/packages/cloud_firestore/cloud_firestore/example/macos/Runner.xcodeproj/project.pbxproj +++ b/packages/cloud_firestore/cloud_firestore/example/macos/Runner.xcodeproj/project.pbxproj @@ -26,12 +26,8 @@ 33CC10F32044A3C60003C045 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 33CC10F22044A3C60003C045 /* Assets.xcassets */; }; 33CC10F62044A3C60003C045 /* MainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = 33CC10F42044A3C60003C045 /* MainMenu.xib */; }; 33CC11132044BFA00003C045 /* MainFlutterWindow.swift in Sources */ = {isa = PBXBuildFile; fileRef = 33CC11122044BFA00003C045 /* MainFlutterWindow.swift */; }; - 33D1A10422148B71006C7A3E /* FlutterMacOS.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 33D1A10322148B71006C7A3E /* FlutterMacOS.framework */; }; - 33D1A10522148B93006C7A3E /* FlutterMacOS.framework in Bundle Framework */ = {isa = PBXBuildFile; fileRef = 33D1A10322148B71006C7A3E /* FlutterMacOS.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; B550B1FA23F53055007DADD5 /* GoogleService-Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = B550B1F923F53055007DADD5 /* GoogleService-Info.plist */; }; CF00B2C1BAC6C45C8CEC0ABB /* Pods_Runner.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 20AC44AD05DF01F5CE774C68 /* Pods_Runner.framework */; }; - D73912F022F37F9E000D13A0 /* App.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D73912EF22F37F9E000D13A0 /* App.framework */; }; - D73912F222F3801D000D13A0 /* App.framework in Bundle Framework */ = {isa = PBXBuildFile; fileRef = D73912EF22F37F9E000D13A0 /* App.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -51,8 +47,6 @@ dstPath = ""; dstSubfolderSpec = 10; files = ( - D73912F222F3801D000D13A0 /* App.framework in Bundle Framework */, - 33D1A10522148B93006C7A3E /* FlutterMacOS.framework in Bundle Framework */, ); name = "Bundle Framework"; runOnlyForDeploymentPostprocessing = 0; @@ -72,7 +66,6 @@ 33CEB47222A05771004F2AC0 /* Flutter-Debug.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = "Flutter-Debug.xcconfig"; sourceTree = ""; }; 33CEB47422A05771004F2AC0 /* Flutter-Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = "Flutter-Release.xcconfig"; sourceTree = ""; }; 33CEB47722A0578A004F2AC0 /* Flutter-Generated.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = "Flutter-Generated.xcconfig"; path = "ephemeral/Flutter-Generated.xcconfig"; sourceTree = ""; }; - 33D1A10322148B71006C7A3E /* FlutterMacOS.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = FlutterMacOS.framework; path = Flutter/ephemeral/FlutterMacOS.framework; sourceTree = SOURCE_ROOT; }; 33E51913231747F40026EE4D /* DebugProfile.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = DebugProfile.entitlements; sourceTree = ""; }; 33E51914231749380026EE4D /* Release.entitlements */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.entitlements; path = Release.entitlements; sourceTree = ""; }; 33E5194F232828860026EE4D /* AppInfo.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = AppInfo.xcconfig; sourceTree = ""; }; @@ -81,7 +74,6 @@ 9740EEB21CF90195004384FC /* Debug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = Debug.xcconfig; sourceTree = ""; }; B550B1F923F53055007DADD5 /* GoogleService-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "GoogleService-Info.plist"; sourceTree = ""; }; BFF2C4019A4A6B2204D78167 /* Pods-Runner.profile.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.profile.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.profile.xcconfig"; sourceTree = ""; }; - D73912EF22F37F9E000D13A0 /* App.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = App.framework; path = Flutter/ephemeral/App.framework; sourceTree = SOURCE_ROOT; }; F84572E2CE6BA0CFCE7EC16B /* Pods-Runner.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.release.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"; sourceTree = ""; }; /* End PBXFileReference section */ @@ -90,8 +82,6 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( - D73912F022F37F9E000D13A0 /* App.framework in Frameworks */, - 33D1A10422148B71006C7A3E /* FlutterMacOS.framework in Frameworks */, CF00B2C1BAC6C45C8CEC0ABB /* Pods_Runner.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; @@ -147,8 +137,6 @@ 33CEB47222A05771004F2AC0 /* Flutter-Debug.xcconfig */, 33CEB47422A05771004F2AC0 /* Flutter-Release.xcconfig */, 33CEB47722A0578A004F2AC0 /* Flutter-Generated.xcconfig */, - D73912EF22F37F9E000D13A0 /* App.framework */, - 33D1A10322148B71006C7A3E /* FlutterMacOS.framework */, ); path = Flutter; sourceTree = ""; @@ -199,6 +187,7 @@ 33CC110E2044A8840003C045 /* Bundle Framework */, 3399D490228B24CF009A79C7 /* ShellScript */, 975391D0C03E32306137DE4C /* [CP] Embed Pods Frameworks */, + BAB8F2C5684814BE2193F3E5 /* [CP] Copy Pods Resources */, ); buildRules = ( ); @@ -306,7 +295,7 @@ ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "echo \"$PRODUCT_NAME.app\" > \"$PROJECT_DIR\"/Flutter/ephemeral/.app_filename\n"; + shellScript = "echo \"$PRODUCT_NAME.app\" > \"$PROJECT_DIR\"/Flutter/ephemeral/.app_filename && \"$FLUTTER_ROOT\"/packages/flutter_tools/bin/macos_assemble.sh embed\n"; }; 33CC111E2044C6BF0003C045 /* ShellScript */ = { isa = PBXShellScriptBuildPhase; @@ -333,16 +322,31 @@ buildActionMask = 2147483647; files = ( ); - inputFileListPaths = ( + inputPaths = ( ); name = "[CP] Embed Pods Frameworks"; - outputFileListPaths = ( + outputPaths = ( ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh\"\n"; showEnvVarsInLog = 0; }; + BAB8F2C5684814BE2193F3E5 /* [CP] Copy Pods Resources */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + ); + name = "[CP] Copy Pods Resources"; + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-resources.sh\"\n"; + showEnvVarsInLog = 0; + }; /* End PBXShellScriptBuildPhase section */ /* Begin PBXSourcesBuildPhase section */ diff --git a/packages/cloud_firestore/cloud_firestore/example/pubspec.yaml b/packages/cloud_firestore/cloud_firestore/example/pubspec.yaml index fb2f069ccf84..4d4c8072f202 100755 --- a/packages/cloud_firestore/cloud_firestore/example/pubspec.yaml +++ b/packages/cloud_firestore/cloud_firestore/example/pubspec.yaml @@ -2,8 +2,8 @@ name: cloud_firestore_example description: Demonstrates how to use the firestore plugin. environment: - sdk: ">=2.12.0 <3.0.0" - flutter: ">=1.12.13+hotfix.4" + sdk: '>=2.12.0 <3.0.0' + flutter: '>=1.12.13+hotfix.4' dependencies: cloud_firestore: @@ -27,7 +27,7 @@ dependency_overrides: path: ../../../firebase_core/firebase_core_web dev_dependencies: - drive: ^0.1.0 + drive: ^1.0.0-1.0.nullsafety.1 flutter_driver: sdk: flutter test: any diff --git a/packages/cloud_firestore/cloud_firestore/example/test_driver/cloud_firestore_e2e.dart b/packages/cloud_firestore/cloud_firestore/example/test_driver/cloud_firestore_e2e.dart index d1c6070b07a1..b5681b533452 100644 --- a/packages/cloud_firestore/cloud_firestore/example/test_driver/cloud_firestore_e2e.dart +++ b/packages/cloud_firestore/cloud_firestore/example/test_driver/cloud_firestore_e2e.dart @@ -1,4 +1,3 @@ -// @dart=2.9 // Copyright 2020, the Chromium project authors. Please see the AUTHORS file // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. @@ -12,6 +11,7 @@ import 'collection_reference_e2e.dart'; import 'document_change_e2e.dart'; import 'document_reference_e2e.dart'; import 'field_value_e2e.dart'; +import 'firebase_config.dart'; import 'geo_point_e2e.dart'; import 'instance_e2e.dart'; import 'query_e2e.dart'; @@ -25,7 +25,7 @@ bool kUseFirestoreEmulator = true; void testsMain() { setUpAll(() async { - await Firebase.initializeApp(); + await Firebase.initializeApp(options: TestFirebaseConfig.platformOptions); if (kUseFirestoreEmulator) { FirebaseFirestore.instance.useFirestoreEmulator('localhost', 8080); diff --git a/packages/cloud_firestore/cloud_firestore/example/test_driver/cloud_firestore_e2e_test.dart b/packages/cloud_firestore/cloud_firestore/example/test_driver/cloud_firestore_e2e_test.dart index d44896e41f7c..f9c0fa99a519 100644 --- a/packages/cloud_firestore/cloud_firestore/example/test_driver/cloud_firestore_e2e_test.dart +++ b/packages/cloud_firestore/cloud_firestore/example/test_driver/cloud_firestore_e2e_test.dart @@ -1,4 +1,3 @@ -// @dart=2.9 // Copyright 2020, the Chromium project authors. Please see the AUTHORS file // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. diff --git a/packages/cloud_firestore/cloud_firestore/example/test_driver/field_value_e2e.dart b/packages/cloud_firestore/cloud_firestore/example/test_driver/field_value_e2e.dart index 598f6506dad1..596b133294a2 100644 --- a/packages/cloud_firestore/cloud_firestore/example/test_driver/field_value_e2e.dart +++ b/packages/cloud_firestore/cloud_firestore/example/test_driver/field_value_e2e.dart @@ -2,8 +2,6 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. -// @dart=2.9 - import 'dart:async'; import 'package:flutter_test/flutter_test.dart'; @@ -11,7 +9,7 @@ import 'package:cloud_firestore/cloud_firestore.dart'; void runFieldValueTests() { group('$FieldValue', () { - FirebaseFirestore /*?*/ firestore; + late FirebaseFirestore firestore; setUpAll(() async { firestore = FirebaseFirestore.instance; @@ -32,7 +30,7 @@ void runFieldValueTests() { await doc.set({'foo': 2}); await doc.update({'foo': FieldValue.increment(1)}); DocumentSnapshot> snapshot = await doc.get(); - expect(snapshot.data()['foo'], equals(3)); + expect(snapshot.data()!['foo'], equals(3)); }); test('decrements a number', () async { @@ -41,7 +39,7 @@ void runFieldValueTests() { await doc.set({'foo': 2}); await doc.update({'foo': FieldValue.increment(-1)}); DocumentSnapshot> snapshot = await doc.get(); - expect(snapshot.data()['foo'], equals(1)); + expect(snapshot.data()!['foo'], equals(1)); }); test('sets an increment if it does not exist', () async { @@ -51,7 +49,7 @@ void runFieldValueTests() { expect(snapshot.exists, isFalse); await doc.set({'foo': FieldValue.increment(1)}); DocumentSnapshot> snapshot2 = await doc.get(); - expect(snapshot2.data()['foo'], equals(1)); + expect(snapshot2.data()!['foo'], equals(1)); }); }); @@ -61,7 +59,7 @@ void runFieldValueTests() { await initializeTest('field-value-server-timestamp-new'); await doc.set({'foo': FieldValue.serverTimestamp()}); DocumentSnapshot> snapshot = await doc.get(); - expect(snapshot.data()['foo'], isA()); + expect(snapshot.data()!['foo'], isA()); }); test('updates a server time value', () async { @@ -69,12 +67,12 @@ void runFieldValueTests() { await initializeTest('field-value-server-timestamp-update'); await doc.set({'foo': FieldValue.serverTimestamp()}); DocumentSnapshot> snapshot = await doc.get(); - Timestamp serverTime1 = snapshot.data()['foo']; + Timestamp serverTime1 = snapshot.data()!['foo']; expect(serverTime1, isA()); await Future.delayed(const Duration(milliseconds: 100)); await doc.update({'foo': FieldValue.serverTimestamp()}); DocumentSnapshot> snapshot2 = await doc.get(); - Timestamp serverTime2 = snapshot2.data()['foo']; + Timestamp serverTime2 = snapshot2.data()!['foo']; expect(serverTime2, isA()); expect( serverTime2.microsecondsSinceEpoch > @@ -106,7 +104,7 @@ void runFieldValueTests() { 'foo': FieldValue.arrayUnion([3, 4]) }); DocumentSnapshot> snapshot = await doc.get(); - expect(snapshot.data()['foo'], equals([1, 2, 3, 4])); + expect(snapshot.data()!['foo'], equals([1, 2, 3, 4])); }); test('updates an array if current value is not an array', () async { @@ -117,7 +115,7 @@ void runFieldValueTests() { 'foo': FieldValue.arrayUnion([3, 4]) }); DocumentSnapshot> snapshot = await doc.get(); - expect(snapshot.data()['foo'], equals([3, 4])); + expect(snapshot.data()!['foo'], equals([3, 4])); }); test('sets an array if current value is not an array', () async { @@ -128,7 +126,7 @@ void runFieldValueTests() { 'foo': FieldValue.arrayUnion([3, 4]) }); DocumentSnapshot> snapshot = await doc.get(); - expect(snapshot.data()['foo'], equals([3, 4])); + expect(snapshot.data()!['foo'], equals([3, 4])); }); }); @@ -143,7 +141,7 @@ void runFieldValueTests() { 'foo': FieldValue.arrayRemove([3, 4]) }); DocumentSnapshot> snapshot = await doc.get(); - expect(snapshot.data()['foo'], equals([1, 2])); + expect(snapshot.data()!['foo'], equals([1, 2])); }); test('removes & updates an array if existing item is not an array', @@ -155,7 +153,7 @@ void runFieldValueTests() { 'foo': FieldValue.arrayUnion([3, 4]) }); DocumentSnapshot> snapshot = await doc.get(); - expect(snapshot.data()['foo'], equals([3, 4])); + expect(snapshot.data()!['foo'], equals([3, 4])); }); test('removes & sets an array if existing item is not an array', @@ -167,7 +165,7 @@ void runFieldValueTests() { 'foo': FieldValue.arrayUnion([3, 4]) }); DocumentSnapshot> snapshot = await doc.get(); - expect(snapshot.data()['foo'], equals([3, 4])); + expect(snapshot.data()!['foo'], equals([3, 4])); }); // ignore: todo @@ -188,7 +186,7 @@ void runFieldValueTests() { 'foo': FieldValue.arrayUnion([2, ref]) }); DocumentSnapshot> snapshot = await doc.get(); - expect(snapshot.data()['foo'], equals([1, 2, ref])); + expect(snapshot.data()!['foo'], equals([1, 2, ref])); }, skip: true, ); diff --git a/packages/cloud_firestore/cloud_firestore/example/test_driver/firebase_config.dart b/packages/cloud_firestore/cloud_firestore/example/test_driver/firebase_config.dart new file mode 100644 index 000000000000..30fc4537ac75 --- /dev/null +++ b/packages/cloud_firestore/cloud_firestore/example/test_driver/firebase_config.dart @@ -0,0 +1,45 @@ +import 'dart:io'; + +import 'package:firebase_core/firebase_core.dart'; +import 'package:flutter/foundation.dart'; + +class TestFirebaseConfig { + static FirebaseOptions get platformOptions { + if (kIsWeb) { + // Web + return const FirebaseOptions( + apiKey: 'AIzaSyAgUhHU8wSJgO5MVNy95tMT07NEjzMOfz0', + authDomain: 'react-native-firebase-testing.firebaseapp.com', + databaseURL: 'https://react-native-firebase-testing.firebaseio.com', + projectId: 'react-native-firebase-testing', + storageBucket: 'react-native-firebase-testing.appspot.com', + messagingSenderId: '448618578101', + appId: '1:448618578101:web:772d484dc9eb15e9ac3efc', + measurementId: 'G-0N1G9FLDZE', + ); + } else if (Platform.isIOS || Platform.isMacOS) { + // iOS and MacOS + return const FirebaseOptions( + appId: '1:448618578101:ios:2bc5c1fe2ec336f8ac3efc', + apiKey: 'AIzaSyAHAsf51D0A407EklG1bs-5wA7EbyfNFg0', + projectId: 'react-native-firebase-testing', + messagingSenderId: '448618578101', + iosBundleId: 'io.flutter.plugins.firebase.firestore.example', + iosClientId: + '448618578101-ja1be10uicsa2dvss16gh4hkqks0vq61.apps.googleusercontent.com', + androidClientId: + '448618578101-2baveavh8bvs2famsa5r8t77fe1nrcn6.apps.googleusercontent.com', + storageBucket: 'react-native-firebase-testing.appspot.com', + databaseURL: 'https://react-native-firebase-testing.firebaseio.com', + ); + } else { + // Android + return const FirebaseOptions( + appId: '1:448618578101:android:3ad281c0067ccf97ac3efc', + apiKey: 'AIzaSyCuu4tbv9CwwTudNOweMNstzZHIDBhgJxA', + projectId: 'react-native-firebase-testing', + messagingSenderId: '448618578101', + ); + } + } +} diff --git a/packages/cloud_firestore/cloud_firestore/example/test_driver/geo_point_e2e.dart b/packages/cloud_firestore/cloud_firestore/example/test_driver/geo_point_e2e.dart index 38ab597f5d71..ef668c49fa14 100644 --- a/packages/cloud_firestore/cloud_firestore/example/test_driver/geo_point_e2e.dart +++ b/packages/cloud_firestore/cloud_firestore/example/test_driver/geo_point_e2e.dart @@ -2,8 +2,6 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. -// @dart=2.9 - import 'dart:async'; import 'package:flutter_test/flutter_test.dart'; @@ -11,7 +9,7 @@ import 'package:cloud_firestore/cloud_firestore.dart'; void runGeoPointTests() { group('$GeoPoint', () { - FirebaseFirestore /*?*/ firestore; + late FirebaseFirestore /*?*/ firestore; setUpAll(() async { firestore = FirebaseFirestore.instance; @@ -33,7 +31,7 @@ void runGeoPointTests() { DocumentSnapshot> snapshot = await doc.get(); - GeoPoint geopoint = snapshot.data()['foo']; + GeoPoint geopoint = snapshot.data()!['foo']; expect(geopoint, isA()); expect(geopoint.latitude, equals(10)); expect(geopoint.longitude, equals(-10)); @@ -49,7 +47,7 @@ void runGeoPointTests() { DocumentSnapshot> snapshot = await doc.get(); - GeoPoint geopoint = snapshot.data()['foo']; + GeoPoint geopoint = snapshot.data()!['foo']; expect(geopoint, isA()); expect(geopoint.latitude, equals(-10)); expect(geopoint.longitude, equals(10)); diff --git a/packages/cloud_firestore/cloud_firestore/example/test_driver/instance_e2e.dart b/packages/cloud_firestore/cloud_firestore/example/test_driver/instance_e2e.dart index be592164302a..c995feefb955 100644 --- a/packages/cloud_firestore/cloud_firestore/example/test_driver/instance_e2e.dart +++ b/packages/cloud_firestore/cloud_firestore/example/test_driver/instance_e2e.dart @@ -2,8 +2,6 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. -// @dart=2.9 - import 'dart:async'; import 'package:flutter/foundation.dart'; @@ -14,7 +12,7 @@ void runInstanceTests() { group( '$FirebaseFirestore.instance', () { - FirebaseFirestore /*?*/ firestore; + late FirebaseFirestore /*?*/ firestore; setUpAll(() async { firestore = FirebaseFirestore.instance; @@ -107,7 +105,7 @@ void runInstanceTests() { DocumentSnapshot> documentSnapshot = await documentReference.get(); expect(documentSnapshot.metadata.isFromCache, isTrue); - expect(documentSnapshot.data()['foo'], equals('bar')); + expect(documentSnapshot.data()!['foo'], equals('bar')); // Go back online once test complete await firestore.enableNetwork(); @@ -132,7 +130,7 @@ void runInstanceTests() { } on FirebaseException catch (e) { expect(e.code, equals('failed-precondition')); } catch (e) { - fail(e); + fail('$e'); } await firestore.terminate(); diff --git a/packages/cloud_firestore/cloud_firestore/example/test_driver/snapshot_metadata_e2e.dart b/packages/cloud_firestore/cloud_firestore/example/test_driver/snapshot_metadata_e2e.dart index 2692abb98389..dc718927c0be 100644 --- a/packages/cloud_firestore/cloud_firestore/example/test_driver/snapshot_metadata_e2e.dart +++ b/packages/cloud_firestore/cloud_firestore/example/test_driver/snapshot_metadata_e2e.dart @@ -2,8 +2,6 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. -// @dart=2.9 - import 'dart:async'; import 'package:flutter/foundation.dart'; @@ -14,7 +12,7 @@ void runSnapshotMetadataTests() { group( '$SnapshotMetadata', () { - FirebaseFirestore /*?*/ firestore; + late FirebaseFirestore /*?*/ firestore; setUpAll(() async { firestore = FirebaseFirestore.instance; diff --git a/packages/cloud_firestore/cloud_firestore/example/test_driver/timestamp_e2e.dart b/packages/cloud_firestore/cloud_firestore/example/test_driver/timestamp_e2e.dart index 7357454030b6..ffd46d51d0dd 100644 --- a/packages/cloud_firestore/cloud_firestore/example/test_driver/timestamp_e2e.dart +++ b/packages/cloud_firestore/cloud_firestore/example/test_driver/timestamp_e2e.dart @@ -2,8 +2,6 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. -// @dart=2.9 - import 'dart:async'; import 'package:flutter_test/flutter_test.dart'; @@ -11,7 +9,7 @@ import 'package:cloud_firestore/cloud_firestore.dart'; void runTimestampTests() { group('$Timestamp', () { - FirebaseFirestore /*?*/ firestore; + late FirebaseFirestore /*?*/ firestore; setUpAll(() async { firestore = FirebaseFirestore.instance; @@ -33,7 +31,7 @@ void runTimestampTests() { await doc.set({'foo': Timestamp.fromDate(date)}); DocumentSnapshot> snapshot = await doc.get(); - Timestamp timestamp = snapshot.data()['foo']; + Timestamp timestamp = snapshot.data()!['foo']; expect(timestamp, isA()); expect( timestamp.millisecondsSinceEpoch, @@ -50,7 +48,7 @@ void runTimestampTests() { await doc.update({'foo': date}); DocumentSnapshot> snapshot = await doc.get(); - Timestamp timestamp = snapshot.data()['foo']; + Timestamp timestamp = snapshot.data()!['foo']; expect(timestamp, isA()); expect( timestamp.millisecondsSinceEpoch, diff --git a/packages/cloud_functions/cloud_functions/example/lib/firebase_config.dart b/packages/cloud_functions/cloud_functions/example/lib/firebase_config.dart new file mode 100644 index 000000000000..32fb2e9349a6 --- /dev/null +++ b/packages/cloud_functions/cloud_functions/example/lib/firebase_config.dart @@ -0,0 +1,46 @@ +import 'dart:io'; + +import 'package:firebase_core/firebase_core.dart'; +import 'package:flutter/foundation.dart'; + +class DefaultFirebaseConfig { + static FirebaseOptions get platformOptions { + if (kIsWeb) { + // Web + return const FirebaseOptions( + apiKey: 'AIzaSyAgUhHU8wSJgO5MVNy95tMT07NEjzMOfz0', + authDomain: 'react-native-firebase-testing.firebaseapp.com', + databaseURL: 'https://react-native-firebase-testing.firebaseio.com', + projectId: 'react-native-firebase-testing', + storageBucket: 'react-native-firebase-testing.appspot.com', + messagingSenderId: '448618578101', + appId: '1:448618578101:web:0b650370bb29e29cac3efc', + measurementId: 'G-F79DJ0VFGS', + ); + } else if (Platform.isIOS || Platform.isMacOS) { + // iOS and MacOS + return const FirebaseOptions( + appId: '1:448618578101:ios:f7208957983eeee4ac3efc', + apiKey: 'AIzaSyAHAsf51D0A407EklG1bs-5wA7EbyfNFg0', + projectId: 'react-native-firebase-testing', + messagingSenderId: '448618578101', + iosBundleId: 'io.flutter.plugins.firebase.functions.example', + iosClientId: + '48618578101-lc3q11v4dv28hef68s6skqju3k2gjd3j.apps.googleusercontent.com', + androidClientId: + '448618578101-vh59lklbaigpccaugknk3j0g1pp81kr2.apps.googleusercontent.com', + databaseURL: 'https://react-native-firebase-testing.firebaseio.com', + storageBucket: 'react-native-firebase-testing.appspot.com', + ); + } else { + // Android + return const FirebaseOptions( + // App ID of FF Core Example + appId: '1:448618578101:android:0446912d5f1476b6ac3efc', + apiKey: 'AIzaSyCuu4tbv9CwwTudNOweMNstzZHIDBhgJxA', + projectId: 'react-native-firebase-testing', + messagingSenderId: '448618578101', + ); + } + } +} diff --git a/packages/cloud_functions/cloud_functions/example/lib/main.dart b/packages/cloud_functions/cloud_functions/example/lib/main.dart index 80b02b0b28fd..d68443f8dca2 100644 --- a/packages/cloud_functions/cloud_functions/example/lib/main.dart +++ b/packages/cloud_functions/cloud_functions/example/lib/main.dart @@ -1,32 +1,29 @@ -// ignore_for_file: require_trailing_commas // Copyright 2019 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// @dart=2.9 - import 'dart:async'; import 'dart:core'; import 'package:cloud_functions/cloud_functions.dart'; +import 'package:cloud_functions_example/firebase_config.dart'; import 'package:firebase_core/firebase_core.dart'; import 'package:flutter/material.dart'; Future main() async { WidgetsFlutterBinding.ensureInitialized(); - await Firebase.initializeApp( - options: const FirebaseOptions( - apiKey: 'AIzaSyAHAsf51D0A407EklG1bs-5wA7EbyfNFg0', - appId: '1:448618578101:ios:2bc5c1fe2ec336f8ac3efc', - messagingSenderId: '448618578101', - projectId: 'react-native-firebase-testing', - )); + + await Firebase.initializeApp(options: DefaultFirebaseConfig.platformOptions); + + // You should have the Functions Emulator running locally to use it + // https://firebase.google.com/docs/functions/local-emulator FirebaseFunctions.instance.useFunctionsEmulator('localhost', 5001); + runApp(MyApp()); } class MyApp extends StatefulWidget { - MyApp({Key key}) : super(key: key); + MyApp({Key? key}) : super(key: key); @override _MyAppState createState() => _MyAppState(); } @@ -34,11 +31,6 @@ class MyApp extends StatefulWidget { class _MyAppState extends State { List fruit = []; - @override - void initState() { - super.initState(); - } - @override Widget build(BuildContext context) { return MaterialApp( @@ -47,35 +39,42 @@ class _MyAppState extends State { title: const Text('Firebase Functions Example'), ), body: Center( - child: ListView.builder( - itemCount: fruit.length, - itemBuilder: (context, index) { - return ListTile( - title: Text('${fruit[index]}'), - ); - })), + child: ListView.builder( + itemCount: fruit.length, + itemBuilder: (context, index) { + return ListTile( + title: Text('${fruit[index]}'), + ); + }, + ), + ), floatingActionButton: Builder( builder: (context) => FloatingActionButton.extended( onPressed: () async { - // See index.js in the functions folder for the example function we + // See index.js in .github/workflows/scripts for the example function we // are using for this example HttpsCallable callable = FirebaseFunctions.instance.httpsCallable( - 'listFruit', - options: HttpsCallableOptions( - timeout: const Duration(seconds: 5))); + 'listFruit', + options: HttpsCallableOptions( + timeout: const Duration(seconds: 5), + ), + ); - await callable().then((v) { + try { + final result = await callable(); setState(() { fruit.clear(); - v.data.forEach((f) { + result.data.forEach((f) { fruit.add(f); }); }); - }).catchError((e) { - ScaffoldMessenger.of(context).showSnackBar(SnackBar( - content: Text('ERROR: $e'), - )); - }); + } catch (e) { + ScaffoldMessenger.of(context).showSnackBar( + SnackBar( + content: Text('ERROR: $e'), + ), + ); + } }, label: const Text('Call Function'), icon: const Icon(Icons.cloud), diff --git a/packages/cloud_functions/cloud_functions/example/macos/Runner.xcodeproj/project.pbxproj b/packages/cloud_functions/cloud_functions/example/macos/Runner.xcodeproj/project.pbxproj index 538a2f310beb..3b3fd35fe04b 100644 --- a/packages/cloud_functions/cloud_functions/example/macos/Runner.xcodeproj/project.pbxproj +++ b/packages/cloud_functions/cloud_functions/example/macos/Runner.xcodeproj/project.pbxproj @@ -26,11 +26,7 @@ 33CC10F32044A3C60003C045 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 33CC10F22044A3C60003C045 /* Assets.xcassets */; }; 33CC10F62044A3C60003C045 /* MainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = 33CC10F42044A3C60003C045 /* MainMenu.xib */; }; 33CC11132044BFA00003C045 /* MainFlutterWindow.swift in Sources */ = {isa = PBXBuildFile; fileRef = 33CC11122044BFA00003C045 /* MainFlutterWindow.swift */; }; - 33D1A10422148B71006C7A3E /* FlutterMacOS.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 33D1A10322148B71006C7A3E /* FlutterMacOS.framework */; }; - 33D1A10522148B93006C7A3E /* FlutterMacOS.framework in Bundle Framework */ = {isa = PBXBuildFile; fileRef = 33D1A10322148B71006C7A3E /* FlutterMacOS.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; B550B1FE23F53792007DADD5 /* GoogleService-Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = B550B1FD23F53792007DADD5 /* GoogleService-Info.plist */; }; - D73912F022F37F9E000D13A0 /* App.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D73912EF22F37F9E000D13A0 /* App.framework */; }; - D73912F222F3801D000D13A0 /* App.framework in Bundle Framework */ = {isa = PBXBuildFile; fileRef = D73912EF22F37F9E000D13A0 /* App.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; E1A3C0FEB219DE3059F49DD9 /* Pods_Runner.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 2EDA759B4F18DE63DF0790FB /* Pods_Runner.framework */; }; /* End PBXBuildFile section */ @@ -51,8 +47,6 @@ dstPath = ""; dstSubfolderSpec = 10; files = ( - D73912F222F3801D000D13A0 /* App.framework in Bundle Framework */, - 33D1A10522148B93006C7A3E /* FlutterMacOS.framework in Bundle Framework */, ); name = "Bundle Framework"; runOnlyForDeploymentPostprocessing = 0; @@ -72,7 +66,6 @@ 33CEB47222A05771004F2AC0 /* Flutter-Debug.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = "Flutter-Debug.xcconfig"; sourceTree = ""; }; 33CEB47422A05771004F2AC0 /* Flutter-Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = "Flutter-Release.xcconfig"; sourceTree = ""; }; 33CEB47722A0578A004F2AC0 /* Flutter-Generated.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = "Flutter-Generated.xcconfig"; path = "ephemeral/Flutter-Generated.xcconfig"; sourceTree = ""; }; - 33D1A10322148B71006C7A3E /* FlutterMacOS.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = FlutterMacOS.framework; path = Flutter/ephemeral/FlutterMacOS.framework; sourceTree = SOURCE_ROOT; }; 33E51913231747F40026EE4D /* DebugProfile.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = DebugProfile.entitlements; sourceTree = ""; }; 33E51914231749380026EE4D /* Release.entitlements */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.entitlements; path = Release.entitlements; sourceTree = ""; }; 33E5194F232828860026EE4D /* AppInfo.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = AppInfo.xcconfig; sourceTree = ""; }; @@ -82,7 +75,6 @@ B51643519054BD100F273F38 /* Pods-Runner.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.release.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"; sourceTree = ""; }; B550B1FD23F53792007DADD5 /* GoogleService-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "GoogleService-Info.plist"; sourceTree = ""; }; D71BFD332DFDD49FEC2851C7 /* Pods-Runner.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.debug.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"; sourceTree = ""; }; - D73912EF22F37F9E000D13A0 /* App.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = App.framework; path = Flutter/ephemeral/App.framework; sourceTree = SOURCE_ROOT; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -90,8 +82,6 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( - D73912F022F37F9E000D13A0 /* App.framework in Frameworks */, - 33D1A10422148B71006C7A3E /* FlutterMacOS.framework in Frameworks */, E1A3C0FEB219DE3059F49DD9 /* Pods_Runner.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; @@ -157,8 +147,6 @@ 33CEB47222A05771004F2AC0 /* Flutter-Debug.xcconfig */, 33CEB47422A05771004F2AC0 /* Flutter-Release.xcconfig */, 33CEB47722A0578A004F2AC0 /* Flutter-Generated.xcconfig */, - D73912EF22F37F9E000D13A0 /* App.framework */, - 33D1A10322148B71006C7A3E /* FlutterMacOS.framework */, ); path = Flutter; sourceTree = ""; @@ -284,7 +272,7 @@ ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "echo \"$PRODUCT_NAME.app\" > \"$PROJECT_DIR\"/Flutter/ephemeral/.app_filename\n"; + shellScript = "echo \"$PRODUCT_NAME.app\" > \"$PROJECT_DIR\"/Flutter/ephemeral/.app_filename && \"$FLUTTER_ROOT\"/packages/flutter_tools/bin/macos_assemble.sh embed\n"; }; 33CC111E2044C6BF0003C045 /* ShellScript */ = { isa = PBXShellScriptBuildPhase; @@ -311,10 +299,10 @@ buildActionMask = 2147483647; files = ( ); - inputFileListPaths = ( + inputPaths = ( ); name = "[CP] Embed Pods Frameworks"; - outputFileListPaths = ( + outputPaths = ( ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; diff --git a/packages/cloud_functions/cloud_functions/example/pubspec.yaml b/packages/cloud_functions/cloud_functions/example/pubspec.yaml index fa2c58c804e4..22a1ea7dd717 100644 --- a/packages/cloud_functions/cloud_functions/example/pubspec.yaml +++ b/packages/cloud_functions/cloud_functions/example/pubspec.yaml @@ -2,8 +2,8 @@ name: cloud_functions_example description: Demonstrates how to use the cloud_functions plugin. environment: - sdk: ">=2.12.0 <3.0.0" - flutter: ">=1.12.13+hotfix.4" + sdk: '>=2.12.0 <3.0.0' + flutter: '>=1.12.13+hotfix.4' dependencies: cloud_functions: @@ -27,7 +27,7 @@ dependency_overrides: path: ../../../firebase_core/firebase_core_web dev_dependencies: - drive: 0.1.0 + drive: ^1.0.0-1.0.nullsafety.1 flutter_driver: sdk: flutter test: any diff --git a/packages/cloud_functions/cloud_functions/example/test_driver/cloud_functions_e2e.dart b/packages/cloud_functions/cloud_functions/example/test_driver/cloud_functions_e2e.dart index 878a9c2e1cf6..c62d60c6c01c 100644 --- a/packages/cloud_functions/cloud_functions/example/test_driver/cloud_functions_e2e.dart +++ b/packages/cloud_functions/cloud_functions/example/test_driver/cloud_functions_e2e.dart @@ -1,17 +1,13 @@ -// ignore_for_file: require_trailing_commas -// @dart = 2.9 - // Copyright 2020, the Chromium project authors. Please see the AUTHORS file // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. -// @dart=2.9 - import 'package:cloud_functions/cloud_functions.dart'; import 'package:drive/drive.dart' as drive; import 'package:firebase_core/firebase_core.dart'; import 'package:flutter_test/flutter_test.dart'; +import 'firebase_config.dart'; import 'sample.dart' as data; String kTestFunctionDefaultRegion = 'testFunctionDefaultRegion'; @@ -20,9 +16,10 @@ String kTestFunctionTimeout = 'testFunctionTimeout'; String kTestMapConvertType = 'testMapConvertType'; void testsMain() { - HttpsCallable callable; + late HttpsCallable callable; + setUpAll(() async { - await Firebase.initializeApp(); + await Firebase.initializeApp(options: TestFirebaseConfig.platformOptions); FirebaseFunctions.instance.useFunctionsEmulator('localhost', 5001); callable = FirebaseFunctions.instance.httpsCallable(kTestFunctionDefaultRegion); @@ -85,15 +82,16 @@ void testsMain() { }); test( - '[HttpsCallableResult.data] should return Map type for returned objects', - () async { - HttpsCallable callable = - FirebaseFunctions.instance.httpsCallable(kTestMapConvertType); + '[HttpsCallableResult.data] should return Map type for returned objects', + () async { + HttpsCallable callable = + FirebaseFunctions.instance.httpsCallable(kTestMapConvertType); - var result = await callable(); + var result = await callable(); - expect(result.data, isA>()); - }); + expect(result.data, isA>()); + }, + ); }); group('FirebaseFunctionsException', () { @@ -107,7 +105,7 @@ void testsMain() { expect(e.message, equals('Invalid test requested.')); return; } catch (e) { - fail(e); + fail('$e'); } }); @@ -122,18 +120,21 @@ void testsMain() { } on FirebaseFunctionsException catch (e) { expect(e.code, equals('cancelled')); expect( - e.message, - equals( - 'Response data was requested to be sent as part of an Error payload, so here we are!')); + e.message, + equals( + 'Response data was requested to be sent as part of an Error payload, so here we are!', + ), + ); expect(e.details, equals(data.deepMap)); } catch (e) { - fail(e); + fail('$e'); } }); }); group('region', () { - HttpsCallable customRegionCallable; + late HttpsCallable customRegionCallable; + setUpAll(() async { customRegionCallable = FirebaseFunctions.instanceFor(region: 'europe-west1') @@ -147,12 +148,13 @@ void testsMain() { }); group('HttpsCallableOptions', () { - HttpsCallable timeoutCallable; + late HttpsCallable timeoutCallable; setUpAll(() async { timeoutCallable = FirebaseFunctions.instance.httpsCallable( - kTestFunctionTimeout, - options: HttpsCallableOptions(timeout: const Duration(seconds: 3))); + kTestFunctionTimeout, + options: HttpsCallableOptions(timeout: const Duration(seconds: 3)), + ); }); test('times out when the provided timeout is exceeded', () async { @@ -164,7 +166,7 @@ void testsMain() { } on FirebaseFunctionsException catch (e) { expect(e.code, equals('deadline-exceeded')); } catch (e) { - fail(e); + fail('$e'); } }); }); diff --git a/packages/cloud_functions/cloud_functions/example/test_driver/cloud_functions_e2e_test.dart b/packages/cloud_functions/cloud_functions/example/test_driver/cloud_functions_e2e_test.dart index fa0a63495989..f9c0fa99a519 100644 --- a/packages/cloud_functions/cloud_functions/example/test_driver/cloud_functions_e2e_test.dart +++ b/packages/cloud_functions/cloud_functions/example/test_driver/cloud_functions_e2e_test.dart @@ -1,12 +1,7 @@ -// ignore_for_file: require_trailing_commas -// @dart = 2.9 - // Copyright 2020, the Chromium project authors. Please see the AUTHORS file // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. -// @dart=2.9 - import 'package:drive/drive_driver.dart' as drive; void main() => drive.main(); diff --git a/packages/cloud_functions/cloud_functions/example/test_driver/firebase_config.dart b/packages/cloud_functions/cloud_functions/example/test_driver/firebase_config.dart new file mode 100644 index 000000000000..6837fa2ce656 --- /dev/null +++ b/packages/cloud_functions/cloud_functions/example/test_driver/firebase_config.dart @@ -0,0 +1,46 @@ +import 'dart:io'; + +import 'package:firebase_core/firebase_core.dart'; +import 'package:flutter/foundation.dart'; + +class TestFirebaseConfig { + static FirebaseOptions get platformOptions { + if (kIsWeb) { + // Web + return const FirebaseOptions( + apiKey: 'AIzaSyAgUhHU8wSJgO5MVNy95tMT07NEjzMOfz0', + authDomain: 'react-native-firebase-testing.firebaseapp.com', + databaseURL: 'https://react-native-firebase-testing.firebaseio.com', + projectId: 'react-native-firebase-testing', + storageBucket: 'react-native-firebase-testing.appspot.com', + messagingSenderId: '448618578101', + appId: '1:448618578101:web:0b650370bb29e29cac3efc', + measurementId: 'G-F79DJ0VFGS', + ); + } else if (Platform.isIOS || Platform.isMacOS) { + // iOS and MacOS + return const FirebaseOptions( + appId: '1:448618578101:ios:f7208957983eeee4ac3efc', + apiKey: 'AIzaSyAHAsf51D0A407EklG1bs-5wA7EbyfNFg0', + projectId: 'react-native-firebase-testing', + messagingSenderId: '448618578101', + iosBundleId: 'io.flutter.plugins.firebase.functions.example', + iosClientId: + '48618578101-lc3q11v4dv28hef68s6skqju3k2gjd3j.apps.googleusercontent.com', + androidClientId: + '448618578101-vh59lklbaigpccaugknk3j0g1pp81kr2.apps.googleusercontent.com', + databaseURL: 'https://react-native-firebase-testing.firebaseio.com', + storageBucket: 'react-native-firebase-testing.appspot.com', + ); + } else { + // Android + return const FirebaseOptions( + // App ID of FF Core Example + appId: '1:448618578101:android:0446912d5f1476b6ac3efc', + apiKey: 'AIzaSyCuu4tbv9CwwTudNOweMNstzZHIDBhgJxA', + projectId: 'react-native-firebase-testing', + messagingSenderId: '448618578101', + ); + } + } +} diff --git a/packages/cloud_functions/cloud_functions/example/test_driver/sample.dart b/packages/cloud_functions/cloud_functions/example/test_driver/sample.dart index c29d1673253d..7bf762358da4 100644 --- a/packages/cloud_functions/cloud_functions/example/test_driver/sample.dart +++ b/packages/cloud_functions/cloud_functions/example/test_driver/sample.dart @@ -1,6 +1,3 @@ -// ignore_for_file: require_trailing_commas -// @dart = 2.9 - // Copyright 2020, the Chromium project authors. Please see the AUTHORS file // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. diff --git a/packages/firebase_app_check/firebase_app_check/example/pubspec.yaml b/packages/firebase_app_check/firebase_app_check/example/pubspec.yaml index 2af1d6c4c6db..6849b338649d 100644 --- a/packages/firebase_app_check/firebase_app_check/example/pubspec.yaml +++ b/packages/firebase_app_check/firebase_app_check/example/pubspec.yaml @@ -6,7 +6,7 @@ publish_to: 'none' version: 1.0.0+1 environment: - sdk: ">=2.7.0 <3.0.0" + sdk: '>=2.7.0 <3.0.0' dependencies: cupertino_icons: ^0.1.2 @@ -30,7 +30,7 @@ dependency_overrides: path: ../../../firebase_core/firebase_core_web dev_dependencies: - drive: 0.1.0 + drive: ^1.0.0-1.0.nullsafety.1 flutter_driver: sdk: flutter test: any diff --git a/packages/firebase_app_check/firebase_app_check/example/test_driver/firebase_app_check_e2e.dart b/packages/firebase_app_check/firebase_app_check/example/test_driver/firebase_app_check_e2e.dart index c39055c11ae1..c38604acad9d 100644 --- a/packages/firebase_app_check/firebase_app_check/example/test_driver/firebase_app_check_e2e.dart +++ b/packages/firebase_app_check/firebase_app_check/example/test_driver/firebase_app_check_e2e.dart @@ -1,6 +1,3 @@ -// ignore_for_file: require_trailing_commas -// @dart = 2.9 - // Copyright 2021, the Chromium project authors. Please see the AUTHORS file // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. diff --git a/packages/firebase_app_check/firebase_app_check/example/test_driver/firebase_app_check_e2e_test.dart b/packages/firebase_app_check/firebase_app_check/example/test_driver/firebase_app_check_e2e_test.dart index 2d22ba44a73f..bb4e596d9ec0 100644 --- a/packages/firebase_app_check/firebase_app_check/example/test_driver/firebase_app_check_e2e_test.dart +++ b/packages/firebase_app_check/firebase_app_check/example/test_driver/firebase_app_check_e2e_test.dart @@ -1,5 +1,3 @@ -// ignore_for_file: require_trailing_commas -// @dart=2.9 // Copyright 2021, the Chromium project authors. Please see the AUTHORS file // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. diff --git a/packages/firebase_auth/firebase_auth/example/ios/Runner.xcodeproj/project.pbxproj b/packages/firebase_auth/firebase_auth/example/ios/Runner.xcodeproj/project.pbxproj index e7b06b3e41f4..dc5397716012 100644 --- a/packages/firebase_auth/firebase_auth/example/ios/Runner.xcodeproj/project.pbxproj +++ b/packages/firebase_auth/firebase_auth/example/ios/Runner.xcodeproj/project.pbxproj @@ -149,7 +149,6 @@ 97C146EC1CF9000F007C117D /* Resources */, 9705A1C41CF9048500538489 /* Embed Frameworks */, 3B06AD1E1E4923F5004D2608 /* Thin Binary */, - B7F1A9EA4C114C29858E66FE /* [CP] Embed Pods Frameworks */, ); buildRules = ( ); @@ -359,7 +358,7 @@ "$(inherited)", "$(PROJECT_DIR)/Flutter", ); - PRODUCT_BUNDLE_IDENTIFIER = com.firebase.FlutterfireAuth; + PRODUCT_BUNDLE_IDENTIFIER = io.flutter.plugins.firebase.auth; PRODUCT_NAME = "$(TARGET_NAME)"; VERSIONING_SYSTEM = "apple-generic"; }; @@ -487,7 +486,7 @@ "$(inherited)", "$(PROJECT_DIR)/Flutter", ); - PRODUCT_BUNDLE_IDENTIFIER = com.firebase.FlutterfireAuth; + PRODUCT_BUNDLE_IDENTIFIER = io.flutter.plugins.firebase.auth; PRODUCT_NAME = "$(TARGET_NAME)"; VERSIONING_SYSTEM = "apple-generic"; }; @@ -510,7 +509,7 @@ "$(inherited)", "$(PROJECT_DIR)/Flutter", ); - PRODUCT_BUNDLE_IDENTIFIER = com.firebase.FlutterfireAuth; + PRODUCT_BUNDLE_IDENTIFIER = io.flutter.plugins.firebase.auth; PRODUCT_NAME = "$(TARGET_NAME)"; VERSIONING_SYSTEM = "apple-generic"; }; diff --git a/packages/firebase_auth/firebase_auth/example/lib/firebase_config.dart b/packages/firebase_auth/firebase_auth/example/lib/firebase_config.dart new file mode 100644 index 000000000000..640e279fdf6a --- /dev/null +++ b/packages/firebase_auth/firebase_auth/example/lib/firebase_config.dart @@ -0,0 +1,47 @@ +import 'dart:io'; + +import 'package:firebase_core/firebase_core.dart'; +import 'package:flutter/foundation.dart'; + +class DefaultFirebaseConfig { + static FirebaseOptions get platformOptions { + if (kIsWeb) { + // Web + return const FirebaseOptions( + apiKey: 'AIzaSyAgUhHU8wSJgO5MVNy95tMT07NEjzMOfz0', + appId: '1:448618578101:web:0b650370bb29e29cac3efc', + messagingSenderId: '448618578101', + projectId: 'react-native-firebase-testing', + authDomain: 'react-native-firebase-testing.firebaseapp.com', + ); + } else if (Platform.isIOS || Platform.isMacOS) { + // iOS and MacOS + return const FirebaseOptions( + apiKey: 'AIzaSyAHAsf51D0A407EklG1bs-5wA7EbyfNFg0', + appId: '1:448618578101:ios:4cd06f56e36384acac3efc', + messagingSenderId: '448618578101', + projectId: 'react-native-firebase-testing', + authDomain: 'react-native-firebase-testing.firebaseapp.com', + iosBundleId: 'io.flutter.plugins.firebase.auth', + databaseURL: 'https://react-native-firebase-testing.firebaseio.com', + iosClientId: + '448618578101-m53gtqfnqipj12pts10590l37npccd2r.apps.googleusercontent.com', + androidClientId: + '448618578101-26jgjs0rtl4ts2i667vjb28kldvs2kp6.apps.googleusercontent.com', + storageBucket: 'react-native-firebase-testing.appspot.com', + ); + } else { + // Android + return const FirebaseOptions( + apiKey: 'AIzaSyCuu4tbv9CwwTudNOweMNstzZHIDBhgJxA', + appId: '1:448618578101:android:9d44a7b85d1ab0baac3efc', + messagingSenderId: '448618578101', + projectId: 'react-native-firebase-testing', + authDomain: 'react-native-firebase-testing.firebaseapp.com', + databaseURL: 'https://react-native-firebase-testing.firebaseio.com', + androidClientId: + '448618578101-qd7qb4i251kmq2ju79bl7sif96si0ve3.apps.googleusercontent.com', + ); + } + } +} diff --git a/packages/firebase_auth/firebase_auth/example/lib/main.dart b/packages/firebase_auth/firebase_auth/example/lib/main.dart index c24de980ffa5..2646963ebb59 100755 --- a/packages/firebase_auth/firebase_auth/example/lib/main.dart +++ b/packages/firebase_auth/firebase_auth/example/lib/main.dart @@ -1,28 +1,20 @@ -// ignore_for_file: require_trailing_commas // Copyright 2020 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -import 'package:firebase_auth/firebase_auth.dart'; -import 'package:firebase_core/firebase_core.dart'; import 'package:flutter/material.dart'; import 'package:flutter_signin_button/button_builder.dart'; +import 'package:firebase_auth/firebase_auth.dart'; +import 'package:firebase_auth_example/firebase_config.dart'; +import 'package:firebase_core/firebase_core.dart'; + import './register_page.dart'; import './signin_page.dart'; Future main() async { WidgetsFlutterBinding.ensureInitialized(); - await Firebase.initializeApp( - options: const FirebaseOptions( - apiKey: 'AIzaSyAHAsf51D0A407EklG1bs-5wA7EbyfNFg0', - appId: '1:448618578101:ios:4cd06f56e36384acac3efc', - messagingSenderId: '448618578101', - projectId: 'react-native-firebase-testing', - authDomain: 'react-native-firebase-testing.firebaseapp.com', - iosClientId: - '448618578101-m53gtqfnqipj12pts10590l37npccd2r.apps.googleusercontent.com', - )); + await Firebase.initializeApp(options: DefaultFirebaseConfig.platformOptions); await FirebaseAuth.instance.useAuthEmulator('localhost', 9099); runApp(AuthExampleApp()); } diff --git a/packages/firebase_auth/firebase_auth/example/macos/Runner.xcodeproj/project.pbxproj b/packages/firebase_auth/firebase_auth/example/macos/Runner.xcodeproj/project.pbxproj index 7747c7213f64..95ececa25e95 100644 --- a/packages/firebase_auth/firebase_auth/example/macos/Runner.xcodeproj/project.pbxproj +++ b/packages/firebase_auth/firebase_auth/example/macos/Runner.xcodeproj/project.pbxproj @@ -448,7 +448,7 @@ "$(inherited)", "@executable_path/../Frameworks", ); - PRODUCT_BUNDLE_IDENTIFIER = io.flutter.plugins.firebaseauthexample; + PRODUCT_BUNDLE_IDENTIFIER = io.flutter.plugins.firebase.auth; PROVISIONING_PROFILE_SPECIFIER = ""; SWIFT_VERSION = 5.0; }; @@ -579,7 +579,7 @@ "$(inherited)", "@executable_path/../Frameworks", ); - PRODUCT_BUNDLE_IDENTIFIER = io.flutter.plugins.firebaseauthexample; + PRODUCT_BUNDLE_IDENTIFIER = io.flutter.plugins.firebase.auth; PROVISIONING_PROFILE_SPECIFIER = ""; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; SWIFT_VERSION = 5.0; @@ -604,7 +604,7 @@ "$(inherited)", "@executable_path/../Frameworks", ); - PRODUCT_BUNDLE_IDENTIFIER = io.flutter.plugins.firebaseauthexample; + PRODUCT_BUNDLE_IDENTIFIER = io.flutter.plugins.firebase.auth; PROVISIONING_PROFILE_SPECIFIER = ""; SWIFT_VERSION = 5.0; }; diff --git a/packages/firebase_auth/firebase_auth/example/macos/Runner/GoogleService-Info.plist b/packages/firebase_auth/firebase_auth/example/macos/Runner/GoogleService-Info.plist index 3261422f8e83..4294d3c0f603 100644 --- a/packages/firebase_auth/firebase_auth/example/macos/Runner/GoogleService-Info.plist +++ b/packages/firebase_auth/firebase_auth/example/macos/Runner/GoogleService-Info.plist @@ -3,11 +3,11 @@ CLIENT_ID - 448618578101-ja1be10uicsa2dvss16gh4hkqks0vq61.apps.googleusercontent.com + 448618578101-m53gtqfnqipj12pts10590l37npccd2r.apps.googleusercontent.com REVERSED_CLIENT_ID - com.googleusercontent.apps.448618578101-ja1be10uicsa2dvss16gh4hkqks0vq61 + com.googleusercontent.apps.448618578101-m53gtqfnqipj12pts10590l37npccd2r ANDROID_CLIENT_ID - 448618578101-2baveavh8bvs2famsa5r8t77fe1nrcn6.apps.googleusercontent.com + 448618578101-26jgjs0rtl4ts2i667vjb28kldvs2kp6.apps.googleusercontent.com API_KEY AIzaSyAHAsf51D0A407EklG1bs-5wA7EbyfNFg0 GCM_SENDER_ID @@ -15,24 +15,24 @@ PLIST_VERSION 1 BUNDLE_ID - io.flutter.plugins.firebaseauthexample + io.flutter.plugins.firebase.auth PROJECT_ID react-native-firebase-testing STORAGE_BUCKET react-native-firebase-testing.appspot.com IS_ADS_ENABLED - + IS_ANALYTICS_ENABLED - + IS_APPINVITE_ENABLED - + IS_GCM_ENABLED - + IS_SIGNIN_ENABLED - + GOOGLE_APP_ID - 1:448618578101:ios:2bc5c1fe2ec336f8ac3efc + 1:448618578101:ios:4cd06f56e36384acac3efc DATABASE_URL https://react-native-firebase-testing.firebaseio.com - + \ No newline at end of file diff --git a/packages/firebase_auth/firebase_auth/example/macos/Runner/Info.plist b/packages/firebase_auth/firebase_auth/example/macos/Runner/Info.plist index fe5d6f6252aa..de633ff2e0de 100644 --- a/packages/firebase_auth/firebase_auth/example/macos/Runner/Info.plist +++ b/packages/firebase_auth/firebase_auth/example/macos/Runner/Info.plist @@ -33,16 +33,16 @@ $(FLUTTER_BUILD_NUMBER) LSMinimumSystemVersion $(MACOSX_DEPLOYMENT_TARGET) + NSAppTransportSecurity + + NSAllowsArbitraryLoads + + NSHumanReadableCopyright $(PRODUCT_COPYRIGHT) NSMainNibFile MainMenu NSPrincipalClass NSApplication - NSAppTransportSecurity - - NSAllowsArbitraryLoads - - diff --git a/packages/firebase_auth/firebase_auth/example/test_driver/firebase_auth_e2e.dart b/packages/firebase_auth/firebase_auth/example/test_driver/firebase_auth_e2e.dart index aadd79d68462..52f41fb74fab 100644 --- a/packages/firebase_auth/firebase_auth/example/test_driver/firebase_auth_e2e.dart +++ b/packages/firebase_auth/firebase_auth/example/test_driver/firebase_auth_e2e.dart @@ -1,5 +1,3 @@ -// ignore_for_file: require_trailing_commas - // Copyright 2020, the Chromium project authors. Please see the AUTHORS file // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. @@ -9,6 +7,7 @@ import 'package:firebase_auth/firebase_auth.dart'; import 'package:firebase_core/firebase_core.dart'; import 'package:flutter_test/flutter_test.dart'; +import 'firebase_config.dart'; import 'instance_e2e.dart'; import 'test_utils.dart'; import 'user_e2e.dart'; @@ -19,16 +18,8 @@ bool useEmulator = true; void testsMain() { setUpAll(() async { - await Firebase.initializeApp( - options: const FirebaseOptions( - apiKey: 'AIzaSyAHAsf51D0A407EklG1bs-5wA7EbyfNFg0', - appId: '1:448618578101:ios:4cd06f56e36384acac3efc', - messagingSenderId: '448618578101', - projectId: 'react-native-firebase-testing', - authDomain: 'react-native-firebase-testing.firebaseapp.com', - iosClientId: - '448618578101-m53gtqfnqipj12pts10590l37npccd2r.apps.googleusercontent.com', - )); + // TODO(pr_Mais): macos isn't compiling without the GoogleService.plist file + await Firebase.initializeApp(options: TestFirebaseConfig.platformOptions); if (useEmulator) { await FirebaseAuth.instance @@ -52,6 +43,7 @@ void testsMain() { email: testDisabledEmail, password: testPassword, ); + await emulatorDisableUser(disabledUserCredential.user!.uid); await ensureSignedOut(); diff --git a/packages/firebase_auth/firebase_auth/example/test_driver/firebase_config.dart b/packages/firebase_auth/firebase_auth/example/test_driver/firebase_config.dart new file mode 100644 index 000000000000..1a9a4d9c20e3 --- /dev/null +++ b/packages/firebase_auth/firebase_auth/example/test_driver/firebase_config.dart @@ -0,0 +1,47 @@ +import 'dart:io'; + +import 'package:firebase_core/firebase_core.dart'; +import 'package:flutter/foundation.dart'; + +class TestFirebaseConfig { + static FirebaseOptions get platformOptions { + if (kIsWeb) { + // Web + return const FirebaseOptions( + apiKey: 'AIzaSyAgUhHU8wSJgO5MVNy95tMT07NEjzMOfz0', + appId: '1:448618578101:web:0b650370bb29e29cac3efc', + messagingSenderId: '448618578101', + projectId: 'react-native-firebase-testing', + authDomain: 'react-native-firebase-testing.firebaseapp.com', + ); + } else if (Platform.isIOS || Platform.isMacOS) { + // iOS and MacOS + return const FirebaseOptions( + apiKey: 'AIzaSyAHAsf51D0A407EklG1bs-5wA7EbyfNFg0', + appId: '1:448618578101:ios:4cd06f56e36384acac3efc', + messagingSenderId: '448618578101', + projectId: 'react-native-firebase-testing', + authDomain: 'react-native-firebase-testing.firebaseapp.com', + iosBundleId: 'io.flutter.plugins.firebase.auth', + databaseURL: 'https://react-native-firebase-testing.firebaseio.com', + iosClientId: + '448618578101-m53gtqfnqipj12pts10590l37npccd2r.apps.googleusercontent.com', + androidClientId: + '448618578101-26jgjs0rtl4ts2i667vjb28kldvs2kp6.apps.googleusercontent.com', + storageBucket: 'react-native-firebase-testing.appspot.com', + ); + } else { + // Android + return const FirebaseOptions( + apiKey: 'AIzaSyCuu4tbv9CwwTudNOweMNstzZHIDBhgJxA', + appId: '1:448618578101:android:9d44a7b85d1ab0baac3efc', + messagingSenderId: '448618578101', + projectId: 'react-native-firebase-testing', + authDomain: 'react-native-firebase-testing.firebaseapp.com', + databaseURL: 'https://react-native-firebase-testing.firebaseio.com', + androidClientId: + '448618578101-qd7qb4i251kmq2ju79bl7sif96si0ve3.apps.googleusercontent.com', + ); + } + } +} diff --git a/packages/firebase_auth/firebase_auth/example/test_driver/instance_e2e.dart b/packages/firebase_auth/firebase_auth/example/test_driver/instance_e2e.dart index 3ffb15c08958..1a2a6b98af8d 100644 --- a/packages/firebase_auth/firebase_auth/example/test_driver/instance_e2e.dart +++ b/packages/firebase_auth/firebase_auth/example/test_driver/instance_e2e.dart @@ -660,7 +660,8 @@ void runInstanceTests() { Future getError() async { Completer completer = Completer(); - unawaited(FirebaseAuth.instance.verifyPhoneNumber( + unawaited( + FirebaseAuth.instance.verifyPhoneNumber( phoneNumber: 'foo', verificationCompleted: (PhoneAuthCredential credential) { return completer @@ -676,13 +677,16 @@ void runInstanceTests() { codeAutoRetrievalTimeout: (String foo) { return completer .completeError(Exception('Should not have been called')); - })); + }, + ), + ); return completer.future as FutureOr; } Exception e = await getError(); expect(e, isA()); + FirebaseAuthException exception = e as FirebaseAuthException; expect(exception.code, equals('invalid-phone-number')); }); diff --git a/packages/firebase_core/firebase_core/example/android/app/google-services.json b/packages/firebase_core/firebase_core/example/android/app/google-services.json deleted file mode 100644 index 7f7e074c2429..000000000000 --- a/packages/firebase_core/firebase_core/example/android/app/google-services.json +++ /dev/null @@ -1,42 +0,0 @@ -{ - "project_info": { - "project_number": "159623150305", - "firebase_url": "https://flutter-firebase-plugins.firebaseio.com", - "project_id": "flutter-firebase-plugins", - "storage_bucket": "flutter-firebase-plugins.appspot.com" - }, - "client": [ - { - "client_info": { - "mobilesdk_app_id": "1:159623150305:android:236f9daea101f77e", - "android_client_info": { - "package_name": "io.flutter.plugins.firebasecoreexample" - } - }, - "oauth_client": [ - { - "client_id": "159623150305-q05bbbtsutr02abhips3suj7hujfk4bg.apps.googleusercontent.com", - "client_type": 3 - } - ], - "api_key": [ - { - "current_key": "AIzaSyChk3KEG7QYrs4kQPLP1tjJNxBTbfCAdgg" - } - ], - "services": { - "analytics_service": { - "status": 1 - }, - "appinvite_service": { - "status": 1, - "other_platform_oauth_client": [] - }, - "ads_service": { - "status": 2 - } - } - } - ], - "configuration_version": "1" -} diff --git a/packages/firebase_core/firebase_core/example/lib/firebase_config.dart b/packages/firebase_core/firebase_core/example/lib/firebase_config.dart new file mode 100644 index 000000000000..fe45999096b4 --- /dev/null +++ b/packages/firebase_core/firebase_core/example/lib/firebase_config.dart @@ -0,0 +1,35 @@ +import 'dart:io'; + +import 'package:firebase_core/firebase_core.dart'; +import 'package:flutter/foundation.dart'; + +class DefaultFirebaseConfig { + static FirebaseOptions get platformOptions { + if (kIsWeb) { + // Web + return const FirebaseOptions( + appId: '1:448618578101:web:0b650370bb29e29cac3efc', + apiKey: 'AIzaSyAgUhHU8wSJgO5MVNy95tMT07NEjzMOfz0', + projectId: 'react-native-firebase-testing', + messagingSenderId: '448618578101', + ); + } else if (Platform.isIOS || Platform.isMacOS) { + // iOS and MacOS + return const FirebaseOptions( + appId: '1:448618578101:ios:0b650370bb29e29cac3efc', + apiKey: 'AIzaSyAgUhHU8wSJgO5MVNy95tMT07NEjzMOfz0', + projectId: 'react-native-firebase-testing', + messagingSenderId: '448618578101', + iosBundleId: 'io.flutter.plugins.firebasecoreexample', + ); + } else { + // Android + return const FirebaseOptions( + appId: '1:448618578101:android:0446912d5f1476b6ac3efc', + apiKey: 'AIzaSyCuu4tbv9CwwTudNOweMNstzZHIDBhgJxA', + projectId: 'react-native-firebase-testing', + messagingSenderId: '448618578101', + ); + } + } +} diff --git a/packages/firebase_core/firebase_core/example/lib/main.dart b/packages/firebase_core/firebase_core/example/lib/main.dart index e0f6ee8e1507..13ae5fa6a618 100644 --- a/packages/firebase_core/firebase_core/example/lib/main.dart +++ b/packages/firebase_core/firebase_core/example/lib/main.dart @@ -1,19 +1,16 @@ -// ignore_for_file: require_trailing_commas // Copyright 2019 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// ignore_for_file: public_member_api_docs - -// @dart=2.9 import 'dart:async'; +import 'package:firebase_core_example/firebase_config.dart'; import 'package:flutter/material.dart'; import 'package:firebase_core/firebase_core.dart'; void main() => runApp(const MyApp()); class MyApp extends StatelessWidget { - const MyApp({Key key}) : super(key: key); + const MyApp({Key? key}) : super(key: key); String get name => 'foo'; @@ -26,13 +23,8 @@ class MyApp extends StatelessWidget { Future initializeDefault() async { FirebaseApp app = await Firebase.initializeApp( - options: const FirebaseOptions( - apiKey: 'AIzaSyAHAsf51D0A407EklG1bs-5wA7EbyfNFg0', - appId: '1:448618578101:ios:2bc5c1fe2ec336f8ac3efc', - messagingSenderId: '448618578101', - projectId: 'react-native-firebase-testing', - )); - assert(app != null); + options: DefaultFirebaseConfig.platformOptions, + ); print('Initialized default app $app'); } @@ -40,7 +32,6 @@ class MyApp extends StatelessWidget { FirebaseApp app = await Firebase.initializeApp(name: name, options: firebaseOptions); - assert(app != null); print('Initialized $app'); } @@ -51,13 +42,13 @@ class MyApp extends StatelessWidget { void options() { final FirebaseApp app = Firebase.app(name); - final FirebaseOptions options = app?.options; + final options = app.options; print('Current options for app $name: $options'); } Future delete() async { final FirebaseApp app = Firebase.app(name); - await app?.delete(); + await app.delete(); print('App $name deleted'); } @@ -75,16 +66,25 @@ class MyApp extends StatelessWidget { crossAxisAlignment: CrossAxisAlignment.stretch, children: [ ElevatedButton( - onPressed: initializeDefault, - child: const Text('Initialize default app')), + onPressed: initializeDefault, + child: const Text('Initialize default app'), + ), + ElevatedButton( + onPressed: initializeSecondary, + child: const Text('Initialize secondary app'), + ), ElevatedButton( - onPressed: initializeSecondary, - child: const Text('Initialize secondary app')), - ElevatedButton(onPressed: apps, child: const Text('Get apps')), + onPressed: apps, + child: const Text('Get apps'), + ), ElevatedButton( - onPressed: options, child: const Text('List options')), + onPressed: options, + child: const Text('List options'), + ), ElevatedButton( - onPressed: delete, child: const Text('Delete app')), + onPressed: delete, + child: const Text('Delete app'), + ), ], ), ), diff --git a/packages/firebase_core/firebase_core/example/pubspec.yaml b/packages/firebase_core/firebase_core/example/pubspec.yaml index 8974871fa72b..2f9ad9ba2905 100644 --- a/packages/firebase_core/firebase_core/example/pubspec.yaml +++ b/packages/firebase_core/firebase_core/example/pubspec.yaml @@ -2,7 +2,7 @@ name: firebase_core_example description: Demonstrates how to use the firebase_core plugin. environment: - sdk: ">=2.12.0 <3.0.0" + sdk: '>=2.12.0 <3.0.0' dependencies: firebase_core: @@ -17,7 +17,7 @@ dependency_overrides: path: ../../firebase_core_web dev_dependencies: - e2e: ^0.6.1 + drive: ^1.0.0-1.0.nullsafety.1 flutter_driver: sdk: flutter flutter_test: diff --git a/packages/firebase_core/firebase_core/example/test_driver/firebase_config.dart b/packages/firebase_core/firebase_core/example/test_driver/firebase_config.dart new file mode 100644 index 000000000000..aab6a0093f03 --- /dev/null +++ b/packages/firebase_core/firebase_core/example/test_driver/firebase_config.dart @@ -0,0 +1,35 @@ +import 'dart:io'; + +import 'package:firebase_core/firebase_core.dart'; +import 'package:flutter/foundation.dart'; + +class TestFirebaseConfig { + static FirebaseOptions get platformOptions { + if (kIsWeb) { + // Web + return const FirebaseOptions( + appId: '1:448618578101:web:0b650370bb29e29cac3efc', + apiKey: 'AIzaSyAgUhHU8wSJgO5MVNy95tMT07NEjzMOfz0', + projectId: 'react-native-firebase-testing', + messagingSenderId: '448618578101', + ); + } else if (Platform.isIOS || Platform.isMacOS) { + // iOS and MacOS + return const FirebaseOptions( + appId: '1:448618578101:ios:0b650370bb29e29cac3efc', + apiKey: 'AIzaSyAgUhHU8wSJgO5MVNy95tMT07NEjzMOfz0', + projectId: 'react-native-firebase-testing', + messagingSenderId: '448618578101', + iosBundleId: 'io.flutter.plugins.firebasecoreexample', + ); + } else { + // Android + return const FirebaseOptions( + appId: '1:448618578101:android:0446912d5f1476b6ac3efc', + apiKey: 'AIzaSyCuu4tbv9CwwTudNOweMNstzZHIDBhgJxA', + projectId: 'react-native-firebase-testing', + messagingSenderId: '448618578101', + ); + } + } +} diff --git a/packages/firebase_core/firebase_core/example/test_driver/firebase_core_e2e.dart b/packages/firebase_core/firebase_core/example/test_driver/firebase_core_e2e.dart index 05a9a6aea6da..2ae6e8f77749 100644 --- a/packages/firebase_core/firebase_core/example/test_driver/firebase_core_e2e.dart +++ b/packages/firebase_core/firebase_core/example/test_driver/firebase_core_e2e.dart @@ -1,66 +1,47 @@ -// ignore_for_file: require_trailing_commas -// @dart = 2.9 - // Copyright 2019, the Chromium project authors. Please see the AUTHORS file // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. -// @dart=2.9 - -import 'dart:io'; -import 'package:e2e/e2e.dart'; import 'package:firebase_core/firebase_core.dart'; import 'package:firebase_core_platform_interface/firebase_core_platform_interface.dart'; import 'package:flutter_test/flutter_test.dart'; -void main() { - E2EWidgetsFlutterBinding.ensureInitialized(); +import 'package:drive/drive.dart' as drive; + +import 'firebase_config.dart'; +void main() => drive.main(testsMain); + +void testsMain() { String testAppName = 'TestApp'; - FirebaseOptions testAppOptions; - if (Platform.isIOS || Platform.isMacOS) { - testAppOptions = const FirebaseOptions( - appId: '1:448618578101:ios:0b650370bb29e29cac3efc', - apiKey: 'AIzaSyAgUhHU8wSJgO5MVNy95tMT07NEjzMOfz0', - projectId: 'react-native-firebase-testing', - messagingSenderId: '448618578101', - iosBundleId: 'io.flutter.plugins.firebasecoreexample', - ); - } else { - testAppOptions = const FirebaseOptions( - appId: '1:448618578101:web:0b650370bb29e29cac3efc', - apiKey: 'AIzaSyAgUhHU8wSJgO5MVNy95tMT07NEjzMOfz0', - projectId: 'react-native-firebase-testing', - messagingSenderId: '448618578101', - ); - } + FirebaseOptions? testAppOptions = TestFirebaseConfig.platformOptions; setUpAll(() async { await Firebase.initializeApp(name: testAppName, options: testAppOptions); }); - testWidgets('Firebase.apps', (WidgetTester tester) async { + test('Firebase.apps', () async { List apps = Firebase.apps; expect(apps.length, 1); expect(apps[0].name, testAppName); expect(apps[0].options, testAppOptions); }); - testWidgets('Firebase.app()', (WidgetTester tester) async { + test('Firebase.app()', () async { FirebaseApp app = Firebase.app(testAppName); expect(app.name, testAppName); expect(app.options, testAppOptions); }); - testWidgets('Firebase.app() Exception', (WidgetTester tester) async { + test('Firebase.app() Exception', () async { expect( () => Firebase.app('NoApp'), throwsA(noAppExists('NoApp')), ); }); - testWidgets('FirebaseApp.delete()', (WidgetTester tester) async { + test('FirebaseApp.delete()', () async { await Firebase.initializeApp(name: 'SecondaryApp', options: testAppOptions); expect(Firebase.apps.length, 2); @@ -72,8 +53,7 @@ void main() { expect(Firebase.apps.length, 1); }); - testWidgets('FirebaseApp.setAutomaticDataCollectionEnabled()', - (WidgetTester tester) async { + test('FirebaseApp.setAutomaticDataCollectionEnabled()', () async { FirebaseApp app = Firebase.app(testAppName); bool enabled = app.isAutomaticDataCollectionEnabled; @@ -82,8 +62,7 @@ void main() { expect(app.isAutomaticDataCollectionEnabled, !enabled); }); - testWidgets('FirebaseApp.setAutomaticResourceManagementEnabled()', - (WidgetTester tester) async { + test('FirebaseApp.setAutomaticResourceManagementEnabled()', () async { FirebaseApp app = Firebase.app(testAppName); await app.setAutomaticResourceManagementEnabled(true); diff --git a/packages/firebase_core/firebase_core/example/test_driver/firebase_core_e2e_test.dart b/packages/firebase_core/firebase_core/example/test_driver/firebase_core_e2e_test.dart index f91ce3f140cb..f9c0fa99a519 100644 --- a/packages/firebase_core/firebase_core/example/test_driver/firebase_core_e2e_test.dart +++ b/packages/firebase_core/firebase_core/example/test_driver/firebase_core_e2e_test.dart @@ -1,12 +1,7 @@ -// ignore_for_file: require_trailing_commas -// @dart = 2.9 - // Copyright 2020, the Chromium project authors. Please see the AUTHORS file // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. -// @dart=2.9 - -import 'package:e2e/e2e_driver.dart' as e2e; +import 'package:drive/drive_driver.dart' as drive; -Future main() async => e2e.main(); +void main() => drive.main(); diff --git a/packages/firebase_crashlytics/firebase_crashlytics/example/lib/main.dart b/packages/firebase_crashlytics/firebase_crashlytics/example/lib/main.dart index 36730beaa46e..0404fe2d3e5e 100644 --- a/packages/firebase_crashlytics/firebase_crashlytics/example/lib/main.dart +++ b/packages/firebase_crashlytics/firebase_crashlytics/example/lib/main.dart @@ -3,8 +3,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// @dart=2.9 - import 'dart:async'; import 'dart:io'; @@ -24,13 +22,14 @@ Future main() async { await runZonedGuarded(() async { WidgetsFlutterBinding.ensureInitialized(); await Firebase.initializeApp( - options: const FirebaseOptions( - apiKey: 'AIzaSyAHAsf51D0A407EklG1bs-5wA7EbyfNFg0', - appId: '1:448618578101:ios:2bc5c1fe2ec336f8ac3efc', - messagingSenderId: '448618578101', - authDomain: 'react-native-firebase-testing.firebaseapp.com', - projectId: 'react-native-firebase-testing', - )); + options: const FirebaseOptions( + apiKey: 'AIzaSyAHAsf51D0A407EklG1bs-5wA7EbyfNFg0', + appId: '1:448618578101:ios:2bc5c1fe2ec336f8ac3efc', + messagingSenderId: '448618578101', + authDomain: 'react-native-firebase-testing.firebaseapp.com', + projectId: 'react-native-firebase-testing', + ), + ); FlutterError.onError = FirebaseCrashlytics.instance.recordFlutterError; runApp(MyApp()); }, (error, stackTrace) { @@ -39,13 +38,13 @@ Future main() async { } class MyApp extends StatefulWidget { - MyApp({Key key}) : super(key: key); + MyApp({Key? key}) : super(key: key); @override _MyAppState createState() => _MyAppState(); } class _MyAppState extends State { - Future _initializeFlutterFireFuture; + late Future _initializeFlutterFireFuture; Future _testAsyncErrorOnInit() async { Future.delayed(const Duration(seconds: 2), () { @@ -225,7 +224,6 @@ class _MyAppState extends State { ], ), ); - break; default: return const Center(child: Text('Loading')); } diff --git a/packages/firebase_crashlytics/firebase_crashlytics/example/pubspec.yaml b/packages/firebase_crashlytics/firebase_crashlytics/example/pubspec.yaml index ba71f9722f58..383abe007d74 100644 --- a/packages/firebase_crashlytics/firebase_crashlytics/example/pubspec.yaml +++ b/packages/firebase_crashlytics/firebase_crashlytics/example/pubspec.yaml @@ -2,8 +2,8 @@ name: firebase_crashlytics_example description: Demonstrates how to use the firebase_crashlytics plugin. environment: - sdk: ">=2.12.0 <3.0.0" - flutter: ">=1.12.13+hotfix.5" + sdk: '>=2.12.0 <3.0.0' + flutter: '>=1.12.13+hotfix.5' dependencies: firebase_analytics: @@ -28,7 +28,7 @@ dependency_overrides: path: ../../firebase_crashlytics_platform_interface dev_dependencies: - drive: 0.1.0 + drive: 1.0.0-1.0.nullsafety.1 flutter_driver: sdk: flutter test: any diff --git a/packages/firebase_crashlytics/firebase_crashlytics/example/test_driver/firebase_crashlytics_e2e.dart b/packages/firebase_crashlytics/firebase_crashlytics/example/test_driver/firebase_crashlytics_e2e.dart index a91cd53e4e0d..84104db55ab0 100644 --- a/packages/firebase_crashlytics/firebase_crashlytics/example/test_driver/firebase_crashlytics_e2e.dart +++ b/packages/firebase_crashlytics/firebase_crashlytics/example/test_driver/firebase_crashlytics_e2e.dart @@ -1,10 +1,7 @@ -// ignore_for_file: require_trailing_commas // Copyright 2020, the Chromium project authors. Please see the AUTHORS file // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. -// @dart=2.9 - import 'package:drive/drive.dart' as drive; import 'package:flutter/widgets.dart'; import 'package:flutter_test/flutter_test.dart'; @@ -13,7 +10,7 @@ import 'package:firebase_crashlytics/firebase_crashlytics.dart'; void testsMain() { group('$FirebaseCrashlytics', () { - /*late*/ FirebaseCrashlytics crashlytics; + late FirebaseCrashlytics crashlytics; setUpAll(() async { await Firebase.initializeApp(); @@ -56,19 +53,24 @@ void testsMain() { // This is currently only testing that we can log errors without crashing. test('should log error', () async { await crashlytics.recordError( - 'foo exception', StackTrace.fromString('during testing')); + 'foo exception', + StackTrace.fromString('during testing'), + ); }); // This is currently only testing that we can log flutter errors without crashing. test('should record flutter error', () async { - await crashlytics.recordFlutterError(FlutterErrorDetails( + await crashlytics.recordFlutterError( + FlutterErrorDetails( exception: 'foo exception', stack: StackTrace.fromString(''), context: DiagnosticsNode.message('bar reason'), informationCollector: () => [ - DiagnosticsNode.message('first message'), - DiagnosticsNode.message('second message') - ])); + DiagnosticsNode.message('first message'), + DiagnosticsNode.message('second message') + ], + ), + ); }); }); @@ -107,10 +109,14 @@ void testsMain() { group('setCustomKey', () { test('should throw if null', () async { - expect( - () => crashlytics.setCustomKey(null, null), throwsAssertionError); - expect( - () => crashlytics.setCustomKey('foo', null), throwsAssertionError); + // expect( + // () => crashlytics.setCustomKey(null, null), + // throwsAssertionError, + // ); + // expect( + // () => crashlytics.setCustomKey('foo', null), + // throwsAssertionError, + // ); expect(() => crashlytics.setCustomKey('foo', []), throwsAssertionError); expect(() => crashlytics.setCustomKey('foo', {}), throwsAssertionError); }); diff --git a/packages/firebase_crashlytics/firebase_crashlytics/example/test_driver/firebase_crashlytics_e2e_test.dart b/packages/firebase_crashlytics/firebase_crashlytics/example/test_driver/firebase_crashlytics_e2e_test.dart index b37a67802d23..f9c0fa99a519 100644 --- a/packages/firebase_crashlytics/firebase_crashlytics/example/test_driver/firebase_crashlytics_e2e_test.dart +++ b/packages/firebase_crashlytics/firebase_crashlytics/example/test_driver/firebase_crashlytics_e2e_test.dart @@ -1,10 +1,7 @@ -// ignore_for_file: require_trailing_commas // Copyright 2020, the Chromium project authors. Please see the AUTHORS file // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. -// @dart=2.9 - import 'package:drive/drive_driver.dart' as drive; void main() => drive.main(); diff --git a/packages/firebase_messaging/firebase_messaging/example/android/app/google-services.json b/packages/firebase_messaging/firebase_messaging/example/android/app/google-services.json deleted file mode 100644 index fe43a56b87a8..000000000000 --- a/packages/firebase_messaging/firebase_messaging/example/android/app/google-services.json +++ /dev/null @@ -1,931 +0,0 @@ -{ - "project_info": { - "project_number": "448618578101", - "firebase_url": "https://react-native-firebase-testing.firebaseio.com", - "project_id": "react-native-firebase-testing", - "storage_bucket": "react-native-firebase-testing.appspot.com" - }, - "client": [ - { - "client_info": { - "mobilesdk_app_id": "1:448618578101:android:cadfc9e23089d00eac3efc", - "android_client_info": { - "package_name": "com.dackers.demo" - } - }, - "oauth_client": [ - { - "client_id": "448618578101-sg12d2qin42cpr00f8b0gehs5s7inm0v.apps.googleusercontent.com", - "client_type": 3 - } - ], - "api_key": [ - { - "current_key": "AIzaSyCuu4tbv9CwwTudNOweMNstzZHIDBhgJxA" - } - ], - "services": { - "appinvite_service": { - "other_platform_oauth_client": [ - { - "client_id": "448618578101-sg12d2qin42cpr00f8b0gehs5s7inm0v.apps.googleusercontent.com", - "client_type": 3 - }, - { - "client_id": "448618578101-qqah55eossjuaa9np6ppo2l9fe3e7ohh.apps.googleusercontent.com", - "client_type": 2, - "ios_info": { - "bundle_id": "com.crashlytics.test" - } - } - ] - } - } - }, - { - "client_info": { - "mobilesdk_app_id": "1:448618578101:android:f97c4f71d274e363ac3efc", - "android_client_info": { - "package_name": "com.example.crash_test_2" - } - }, - "oauth_client": [ - { - "client_id": "448618578101-sg12d2qin42cpr00f8b0gehs5s7inm0v.apps.googleusercontent.com", - "client_type": 3 - } - ], - "api_key": [ - { - "current_key": "AIzaSyCuu4tbv9CwwTudNOweMNstzZHIDBhgJxA" - } - ], - "services": { - "appinvite_service": { - "other_platform_oauth_client": [ - { - "client_id": "448618578101-sg12d2qin42cpr00f8b0gehs5s7inm0v.apps.googleusercontent.com", - "client_type": 3 - }, - { - "client_id": "448618578101-qqah55eossjuaa9np6ppo2l9fe3e7ohh.apps.googleusercontent.com", - "client_type": 2, - "ios_info": { - "bundle_id": "com.crashlytics.test" - } - } - ] - } - } - }, - { - "client_info": { - "mobilesdk_app_id": "1:448618578101:android:e708991417cc7542ac3efc", - "android_client_info": { - "package_name": "com.example.testapp" - } - }, - "oauth_client": [ - { - "client_id": "448618578101-sg12d2qin42cpr00f8b0gehs5s7inm0v.apps.googleusercontent.com", - "client_type": 3 - } - ], - "api_key": [ - { - "current_key": "AIzaSyCuu4tbv9CwwTudNOweMNstzZHIDBhgJxA" - } - ], - "services": { - "appinvite_service": { - "other_platform_oauth_client": [ - { - "client_id": "448618578101-sg12d2qin42cpr00f8b0gehs5s7inm0v.apps.googleusercontent.com", - "client_type": 3 - }, - { - "client_id": "448618578101-qqah55eossjuaa9np6ppo2l9fe3e7ohh.apps.googleusercontent.com", - "client_type": 2, - "ios_info": { - "bundle_id": "com.crashlytics.test" - } - } - ] - } - } - }, - { - "client_info": { - "mobilesdk_app_id": "1:448618578101:android:78350c93b1c60b39ac3efc", - "android_client_info": { - "package_name": "com.example.weather_application" - } - }, - "oauth_client": [ - { - "client_id": "448618578101-r9nu34bp51ji8dve73mr8toori9nv3fp.apps.googleusercontent.com", - "client_type": 1, - "android_info": { - "package_name": "com.example.weather_application", - "certificate_hash": "909ca1482ef022bbae45a2db6b6d05d807a4c4aa" - } - }, - { - "client_id": "448618578101-sg12d2qin42cpr00f8b0gehs5s7inm0v.apps.googleusercontent.com", - "client_type": 3 - } - ], - "api_key": [ - { - "current_key": "AIzaSyCuu4tbv9CwwTudNOweMNstzZHIDBhgJxA" - } - ], - "services": { - "appinvite_service": { - "other_platform_oauth_client": [ - { - "client_id": "448618578101-sg12d2qin42cpr00f8b0gehs5s7inm0v.apps.googleusercontent.com", - "client_type": 3 - }, - { - "client_id": "448618578101-qqah55eossjuaa9np6ppo2l9fe3e7ohh.apps.googleusercontent.com", - "client_type": 2, - "ios_info": { - "bundle_id": "com.crashlytics.test" - } - } - ] - } - } - }, - { - "client_info": { - "mobilesdk_app_id": "1:448618578101:android:cc6c1dc7a65cc83c", - "android_client_info": { - "package_name": "com.invertase.testing" - } - }, - "oauth_client": [ - { - "client_id": "448618578101-h0o9b94jnhcoal2qgjn7s7ckkc2n7okq.apps.googleusercontent.com", - "client_type": 1, - "android_info": { - "package_name": "com.invertase.testing", - "certificate_hash": "909ca1482ef022bbae45a2db6b6d05d807a4c4aa" - } - }, - { - "client_id": "448618578101-gva3jv7cr8qquj04k0o7cni674j65kha.apps.googleusercontent.com", - "client_type": 1, - "android_info": { - "package_name": "com.invertase.testing", - "certificate_hash": "5e8f16062ea3cd2c4a0d547876baa6f38cabf625" - } - }, - { - "client_id": "448618578101-a9p7bj5jlakabp22fo3cbkj7nsmag24e.apps.googleusercontent.com", - "client_type": 1, - "android_info": { - "package_name": "com.invertase.testing", - "certificate_hash": "889b4292c735f371168a372cc7778992cd8a5052" - } - }, - { - "client_id": "448618578101-pdjje2lkv3p941e03hkrhfa7459cr2v8.apps.googleusercontent.com", - "client_type": 1, - "android_info": { - "package_name": "com.invertase.testing", - "certificate_hash": "992e468b990cc418f306d0131be61ecfad800ac1" - } - }, - { - "client_id": "448618578101-sg12d2qin42cpr00f8b0gehs5s7inm0v.apps.googleusercontent.com", - "client_type": 3 - } - ], - "api_key": [ - { - "current_key": "AIzaSyCuu4tbv9CwwTudNOweMNstzZHIDBhgJxA" - } - ], - "services": { - "appinvite_service": { - "other_platform_oauth_client": [ - { - "client_id": "448618578101-sg12d2qin42cpr00f8b0gehs5s7inm0v.apps.googleusercontent.com", - "client_type": 3 - }, - { - "client_id": "448618578101-qqah55eossjuaa9np6ppo2l9fe3e7ohh.apps.googleusercontent.com", - "client_type": 2, - "ios_info": { - "bundle_id": "com.crashlytics.test" - } - } - ] - } - } - }, - { - "client_info": { - "mobilesdk_app_id": "1:448618578101:android:cc5ce91648e65dbeac3efc", - "android_client_info": { - "package_name": "com.notifeetestapp" - } - }, - "oauth_client": [ - { - "client_id": "448618578101-j9nluebtat700ua550esfvaf64gbo5l5.apps.googleusercontent.com", - "client_type": 1, - "android_info": { - "package_name": "com.notifeetestapp", - "certificate_hash": "5e8f16062ea3cd2c4a0d547876baa6f38cabf625" - } - }, - { - "client_id": "448618578101-sg12d2qin42cpr00f8b0gehs5s7inm0v.apps.googleusercontent.com", - "client_type": 3 - } - ], - "api_key": [ - { - "current_key": "AIzaSyCuu4tbv9CwwTudNOweMNstzZHIDBhgJxA" - } - ], - "services": { - "appinvite_service": { - "other_platform_oauth_client": [ - { - "client_id": "448618578101-sg12d2qin42cpr00f8b0gehs5s7inm0v.apps.googleusercontent.com", - "client_type": 3 - }, - { - "client_id": "448618578101-qqah55eossjuaa9np6ppo2l9fe3e7ohh.apps.googleusercontent.com", - "client_type": 2, - "ios_info": { - "bundle_id": "com.crashlytics.test" - } - } - ] - } - } - }, - { - "client_info": { - "mobilesdk_app_id": "1:448618578101:android:6aa085e64d694703ac3efc", - "android_client_info": { - "package_name": "com.rnfbdemo" - } - }, - "oauth_client": [ - { - "client_id": "448618578101-a8tk83htomfvrelhu71j93safubvipdj.apps.googleusercontent.com", - "client_type": 1, - "android_info": { - "package_name": "com.rnfbdemo", - "certificate_hash": "909ca1482ef022bbae45a2db6b6d05d807a4c4aa" - } - }, - { - "client_id": "448618578101-sg12d2qin42cpr00f8b0gehs5s7inm0v.apps.googleusercontent.com", - "client_type": 3 - } - ], - "api_key": [ - { - "current_key": "AIzaSyCuu4tbv9CwwTudNOweMNstzZHIDBhgJxA" - } - ], - "services": { - "appinvite_service": { - "other_platform_oauth_client": [ - { - "client_id": "448618578101-sg12d2qin42cpr00f8b0gehs5s7inm0v.apps.googleusercontent.com", - "client_type": 3 - }, - { - "client_id": "448618578101-qqah55eossjuaa9np6ppo2l9fe3e7ohh.apps.googleusercontent.com", - "client_type": 2, - "ios_info": { - "bundle_id": "com.crashlytics.test" - } - } - ] - } - } - }, - { - "client_info": { - "mobilesdk_app_id": "1:448618578101:android:c017beb5f26b66fcac3efc", - "android_client_info": { - "package_name": "com.testapp" - } - }, - "oauth_client": [ - { - "client_id": "448618578101-q1ffje1ttluf8vfhi4aa50pag231q9dt.apps.googleusercontent.com", - "client_type": 1, - "android_info": { - "package_name": "com.testapp", - "certificate_hash": "909ca1482ef022bbae45a2db6b6d05d807a4c4aa" - } - }, - { - "client_id": "448618578101-sg12d2qin42cpr00f8b0gehs5s7inm0v.apps.googleusercontent.com", - "client_type": 3 - } - ], - "api_key": [ - { - "current_key": "AIzaSyCuu4tbv9CwwTudNOweMNstzZHIDBhgJxA" - } - ], - "services": { - "appinvite_service": { - "other_platform_oauth_client": [ - { - "client_id": "448618578101-sg12d2qin42cpr00f8b0gehs5s7inm0v.apps.googleusercontent.com", - "client_type": 3 - }, - { - "client_id": "448618578101-qqah55eossjuaa9np6ppo2l9fe3e7ohh.apps.googleusercontent.com", - "client_type": 2, - "ios_info": { - "bundle_id": "com.crashlytics.test" - } - } - ] - } - } - }, - { - "client_info": { - "mobilesdk_app_id": "1:448618578101:android:ad3f78043b0f1078ac3efc", - "android_client_info": { - "package_name": "crashlytics.v4" - } - }, - "oauth_client": [ - { - "client_id": "448618578101-sg12d2qin42cpr00f8b0gehs5s7inm0v.apps.googleusercontent.com", - "client_type": 3 - } - ], - "api_key": [ - { - "current_key": "AIzaSyCuu4tbv9CwwTudNOweMNstzZHIDBhgJxA" - } - ], - "services": { - "appinvite_service": { - "other_platform_oauth_client": [ - { - "client_id": "448618578101-sg12d2qin42cpr00f8b0gehs5s7inm0v.apps.googleusercontent.com", - "client_type": 3 - }, - { - "client_id": "448618578101-qqah55eossjuaa9np6ppo2l9fe3e7ohh.apps.googleusercontent.com", - "client_type": 2, - "ios_info": { - "bundle_id": "com.crashlytics.test" - } - } - ] - } - } - }, - { - "client_info": { - "mobilesdk_app_id": "1:448618578101:android:770b4d1c54259e4cac3efc", - "android_client_info": { - "package_name": "crashlytics.v5" - } - }, - "oauth_client": [ - { - "client_id": "448618578101-sg12d2qin42cpr00f8b0gehs5s7inm0v.apps.googleusercontent.com", - "client_type": 3 - } - ], - "api_key": [ - { - "current_key": "AIzaSyCuu4tbv9CwwTudNOweMNstzZHIDBhgJxA" - } - ], - "services": { - "appinvite_service": { - "other_platform_oauth_client": [ - { - "client_id": "448618578101-sg12d2qin42cpr00f8b0gehs5s7inm0v.apps.googleusercontent.com", - "client_type": 3 - }, - { - "client_id": "448618578101-qqah55eossjuaa9np6ppo2l9fe3e7ohh.apps.googleusercontent.com", - "client_type": 2, - "ios_info": { - "bundle_id": "com.crashlytics.test" - } - } - ] - } - } - }, - { - "client_info": { - "mobilesdk_app_id": "1:448618578101:android:349f77433954456eac3efc", - "android_client_info": { - "package_name": "crashlytics.v6" - } - }, - "oauth_client": [ - { - "client_id": "448618578101-sg12d2qin42cpr00f8b0gehs5s7inm0v.apps.googleusercontent.com", - "client_type": 3 - } - ], - "api_key": [ - { - "current_key": "AIzaSyCuu4tbv9CwwTudNOweMNstzZHIDBhgJxA" - } - ], - "services": { - "appinvite_service": { - "other_platform_oauth_client": [ - { - "client_id": "448618578101-sg12d2qin42cpr00f8b0gehs5s7inm0v.apps.googleusercontent.com", - "client_type": 3 - }, - { - "client_id": "448618578101-qqah55eossjuaa9np6ppo2l9fe3e7ohh.apps.googleusercontent.com", - "client_type": 2, - "ios_info": { - "bundle_id": "com.crashlytics.test" - } - } - ] - } - } - }, - { - "client_info": { - "mobilesdk_app_id": "1:448618578101:android:275b7c40f21f5a6dac3efc", - "android_client_info": { - "package_name": "crashlytics.v7" - } - }, - "oauth_client": [ - { - "client_id": "448618578101-sg12d2qin42cpr00f8b0gehs5s7inm0v.apps.googleusercontent.com", - "client_type": 3 - } - ], - "api_key": [ - { - "current_key": "AIzaSyCuu4tbv9CwwTudNOweMNstzZHIDBhgJxA" - } - ], - "services": { - "appinvite_service": { - "other_platform_oauth_client": [ - { - "client_id": "448618578101-sg12d2qin42cpr00f8b0gehs5s7inm0v.apps.googleusercontent.com", - "client_type": 3 - }, - { - "client_id": "448618578101-qqah55eossjuaa9np6ppo2l9fe3e7ohh.apps.googleusercontent.com", - "client_type": 2, - "ios_info": { - "bundle_id": "com.crashlytics.test" - } - } - ] - } - } - }, - { - "client_info": { - "mobilesdk_app_id": "1:448618578101:android:6bf0706c1f27114dac3efc", - "android_client_info": { - "package_name": "io.flutter.plugins.firebase.cloudfunctions.cloudfunctionsexample" - } - }, - "oauth_client": [ - { - "client_id": "448618578101-sg12d2qin42cpr00f8b0gehs5s7inm0v.apps.googleusercontent.com", - "client_type": 3 - } - ], - "api_key": [ - { - "current_key": "AIzaSyCuu4tbv9CwwTudNOweMNstzZHIDBhgJxA" - } - ], - "services": { - "appinvite_service": { - "other_platform_oauth_client": [ - { - "client_id": "448618578101-sg12d2qin42cpr00f8b0gehs5s7inm0v.apps.googleusercontent.com", - "client_type": 3 - }, - { - "client_id": "448618578101-qqah55eossjuaa9np6ppo2l9fe3e7ohh.apps.googleusercontent.com", - "client_type": 2, - "ios_info": { - "bundle_id": "com.crashlytics.test" - } - } - ] - } - } - }, - { - "client_info": { - "mobilesdk_app_id": "1:448618578101:android:5cc04a661d27c405ac3efc", - "android_client_info": { - "package_name": "io.flutter.plugins.firebase.crashlytics.firebasecrashlyticsexample" - } - }, - "oauth_client": [ - { - "client_id": "448618578101-sg12d2qin42cpr00f8b0gehs5s7inm0v.apps.googleusercontent.com", - "client_type": 3 - } - ], - "api_key": [ - { - "current_key": "AIzaSyCuu4tbv9CwwTudNOweMNstzZHIDBhgJxA" - } - ], - "services": { - "appinvite_service": { - "other_platform_oauth_client": [ - { - "client_id": "448618578101-sg12d2qin42cpr00f8b0gehs5s7inm0v.apps.googleusercontent.com", - "client_type": 3 - }, - { - "client_id": "448618578101-qqah55eossjuaa9np6ppo2l9fe3e7ohh.apps.googleusercontent.com", - "client_type": 2, - "ios_info": { - "bundle_id": "com.crashlytics.test" - } - } - ] - } - } - }, - { - "client_info": { - "mobilesdk_app_id": "1:448618578101:android:3ad281c0067ccf97ac3efc", - "android_client_info": { - "package_name": "io.flutter.plugins.firebase.firestoreexample" - } - }, - "oauth_client": [ - { - "client_id": "448618578101-npu5ll2fj4emgvtietpb685fvdm7fg3s.apps.googleusercontent.com", - "client_type": 1, - "android_info": { - "package_name": "io.flutter.plugins.firebase.firestoreexample", - "certificate_hash": "909ca1482ef022bbae45a2db6b6d05d807a4c4aa" - } - }, - { - "client_id": "448618578101-sg12d2qin42cpr00f8b0gehs5s7inm0v.apps.googleusercontent.com", - "client_type": 3 - } - ], - "api_key": [ - { - "current_key": "AIzaSyCuu4tbv9CwwTudNOweMNstzZHIDBhgJxA" - } - ], - "services": { - "appinvite_service": { - "other_platform_oauth_client": [ - { - "client_id": "448618578101-sg12d2qin42cpr00f8b0gehs5s7inm0v.apps.googleusercontent.com", - "client_type": 3 - }, - { - "client_id": "448618578101-qqah55eossjuaa9np6ppo2l9fe3e7ohh.apps.googleusercontent.com", - "client_type": 2, - "ios_info": { - "bundle_id": "com.crashlytics.test" - } - } - ] - } - } - }, - { - "client_info": { - "mobilesdk_app_id": "1:448618578101:android:0568e76dc62e89bcac3efc", - "android_client_info": { - "package_name": "io.flutter.plugins.firebase.messaging.example" - } - }, - "oauth_client": [ - { - "client_id": "448618578101-sg12d2qin42cpr00f8b0gehs5s7inm0v.apps.googleusercontent.com", - "client_type": 3 - } - ], - "api_key": [ - { - "current_key": "AIzaSyCuu4tbv9CwwTudNOweMNstzZHIDBhgJxA" - } - ], - "services": { - "appinvite_service": { - "other_platform_oauth_client": [ - { - "client_id": "448618578101-sg12d2qin42cpr00f8b0gehs5s7inm0v.apps.googleusercontent.com", - "client_type": 3 - }, - { - "client_id": "448618578101-qqah55eossjuaa9np6ppo2l9fe3e7ohh.apps.googleusercontent.com", - "client_type": 2, - "ios_info": { - "bundle_id": "com.crashlytics.test" - } - } - ] - } - } - }, - { - "client_info": { - "mobilesdk_app_id": "1:448618578101:android:9d44a7b85d1ab0baac3efc", - "android_client_info": { - "package_name": "io.flutter.plugins.firebaseauthexample" - } - }, - "oauth_client": [ - { - "client_id": "448618578101-qd7qb4i251kmq2ju79bl7sif96si0ve3.apps.googleusercontent.com", - "client_type": 1, - "android_info": { - "package_name": "io.flutter.plugins.firebaseauthexample", - "certificate_hash": "909ca1482ef022bbae45a2db6b6d05d807a4c4aa" - } - }, - { - "client_id": "448618578101-velutq65ok2dr5ohh0oi1q62irr920ss.apps.googleusercontent.com", - "client_type": 1, - "android_info": { - "package_name": "io.flutter.plugins.firebaseauthexample", - "certificate_hash": "29142b8612b4b6a0ba0fefd1dbf65ab565fb2cbd" - } - }, - { - "client_id": "448618578101-2brn4509s8513kjf9a0i6kvtb9qnght5.apps.googleusercontent.com", - "client_type": 1, - "android_info": { - "package_name": "io.flutter.plugins.firebaseauthexample", - "certificate_hash": "e1604565b51994d10886de1d91da9968dfec02ed" - } - }, - { - "client_id": "448618578101-2kqet2itdu42g0avs2v3fbsmtf6a45gg.apps.googleusercontent.com", - "client_type": 1, - "android_info": { - "package_name": "io.flutter.plugins.firebaseauthexample", - "certificate_hash": "939efbe8eaa5aaf50396b19fe980ef4a8df1c6e7" - } - }, - { - "client_id": "448618578101-sg12d2qin42cpr00f8b0gehs5s7inm0v.apps.googleusercontent.com", - "client_type": 3 - } - ], - "api_key": [ - { - "current_key": "AIzaSyCuu4tbv9CwwTudNOweMNstzZHIDBhgJxA" - } - ], - "services": { - "appinvite_service": { - "other_platform_oauth_client": [ - { - "client_id": "448618578101-sg12d2qin42cpr00f8b0gehs5s7inm0v.apps.googleusercontent.com", - "client_type": 3 - }, - { - "client_id": "448618578101-qqah55eossjuaa9np6ppo2l9fe3e7ohh.apps.googleusercontent.com", - "client_type": 2, - "ios_info": { - "bundle_id": "com.crashlytics.test" - } - } - ] - } - } - }, - { - "client_info": { - "mobilesdk_app_id": "1:448618578101:android:29bf96f913c195f5ac3efc", - "android_client_info": { - "package_name": "io.flutter.plugins.firebasecrashlyticsexample" - } - }, - "oauth_client": [ - { - "client_id": "448618578101-sg12d2qin42cpr00f8b0gehs5s7inm0v.apps.googleusercontent.com", - "client_type": 3 - } - ], - "api_key": [ - { - "current_key": "AIzaSyCuu4tbv9CwwTudNOweMNstzZHIDBhgJxA" - } - ], - "services": { - "appinvite_service": { - "other_platform_oauth_client": [ - { - "client_id": "448618578101-sg12d2qin42cpr00f8b0gehs5s7inm0v.apps.googleusercontent.com", - "client_type": 3 - }, - { - "client_id": "448618578101-qqah55eossjuaa9np6ppo2l9fe3e7ohh.apps.googleusercontent.com", - "client_type": 2, - "ios_info": { - "bundle_id": "com.crashlytics.test" - } - } - ] - } - } - }, - { - "client_info": { - "mobilesdk_app_id": "1:448618578101:android:d767a536227718bcac3efc", - "android_client_info": { - "package_name": "io.flutter.plugins.firebasemessagingexample" - } - }, - "oauth_client": [ - { - "client_id": "448618578101-rthm8sh42ifgn9vp60914nol7u8h7mgq.apps.googleusercontent.com", - "client_type": 1, - "android_info": { - "package_name": "io.flutter.plugins.firebasemessagingexample", - "certificate_hash": "29142b8612b4b6a0ba0fefd1dbf65ab565fb2cbd" - } - }, - { - "client_id": "448618578101-sg12d2qin42cpr00f8b0gehs5s7inm0v.apps.googleusercontent.com", - "client_type": 3 - } - ], - "api_key": [ - { - "current_key": "AIzaSyCuu4tbv9CwwTudNOweMNstzZHIDBhgJxA" - } - ], - "services": { - "appinvite_service": { - "other_platform_oauth_client": [ - { - "client_id": "448618578101-sg12d2qin42cpr00f8b0gehs5s7inm0v.apps.googleusercontent.com", - "client_type": 3 - }, - { - "client_id": "448618578101-qqah55eossjuaa9np6ppo2l9fe3e7ohh.apps.googleusercontent.com", - "client_type": 2, - "ios_info": { - "bundle_id": "com.crashlytics.test" - } - } - ] - } - } - }, - { - "client_info": { - "mobilesdk_app_id": "1:448618578101:android:553625b1be8cf2efac3efc", - "android_client_info": { - "package_name": "io.flutter.plugins.firebasestorageexample" - } - }, - "oauth_client": [ - { - "client_id": "448618578101-sg12d2qin42cpr00f8b0gehs5s7inm0v.apps.googleusercontent.com", - "client_type": 3 - } - ], - "api_key": [ - { - "current_key": "AIzaSyCuu4tbv9CwwTudNOweMNstzZHIDBhgJxA" - } - ], - "services": { - "appinvite_service": { - "other_platform_oauth_client": [ - { - "client_id": "448618578101-sg12d2qin42cpr00f8b0gehs5s7inm0v.apps.googleusercontent.com", - "client_type": 3 - }, - { - "client_id": "448618578101-qqah55eossjuaa9np6ppo2l9fe3e7ohh.apps.googleusercontent.com", - "client_type": 2, - "ios_info": { - "bundle_id": "com.crashlytics.test" - } - } - ] - } - } - }, - { - "client_info": { - "mobilesdk_app_id": "1:448618578101:android:670b9e77ba703236ac3efc", - "android_client_info": { - "package_name": "io.invertase.flutter.ui.auth.example" - } - }, - "oauth_client": [ - { - "client_id": "448618578101-vh59lklbaigpccaugknk3j0g1pp81kr2.apps.googleusercontent.com", - "client_type": 1, - "android_info": { - "package_name": "io.invertase.flutter.ui.auth.example", - "certificate_hash": "e1604565b51994d10886de1d91da9968dfec02ed" - } - }, - { - "client_id": "448618578101-sg12d2qin42cpr00f8b0gehs5s7inm0v.apps.googleusercontent.com", - "client_type": 3 - } - ], - "api_key": [ - { - "current_key": "AIzaSyCuu4tbv9CwwTudNOweMNstzZHIDBhgJxA" - } - ], - "services": { - "appinvite_service": { - "other_platform_oauth_client": [ - { - "client_id": "448618578101-sg12d2qin42cpr00f8b0gehs5s7inm0v.apps.googleusercontent.com", - "client_type": 3 - }, - { - "client_id": "448618578101-qqah55eossjuaa9np6ppo2l9fe3e7ohh.apps.googleusercontent.com", - "client_type": 2, - "ios_info": { - "bundle_id": "com.crashlytics.test" - } - } - ] - } - } - }, - { - "client_info": { - "mobilesdk_app_id": "1:448618578101:android:b90da4e868ff1aafac3efc", - "android_client_info": { - "package_name": "org.reactjs.native.example.rnfbTestApplication" - } - }, - "oauth_client": [ - { - "client_id": "448618578101-fft7llalbhpetiiuqg4uk19jfp0tfefe.apps.googleusercontent.com", - "client_type": 1, - "android_info": { - "package_name": "org.reactjs.native.example.rnfbTestApplication", - "certificate_hash": "909ca1482ef022bbae45a2db6b6d05d807a4c4aa" - } - }, - { - "client_id": "448618578101-sg12d2qin42cpr00f8b0gehs5s7inm0v.apps.googleusercontent.com", - "client_type": 3 - } - ], - "api_key": [ - { - "current_key": "AIzaSyCuu4tbv9CwwTudNOweMNstzZHIDBhgJxA" - } - ], - "services": { - "appinvite_service": { - "other_platform_oauth_client": [ - { - "client_id": "448618578101-sg12d2qin42cpr00f8b0gehs5s7inm0v.apps.googleusercontent.com", - "client_type": 3 - }, - { - "client_id": "448618578101-qqah55eossjuaa9np6ppo2l9fe3e7ohh.apps.googleusercontent.com", - "client_type": 2, - "ios_info": { - "bundle_id": "com.crashlytics.test" - } - } - ] - } - } - } - ], - "configuration_version": "1" -} \ No newline at end of file diff --git a/packages/firebase_messaging/firebase_messaging/example/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/packages/firebase_messaging/firebase_messaging/example/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata index 1d526a16ed0f..919434a6254f 100644 --- a/packages/firebase_messaging/firebase_messaging/example/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata +++ b/packages/firebase_messaging/firebase_messaging/example/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata @@ -2,6 +2,6 @@ + location = "self:"> diff --git a/packages/firebase_messaging/firebase_messaging/example/lib/firebase_config.dart b/packages/firebase_messaging/firebase_messaging/example/lib/firebase_config.dart new file mode 100644 index 000000000000..04d0a0b4b631 --- /dev/null +++ b/packages/firebase_messaging/firebase_messaging/example/lib/firebase_config.dart @@ -0,0 +1,46 @@ +import 'dart:io'; + +import 'package:firebase_core/firebase_core.dart'; +import 'package:flutter/foundation.dart'; + +class DefaultFirebaseConfig { + static FirebaseOptions get platformOptions { + if (kIsWeb) { + // Web + return const FirebaseOptions( + apiKey: 'AIzaSyAgUhHU8wSJgO5MVNy95tMT07NEjzMOfz0', + authDomain: 'react-native-firebase-testing.firebaseapp.com', + databaseURL: 'https://react-native-firebase-testing.firebaseio.com', + projectId: 'react-native-firebase-testing', + storageBucket: 'react-native-firebase-testing.appspot.com', + messagingSenderId: '448618578101', + appId: '1:448618578101:web:772d484dc9eb15e9ac3efc', + measurementId: 'G-0N1G9FLDZE', + ); + } else if (Platform.isIOS || Platform.isMacOS) { + // iOS and MacOS + return const FirebaseOptions( + apiKey: 'AIzaSyAHAsf51D0A407EklG1bs-5wA7EbyfNFg0', + appId: '1:448618578101:ios:0b11ed8263232715ac3efc', + messagingSenderId: '448618578101', + projectId: 'react-native-firebase-testing', + authDomain: 'react-native-firebase-testing.firebaseapp.com', + iosBundleId: 'io.flutter.plugins.firebase.messaging', + iosClientId: + '448618578101-evbjdqq9co9v29pi8jcua8bm7kr4smuu.apps.googleusercontent.com', + databaseURL: 'https://react-native-firebase-testing.firebaseio.com', + ); + } else { + // Android + return const FirebaseOptions( + appId: '1:448618578101:android:0568e76dc62e89bcac3efc', + apiKey: 'AIzaSyCuu4tbv9CwwTudNOweMNstzZHIDBhgJxA', + projectId: 'react-native-firebase-testing', + messagingSenderId: '448618578101', + authDomain: 'react-native-firebase-testing.firebaseapp.com', + androidClientId: + '448618578101-sg12d2qin42cpr00f8b0gehs5s7inm0v.apps.googleusercontent.com', + ); + } + } +} diff --git a/packages/firebase_messaging/firebase_messaging/example/lib/main.dart b/packages/firebase_messaging/firebase_messaging/example/lib/main.dart index 67ffaebee2cb..f0a45132a6be 100644 --- a/packages/firebase_messaging/firebase_messaging/example/lib/main.dart +++ b/packages/firebase_messaging/firebase_messaging/example/lib/main.dart @@ -1,4 +1,3 @@ -// ignore_for_file: require_trailing_commas // Copyright 2019 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -8,6 +7,7 @@ import 'dart:convert'; import 'package:firebase_core/firebase_core.dart'; import 'package:firebase_messaging/firebase_messaging.dart'; +import 'package:firebase_messaging_example/firebase_config.dart'; import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:http/http.dart' as http; @@ -25,13 +25,7 @@ import 'token_monitor.dart'; Future _firebaseMessagingBackgroundHandler(RemoteMessage message) async { // If you're going to use other Firebase services in the background, such as Firestore, // make sure you call `initializeApp` before using other Firebase services. - await Firebase.initializeApp( - options: const FirebaseOptions( - apiKey: 'AIzaSyAHAsf51D0A407EklG1bs-5wA7EbyfNFg0', - appId: '1:448618578101:ios:2bc5c1fe2ec336f8ac3efc', - messagingSenderId: '448618578101', - projectId: 'react-native-firebase-testing', - )); + await Firebase.initializeApp(options: DefaultFirebaseConfig.platformOptions); print('Handling a background message ${message.messageId}'); } @@ -44,12 +38,13 @@ late FlutterLocalNotificationsPlugin flutterLocalNotificationsPlugin; Future main() async { WidgetsFlutterBinding.ensureInitialized(); await Firebase.initializeApp( - options: const FirebaseOptions( - apiKey: 'AIzaSyAHAsf51D0A407EklG1bs-5wA7EbyfNFg0', - appId: '1:448618578101:ios:2bc5c1fe2ec336f8ac3efc', - messagingSenderId: '448618578101', - projectId: 'react-native-firebase-testing', - )); + options: const FirebaseOptions( + apiKey: 'AIzaSyAHAsf51D0A407EklG1bs-5wA7EbyfNFg0', + appId: '1:448618578101:ios:2bc5c1fe2ec336f8ac3efc', + messagingSenderId: '448618578101', + projectId: 'react-native-firebase-testing', + ), + ); // Set the background messaging handler early on, as a named top-level function FirebaseMessaging.onBackgroundMessage(_firebaseMessagingBackgroundHandler); @@ -136,8 +131,11 @@ class _Application extends State { .getInitialMessage() .then((RemoteMessage? message) { if (message != null) { - Navigator.pushNamed(context, '/message', - arguments: MessageArguments(message, true)); + Navigator.pushNamed( + context, + '/message', + arguments: MessageArguments(message, true), + ); } }); @@ -146,26 +144,30 @@ class _Application extends State { AndroidNotification? android = message.notification?.android; if (notification != null && android != null && !kIsWeb) { flutterLocalNotificationsPlugin.show( - notification.hashCode, - notification.title, - notification.body, - NotificationDetails( - android: AndroidNotificationDetails( - channel.id, - channel.name, - channel.description, - // TODO add a proper drawable resource to android, for now using - // one that already exists in example app. - icon: 'launch_background', - ), - )); + notification.hashCode, + notification.title, + notification.body, + NotificationDetails( + android: AndroidNotificationDetails( + channel.id, + channel.name, + channel.description, + // TODO add a proper drawable resource to android, for now using + // one that already exists in example app. + icon: 'launch_background', + ), + ), + ); } }); FirebaseMessaging.onMessageOpenedApp.listen((RemoteMessage message) { print('A new onMessageOpenedApp event was published!'); - Navigator.pushNamed(context, '/message', - arguments: MessageArguments(message, true)); + Navigator.pushNamed( + context, + '/message', + arguments: MessageArguments(message, true), + ); }); } @@ -194,19 +196,23 @@ class _Application extends State { case 'subscribe': { print( - 'FlutterFire Messaging Example: Subscribing to topic "fcm_test".'); + 'FlutterFire Messaging Example: Subscribing to topic "fcm_test".', + ); await FirebaseMessaging.instance.subscribeToTopic('fcm_test'); print( - 'FlutterFire Messaging Example: Subscribing to topic "fcm_test" successful.'); + 'FlutterFire Messaging Example: Subscribing to topic "fcm_test" successful.', + ); } break; case 'unsubscribe': { print( - 'FlutterFire Messaging Example: Unsubscribing from topic "fcm_test".'); + 'FlutterFire Messaging Example: Unsubscribing from topic "fcm_test".', + ); await FirebaseMessaging.instance.unsubscribeFromTopic('fcm_test'); print( - 'FlutterFire Messaging Example: Unsubscribing from topic "fcm_test" successful.'); + 'FlutterFire Messaging Example: Unsubscribing from topic "fcm_test" successful.', + ); } break; case 'get_apns_token': @@ -218,7 +224,8 @@ class _Application extends State { print('FlutterFire Messaging Example: Got APNs token: $token'); } else { print( - 'FlutterFire Messaging Example: Getting an APNs token is only supported on iOS and macOS platforms.'); + 'FlutterFire Messaging Example: Getting an APNs token is only supported on iOS and macOS platforms.', + ); } } break; @@ -262,16 +269,21 @@ class _Application extends State { ), ), body: SingleChildScrollView( - child: Column(children: [ - MetaCard('Permissions', Permissions()), - MetaCard('FCM Token', TokenMonitor((token) { - _token = token; - return token == null - ? const CircularProgressIndicator() - : Text(token, style: const TextStyle(fontSize: 12)); - })), - MetaCard('Message Stream', MessageList()), - ]), + child: Column( + children: [ + MetaCard('Permissions', Permissions()), + MetaCard( + 'FCM Token', + TokenMonitor((token) { + _token = token; + return token == null + ? const CircularProgressIndicator() + : Text(token, style: const TextStyle(fontSize: 12)); + }), + ), + MetaCard('Message Stream', MessageList()), + ], + ), ), ); } @@ -288,17 +300,22 @@ class MetaCard extends StatelessWidget { @override Widget build(BuildContext context) { return Container( - width: double.infinity, - margin: const EdgeInsets.only(left: 8, right: 8, top: 8), - child: Card( - child: Padding( - padding: const EdgeInsets.all(16), - child: Column(children: [ - Container( - margin: const EdgeInsets.only(bottom: 16), - child: - Text(_title, style: const TextStyle(fontSize: 18))), - _children, - ])))); + width: double.infinity, + margin: const EdgeInsets.only(left: 8, right: 8, top: 8), + child: Card( + child: Padding( + padding: const EdgeInsets.all(16), + child: Column( + children: [ + Container( + margin: const EdgeInsets.only(bottom: 16), + child: Text(_title, style: const TextStyle(fontSize: 18)), + ), + _children, + ], + ), + ), + ), + ); } } diff --git a/packages/firebase_messaging/firebase_messaging/example/macos/Runner.xcodeproj/project.pbxproj b/packages/firebase_messaging/firebase_messaging/example/macos/Runner.xcodeproj/project.pbxproj index 2c47fe8edf7d..97e562593971 100644 --- a/packages/firebase_messaging/firebase_messaging/example/macos/Runner.xcodeproj/project.pbxproj +++ b/packages/firebase_messaging/firebase_messaging/example/macos/Runner.xcodeproj/project.pbxproj @@ -26,12 +26,8 @@ 33CC10F32044A3C60003C045 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 33CC10F22044A3C60003C045 /* Assets.xcassets */; }; 33CC10F62044A3C60003C045 /* MainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = 33CC10F42044A3C60003C045 /* MainMenu.xib */; }; 33CC11132044BFA00003C045 /* MainFlutterWindow.swift in Sources */ = {isa = PBXBuildFile; fileRef = 33CC11122044BFA00003C045 /* MainFlutterWindow.swift */; }; - 33D1A10422148B71006C7A3E /* FlutterMacOS.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 33D1A10322148B71006C7A3E /* FlutterMacOS.framework */; }; - 33D1A10522148B93006C7A3E /* FlutterMacOS.framework in Bundle Framework */ = {isa = PBXBuildFile; fileRef = 33D1A10322148B71006C7A3E /* FlutterMacOS.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; B550B1FC23F53648007DADD5 /* GoogleService-Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = B550B1FB23F53648007DADD5 /* GoogleService-Info.plist */; }; B6036D992F5B77F0D48D7883 /* Pods_Runner.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1026236A547BC5196614E954 /* Pods_Runner.framework */; }; - D73912F022F37F9E000D13A0 /* App.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D73912EF22F37F9E000D13A0 /* App.framework */; }; - D73912F222F3801D000D13A0 /* App.framework in Bundle Framework */ = {isa = PBXBuildFile; fileRef = D73912EF22F37F9E000D13A0 /* App.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -51,8 +47,6 @@ dstPath = ""; dstSubfolderSpec = 10; files = ( - D73912F222F3801D000D13A0 /* App.framework in Bundle Framework */, - 33D1A10522148B93006C7A3E /* FlutterMacOS.framework in Bundle Framework */, ); name = "Bundle Framework"; runOnlyForDeploymentPostprocessing = 0; @@ -74,7 +68,6 @@ 33CEB47222A05771004F2AC0 /* Flutter-Debug.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = "Flutter-Debug.xcconfig"; sourceTree = ""; }; 33CEB47422A05771004F2AC0 /* Flutter-Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = "Flutter-Release.xcconfig"; sourceTree = ""; }; 33CEB47722A0578A004F2AC0 /* Flutter-Generated.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = "Flutter-Generated.xcconfig"; path = "ephemeral/Flutter-Generated.xcconfig"; sourceTree = ""; }; - 33D1A10322148B71006C7A3E /* FlutterMacOS.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = FlutterMacOS.framework; path = Flutter/ephemeral/FlutterMacOS.framework; sourceTree = SOURCE_ROOT; }; 33E51913231747F40026EE4D /* DebugProfile.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = DebugProfile.entitlements; sourceTree = ""; }; 33E51914231749380026EE4D /* Release.entitlements */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.entitlements; path = Release.entitlements; sourceTree = ""; }; 33E5194F232828860026EE4D /* AppInfo.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = AppInfo.xcconfig; sourceTree = ""; }; @@ -82,7 +75,6 @@ 7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = Release.xcconfig; sourceTree = ""; }; 9740EEB21CF90195004384FC /* Debug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = Debug.xcconfig; sourceTree = ""; }; B550B1FB23F53648007DADD5 /* GoogleService-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "GoogleService-Info.plist"; sourceTree = ""; }; - D73912EF22F37F9E000D13A0 /* App.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = App.framework; path = Flutter/ephemeral/App.framework; sourceTree = SOURCE_ROOT; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -90,8 +82,6 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( - D73912F022F37F9E000D13A0 /* App.framework in Frameworks */, - 33D1A10422148B71006C7A3E /* FlutterMacOS.framework in Frameworks */, B6036D992F5B77F0D48D7883 /* Pods_Runner.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; @@ -157,8 +147,6 @@ 33CEB47222A05771004F2AC0 /* Flutter-Debug.xcconfig */, 33CEB47422A05771004F2AC0 /* Flutter-Release.xcconfig */, 33CEB47722A0578A004F2AC0 /* Flutter-Generated.xcconfig */, - D73912EF22F37F9E000D13A0 /* App.framework */, - 33D1A10322148B71006C7A3E /* FlutterMacOS.framework */, ); path = Flutter; sourceTree = ""; @@ -284,7 +272,7 @@ ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "echo \"$PRODUCT_NAME.app\" > \"$PROJECT_DIR\"/Flutter/ephemeral/.app_filename\n"; + shellScript = "echo \"$PRODUCT_NAME.app\" > \"$PROJECT_DIR\"/Flutter/ephemeral/.app_filename && \"$FLUTTER_ROOT\"/packages/flutter_tools/bin/macos_assemble.sh embed\n"; }; 33CC111E2044C6BF0003C045 /* ShellScript */ = { isa = PBXShellScriptBuildPhase; @@ -333,10 +321,10 @@ buildActionMask = 2147483647; files = ( ); - inputFileListPaths = ( + inputPaths = ( ); name = "[CP] Embed Pods Frameworks"; - outputFileListPaths = ( + outputPaths = ( ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; diff --git a/packages/firebase_messaging/firebase_messaging/example/test_driver/firebase_config.dart b/packages/firebase_messaging/firebase_messaging/example/test_driver/firebase_config.dart new file mode 100644 index 000000000000..06e732005542 --- /dev/null +++ b/packages/firebase_messaging/firebase_messaging/example/test_driver/firebase_config.dart @@ -0,0 +1,46 @@ +import 'dart:io'; + +import 'package:firebase_core/firebase_core.dart'; +import 'package:flutter/foundation.dart'; + +class TestFirebaseConfig { + static FirebaseOptions get platformOptions { + if (kIsWeb) { + // Web + return const FirebaseOptions( + apiKey: 'AIzaSyAgUhHU8wSJgO5MVNy95tMT07NEjzMOfz0', + authDomain: 'react-native-firebase-testing.firebaseapp.com', + databaseURL: 'https://react-native-firebase-testing.firebaseio.com', + projectId: 'react-native-firebase-testing', + storageBucket: 'react-native-firebase-testing.appspot.com', + messagingSenderId: '448618578101', + appId: '1:448618578101:web:772d484dc9eb15e9ac3efc', + measurementId: 'G-0N1G9FLDZE', + ); + } else if (Platform.isIOS || Platform.isMacOS) { + // iOS and MacOS + return const FirebaseOptions( + apiKey: 'AIzaSyAHAsf51D0A407EklG1bs-5wA7EbyfNFg0', + appId: '1:448618578101:ios:0b11ed8263232715ac3efc', + messagingSenderId: '448618578101', + projectId: 'react-native-firebase-testing', + authDomain: 'react-native-firebase-testing.firebaseapp.com', + iosBundleId: 'io.flutter.plugins.firebase.messaging', + iosClientId: + '448618578101-evbjdqq9co9v29pi8jcua8bm7kr4smuu.apps.googleusercontent.com', + databaseURL: 'https://react-native-firebase-testing.firebaseio.com', + ); + } else { + // Android + return const FirebaseOptions( + appId: '1:448618578101:android:0568e76dc62e89bcac3efc', + apiKey: 'AIzaSyCuu4tbv9CwwTudNOweMNstzZHIDBhgJxA', + projectId: 'react-native-firebase-testing', + messagingSenderId: '448618578101', + authDomain: 'react-native-firebase-testing.firebaseapp.com', + androidClientId: + '448618578101-sg12d2qin42cpr00f8b0gehs5s7inm0v.apps.googleusercontent.com', + ); + } + } +} diff --git a/packages/firebase_messaging/firebase_messaging/example/test_driver/firebase_messaging_e2e.dart b/packages/firebase_messaging/firebase_messaging/example/test_driver/firebase_messaging_e2e.dart index 76fad6f41a54..cb362021fc74 100644 --- a/packages/firebase_messaging/firebase_messaging/example/test_driver/firebase_messaging_e2e.dart +++ b/packages/firebase_messaging/firebase_messaging/example/test_driver/firebase_messaging_e2e.dart @@ -1,15 +1,12 @@ -// ignore_for_file: require_trailing_commas - // Copyright 2020, the Chromium project authors. Please see the AUTHORS file // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. -// @dart=2.9 - import 'package:drive/drive.dart' as drive; import 'package:firebase_core/firebase_core.dart'; import 'package:flutter_test/flutter_test.dart'; +import 'firebase_config.dart'; import 'instance_e2e.dart'; // Requires that an emulator is running locally @@ -17,7 +14,7 @@ bool USE_EMULATOR = false; void testsMain() { setUpAll(() async { - await Firebase.initializeApp(); + await Firebase.initializeApp(options: TestFirebaseConfig.platformOptions); }); runInstanceTests(); diff --git a/packages/firebase_messaging/firebase_messaging/example/test_driver/firebase_messaging_e2e_test.dart b/packages/firebase_messaging/firebase_messaging/example/test_driver/firebase_messaging_e2e_test.dart index 4a676ab90551..f9c0fa99a519 100644 --- a/packages/firebase_messaging/firebase_messaging/example/test_driver/firebase_messaging_e2e_test.dart +++ b/packages/firebase_messaging/firebase_messaging/example/test_driver/firebase_messaging_e2e_test.dart @@ -1,11 +1,7 @@ -// ignore_for_file: require_trailing_commas - // Copyright 2020, the Chromium project authors. Please see the AUTHORS file // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. -// @dart=2.9 - import 'package:drive/drive_driver.dart' as drive; void main() => drive.main(); diff --git a/packages/firebase_messaging/firebase_messaging/example/test_driver/instance_e2e.dart b/packages/firebase_messaging/firebase_messaging/example/test_driver/instance_e2e.dart index 23c22b2aa192..232fbda15aed 100644 --- a/packages/firebase_messaging/firebase_messaging/example/test_driver/instance_e2e.dart +++ b/packages/firebase_messaging/firebase_messaging/example/test_driver/instance_e2e.dart @@ -1,4 +1,3 @@ -// ignore_for_file: require_trailing_commas // Copyright 2020, the Chromium project authors. Please see the AUTHORS file // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. @@ -62,11 +61,15 @@ void runInstanceTests() { }); group('setAutoInitEnabled()', () { - test('sets the value', () async { - expect(messaging.isAutoInitEnabled, isTrue); - await messaging.setAutoInitEnabled(false); - expect(messaging.isAutoInitEnabled, isFalse); - }, skip: kIsWeb); + test( + 'sets the value', + () async { + expect(messaging.isAutoInitEnabled, isTrue); + await messaging.setAutoInitEnabled(false); + expect(messaging.isAutoInitEnabled, isFalse); + }, + skip: kIsWeb, + ); }); group('isSupported()', () { @@ -77,34 +80,45 @@ void runInstanceTests() { group('requestPermission', () { test( - 'authorizationStatus returns AuthorizationStatus.authorized on Android', - () async { - final result = await messaging.requestPermission(); - expect(result, isA()); - expect(result.authorizationStatus, AuthorizationStatus.authorized); - }, skip: defaultTargetPlatform != TargetPlatform.android || kIsWeb); + 'authorizationStatus returns AuthorizationStatus.authorized on Android', + () async { + final result = await messaging.requestPermission(); + expect(result, isA()); + expect(result.authorizationStatus, AuthorizationStatus.authorized); + }, + skip: defaultTargetPlatform != TargetPlatform.android || kIsWeb, + ); }); group('requestPermission', () { test( - 'authorizationStatus returns AuthorizationStatus.notDetermined on Web', - () async { - final result = await messaging.requestPermission(); - expect(result, isA()); - expect(result.authorizationStatus, AuthorizationStatus.notDetermined); - }, skip: !kIsWeb); + 'authorizationStatus returns AuthorizationStatus.notDetermined on Web', + () async { + final result = await messaging.requestPermission(); + expect(result, isA()); + expect(result.authorizationStatus, AuthorizationStatus.notDetermined); + }, + skip: !kIsWeb, + ); }); group('getAPNSToken', () { - test('resolves null on android', () async { - expect(await messaging.getAPNSToken(), null); - }, skip: defaultTargetPlatform != TargetPlatform.android); + test( + 'resolves null on android', + () async { + expect(await messaging.getAPNSToken(), null); + }, + skip: defaultTargetPlatform != TargetPlatform.android, + ); - test('resolves null on ios if using simulator', () async { - expect(await messaging.getAPNSToken(), null); - }, - skip: !(defaultTargetPlatform == TargetPlatform.iOS || - defaultTargetPlatform != TargetPlatform.macOS)); + test( + 'resolves null on ios if using simulator', + () async { + expect(await messaging.getAPNSToken(), null); + }, + skip: !(defaultTargetPlatform == TargetPlatform.iOS || + defaultTargetPlatform != TargetPlatform.macOS), + ); }); group('getInitialMessage', () { @@ -113,36 +127,52 @@ void runInstanceTests() { }); }); - group('getToken()', () { - test('returns a token', () async { - final result = await messaging.getToken(); - expect(result, isA()); - }); - }, skip: SKIP_MANUAL_TESTS); // only run for manual testing + group( + 'getToken()', + () { + test('returns a token', () async { + final result = await messaging.getToken(); + expect(result, isA()); + }); + }, + skip: SKIP_MANUAL_TESTS, + ); // only run for manual testing group('deleteToken()', () { - test('generate a new token after deleting', () async { - final token1 = await messaging.getToken(); - await messaging.deleteToken(); - final token2 = await messaging.getToken(); - expect(token1, isA()); - expect(token2, isA()); - expect(token1, isNot(token2)); - }, skip: SKIP_MANUAL_TESTS); // only run for manual testing + test( + 'generate a new token after deleting', + () async { + final token1 = await messaging.getToken(); + await messaging.deleteToken(); + final token2 = await messaging.getToken(); + expect(token1, isA()); + expect(token2, isA()); + expect(token1, isNot(token2)); + }, + skip: SKIP_MANUAL_TESTS, + ); // only run for manual testing }); group('subscribeToTopic()', () { - test('successfully subscribes from topic', () async { - const topic = 'test-topic'; - await messaging.subscribeToTopic(topic); - }, skip: kIsWeb); + test( + 'successfully subscribes from topic', + () async { + const topic = 'test-topic'; + await messaging.subscribeToTopic(topic); + }, + skip: kIsWeb, + ); }); group('unsubscribeFromTopic()', () { - test('successfully unsubscribes from topic', () async { - const topic = 'test-topic'; - await messaging.unsubscribeFromTopic(topic); - }, skip: kIsWeb); + test( + 'successfully unsubscribes from topic', + () async { + const topic = 'test-topic'; + await messaging.unsubscribeFromTopic(topic); + }, + skip: kIsWeb, + ); }); }); } diff --git a/packages/firebase_messaging/firebase_messaging/example/test_driver/test_utils.dart b/packages/firebase_messaging/firebase_messaging/example/test_driver/test_utils.dart index b832ae549e7a..79e69a1a60de 100644 --- a/packages/firebase_messaging/firebase_messaging/example/test_driver/test_utils.dart +++ b/packages/firebase_messaging/firebase_messaging/example/test_driver/test_utils.dart @@ -1,11 +1,7 @@ -// ignore_for_file: require_trailing_commas - // Copyright 2020, the Chromium project authors. Please see the AUTHORS file // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. -// @dart=2.9 - import 'package:firebase_core/firebase_core.dart'; import 'dart:io'; diff --git a/packages/firebase_messaging/firebase_messaging/example/web/index.html b/packages/firebase_messaging/firebase_messaging/example/web/index.html index 672c11c263f3..9e5fad756bd2 100644 --- a/packages/firebase_messaging/firebase_messaging/example/web/index.html +++ b/packages/firebase_messaging/firebase_messaging/example/web/index.html @@ -43,7 +43,7 @@ // Service workers are supported. Use them. window.addEventListener('load', function () { //register firebase-messaging service worker - navigator.serviceWorker.register("/firebase-messaging-sw.js"); + // navigator.serviceWorker.register("/firebase-messaging-sw.js"); // Wait for registration to finish before dropping the