Skip to content

Commit

Permalink
feat(core): update to firebase_core-v2.17.0
Browse files Browse the repository at this point in the history
Signed-off-by: Hosung Kim [email protected]
  • Loading branch information
hs0225 committed Nov 8, 2023
1 parent 557c0b0 commit abf4129
Show file tree
Hide file tree
Showing 16 changed files with 870 additions and 1,269 deletions.
4 changes: 2 additions & 2 deletions packages/cloud_functions/example/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ dependencies:
cloud_functions: 4.0.7
cloud_functions_tizen:
path: ..
firebase_core: 2.4.1
firebase_core_tizen: ^1.0.0
firebase_core: ^2.17.0
firebase_core_tizen: ^1.0.1
flutter:
sdk: flutter

Expand Down
2 changes: 1 addition & 1 deletion packages/cloud_functions/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ environment:
dependencies:
cloud_functions: 4.0.7
cloud_functions_platform_interface: 5.1.26
firebase_core_tizen: ^1.0.0
firebase_core_tizen: ^1.0.1
flutter:
sdk: flutter

Expand Down
4 changes: 4 additions & 0 deletions packages/firebase_core/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 1.0.1

* Update firebase_core to 2.17.0.

## 1.0.0

* Initial release.
4 changes: 2 additions & 2 deletions packages/firebase_core/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ To use this package, you need to include `firebase_core_tizen` as a dependency a

```yaml
dependencies:
firebase_core: 2.4.1
firebase_core_tizen: ^1.0.0
firebase_core: ^2.17.0
firebase_core_tizen: ^1.0.1
```
Then you can import `firebase_core` in your Dart code:
Expand Down
2 changes: 1 addition & 1 deletion packages/firebase_core/example/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ environment:
flutter: ">=3.3.0"

dependencies:
firebase_core: 2.4.1
firebase_core: ^2.17.0
firebase_core_tizen:
path: ../
flutter:
Expand Down
7 changes: 4 additions & 3 deletions packages/firebase_core/pigeons/messages.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@ import 'package:pigeon/pigeon.dart';

@ConfigurePigeon(
PigeonOptions(
dartOut: 'temp/messages.g.dart', // do not use it
cppHeaderOut: 'tizen/src/messages.h',
cppSourceOut: 'tizen/src/messages.cc',
dartOut: 'temp/messages.pigeon.dart', // do not use it
cppHeaderOut: 'tizen/src/messages.g.h',
cppSourceOut: 'tizen/src/messages.g.cc',
cppOptions: CppOptions(namespace: 'firebase_core_tizen'),
copyrightHeader: 'pigeons/copyright.txt',
),
)
Expand Down
8 changes: 4 additions & 4 deletions packages/firebase_core/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
name: firebase_core_tizen
description: Flutter plugin for Firebase Core, enabling connecting to multiple
Firebase apps.
version: 1.0.0
version: 1.0.1
homepage:

environment:
sdk: ">=2.18.0 <4.0.0"
flutter: ">=3.3.0"

dependencies:
firebase_core: 2.4.1
firebase_core_platform_interface: 4.5.2
firebase_core: ^2.17.0
firebase_core_platform_interface: ^4.8.0
flutter:
sdk: flutter

dev_dependencies:
flutter_lints: ^2.0.0
flutter_test:
sdk: flutter
pigeon: ^3.2.9
pigeon: 9.2.5

flutter:
plugin:
Expand Down
91 changes: 50 additions & 41 deletions packages/firebase_core/tizen/src/firebase_core_tizen_plugin.cc
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,11 @@
#include <string>

#include "log.h"
#include "messages.h"
#include "messages.g.h"

namespace {
using ::firebase::App;

namespace firebase_core_tizen {

class FirebaseCoreTizenPlugin : public flutter::Plugin,
public FirebaseCoreHostApi,
Expand Down Expand Up @@ -69,7 +71,31 @@ FirebaseCoreTizenPlugin::FirebaseCoreTizenPlugin(

FirebaseCoreTizenPlugin::~FirebaseCoreTizenPlugin() {}

static PigeonFirebaseOptions FirebaseOptionsToPigeonOptions(
// Convert a Pigeon FirebaseOptions to a Firebase Options.
firebase::AppOptions PigeonFirebaseOptionsToAppOptions(
const PigeonFirebaseOptions& pigeon_options) {
firebase::AppOptions app_options;

app_options.set_api_key(pigeon_options.api_key().c_str());
app_options.set_app_id(pigeon_options.app_id().c_str());
app_options.set_messaging_sender_id(
pigeon_options.messaging_sender_id().c_str());
app_options.set_project_id(pigeon_options.project_id().c_str());
if (pigeon_options.database_u_r_l()) {
app_options.set_database_url(pigeon_options.database_u_r_l()->c_str());
}
if (pigeon_options.storage_bucket()) {
app_options.set_storage_bucket(pigeon_options.storage_bucket()->c_str());
}
if (pigeon_options.tracking_id()) {
app_options.set_ga_tracking_id(pigeon_options.tracking_id()->c_str());
}

return app_options;
}

// Convert a AppOptions to PigeonInitializeOption
PigeonFirebaseOptions OptionsFromFIROptions(
const firebase::AppOptions& options) {
PigeonFirebaseOptions pigeon_options;

Expand All @@ -90,25 +116,12 @@ static PigeonFirebaseOptions FirebaseOptionsToPigeonOptions(
return pigeon_options;
}

static firebase::AppOptions PigeonOptionsToFirebaseOptions(
const PigeonFirebaseOptions& options) {
firebase::AppOptions app_options;

app_options.set_api_key(options.api_key().c_str());
app_options.set_app_id(options.app_id().c_str());
app_options.set_messaging_sender_id(options.messaging_sender_id().c_str());
app_options.set_project_id(options.project_id().c_str());
if (options.database_u_r_l()) {
app_options.set_database_url(options.database_u_r_l()->c_str());
}
if (options.storage_bucket()) {
app_options.set_storage_bucket(options.storage_bucket()->c_str());
}
if (options.tracking_id()) {
app_options.set_ga_tracking_id(options.tracking_id()->c_str());
}

return app_options;
// Convert a firebase::App to PigeonInitializeResponse
PigeonInitializeResponse AppToPigeonInitializeResponse(const App& app) {
PigeonInitializeResponse response = PigeonInitializeResponse();
response.set_name(app.name());
response.set_options(OptionsFromFIROptions(app.options()));
return response;
}

void FirebaseCoreTizenPlugin::InitializeApp(
Expand All @@ -118,33 +131,29 @@ void FirebaseCoreTizenPlugin::InitializeApp(
firebase::App* app = firebase::App::GetInstance(app_name.c_str());
if (!app) {
app = firebase::App::Create(
PigeonOptionsToFirebaseOptions(initialize_app_request),
PigeonFirebaseOptionsToAppOptions(initialize_app_request),
app_name.c_str());
}

PigeonInitializeResponse message_response;
message_response.set_name(app->name());
message_response.set_options(FirebaseOptionsToPigeonOptions(app->options()));

result(message_response);
// Send back the result to Flutter
result(AppToPigeonInitializeResponse(*app));
}

void FirebaseCoreTizenPlugin::InitializeCore(
std::function<void(ErrorOr<flutter::EncodableList> reply)> result) {
flutter::EncodableList response;
// TODO: Missing function to get the list of currently initialized apps
std::vector<PigeonInitializeResponse> initializedApps;
std::vector<App*> all_apps = App::GetApps();
for (const App* app : all_apps) {
initializedApps.push_back(AppToPigeonInitializeResponse(*app));
}

std::vector<firebase::App*> firebase_apps = firebase::App::GetApps();
for (auto app : firebase_apps) {
PigeonInitializeResponse message_response;
message_response.set_name(app->name());
message_response.set_options(
FirebaseOptionsToPigeonOptions(app->options()));
flutter::EncodableList encodableList;

response.push_back(
flutter::EncodableValue(message_response.ToEncodableMap()));
for (const auto& item : initializedApps) {
encodableList.push_back(flutter::CustomEncodableValue(item));
}

result(response);
result(encodableList);
}

void FirebaseCoreTizenPlugin::OptionsFromResource(
Expand Down Expand Up @@ -177,11 +186,11 @@ void FirebaseCoreTizenPlugin::Delete(
result(std::nullopt);
}

} // namespace
} // namespace firebase_core_tizen

void FirebaseCoreTizenPluginRegisterWithRegistrar(
FlutterDesktopPluginRegistrarRef registrar) {
FirebaseCoreTizenPlugin::RegisterWithRegistrar(
firebase_core_tizen::FirebaseCoreTizenPlugin::RegisterWithRegistrar(
flutter::PluginRegistrarManager::GetInstance()
->GetRegistrar<flutter::PluginRegistrar>(registrar));
}
Loading

0 comments on commit abf4129

Please sign in to comment.