Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(core): update to firebase_core-v2.21.0 #11

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.21.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.21.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.21.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.21.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',
cppHeaderOut: 'tizen/src/messages.g.h',
cppSourceOut: 'tizen/src/messages.g.cc',
cppOptions: CppOptions(namespace: 'firebase_core_tizen'),
copyrightHeader: 'pigeons/copyright.txt',
),
)
Expand Down
7 changes: 3 additions & 4 deletions packages/firebase_core/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,24 +1,23 @@
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_platform_interface: ^5.0.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
101 changes: 53 additions & 48 deletions packages/firebase_core/tizen/src/firebase_core_tizen_plugin.cc
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@
#include <string>

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

using namespace firebase_core_tizen;
using ::firebase::App;

namespace {

Expand Down Expand Up @@ -69,46 +72,52 @@ FirebaseCoreTizenPlugin::FirebaseCoreTizenPlugin(

FirebaseCoreTizenPlugin::~FirebaseCoreTizenPlugin() {}

static PigeonFirebaseOptions FirebaseOptionsToPigeonOptions(
const firebase::AppOptions& options) {
PigeonFirebaseOptions pigeon_options;
// Convert a Pigeon FirebaseOptions to a Firebase Options.
firebase::AppOptions PigeonFirebaseOptionsToAppOptions(
const PigeonFirebaseOptions& pigeon_options) {
firebase::AppOptions options;
options.set_api_key(pigeon_options.api_key().c_str());
options.set_app_id(pigeon_options.app_id().c_str());
if (pigeon_options.database_u_r_l() != nullptr) {
options.set_database_url(pigeon_options.database_u_r_l()->c_str());
}
if (pigeon_options.tracking_id() != nullptr) {
options.set_ga_tracking_id(pigeon_options.tracking_id()->c_str());
}
options.set_messaging_sender_id(pigeon_options.messaging_sender_id().c_str());

options.set_project_id(pigeon_options.project_id().c_str());

if (pigeon_options.storage_bucket() != nullptr) {
options.set_storage_bucket(pigeon_options.storage_bucket()->c_str());
}
return options;
}

// Convert a AppOptions to PigeonInitializeOption
PigeonFirebaseOptions optionsFromFIROptions(
const firebase::AppOptions& options) {
PigeonFirebaseOptions pigeon_options = PigeonFirebaseOptions();
pigeon_options.set_api_key(options.api_key());
pigeon_options.set_app_id(options.app_id());
pigeon_options.set_messaging_sender_id(options.messaging_sender_id());
pigeon_options.set_project_id(options.project_id());
if (strlen(options.database_url()) > 0) {
if (options.database_url() != nullptr) {
pigeon_options.set_database_u_r_l(options.database_url());
}
if (strlen(options.storage_bucket()) > 0) {
pigeon_options.set_tracking_id(nullptr);
pigeon_options.set_messaging_sender_id(options.messaging_sender_id());
pigeon_options.set_project_id(options.project_id());
if (options.storage_bucket() != nullptr) {
pigeon_options.set_storage_bucket(options.storage_bucket());
}
if (strlen(options.ga_tracking_id()) > 0) {
pigeon_options.set_tracking_id(options.ga_tracking_id());
}

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 +127,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
Loading
Loading