Skip to content

Commit

Permalink
[firebase_functions] Add Firebase Cloud Functions plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
wiertel committed Dec 27, 2022
1 parent 81a670c commit ed98e4a
Show file tree
Hide file tree
Showing 19 changed files with 484 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .github/labeler.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
- packages/device_info_plus/**/*
"p: firebase_core":
- packages/firebase_core/**/*
"p: firebase_functions":
- packages/firebase_functions/**/*
"p: flutter_app_badger":
- packages/flutter_app_badger/**/*
"p: flutter_secure_storage":
Expand Down
1 change: 1 addition & 0 deletions .github/recipe.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ plugins:
google_sign_in: []
image_picker: []
firebase_core: []
firebase_functions: []
tizen_log: []
tizen_notification: []
wearable_rotary: []
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ The _"non-endorsed"_ status means that the plugin is not endorsed by the origina
| [**connectivity_plus_tizen**](packages/connectivity_plus) | [connectivity_plus](https://github.com/fluttercommunity/plus_plugins/tree/main/packages/connectivity_plus) (1st-party) | [![pub package](https://img.shields.io/pub/v/connectivity_plus_tizen.svg)](https://pub.dev/packages/connectivity_plus_tizen) | No |
| [**device_info_plus_tizen**](packages/device_info_plus) | [device_info_plus](https://github.com/fluttercommunity/plus_plugins/tree/main/packages/device_info_plus) (1st-party) | [![pub package](https://img.shields.io/pub/v/device_info_plus_tizen.svg)](https://pub.dev/packages/device_info_plus_tizen) | No |
| [**firebase_core_tizen**](packages/firebase_core) | [firebase_core](https://github.com/firebase/flutterfire/tree/master/packages/firebase_core) | [![pub package](https://img.shields.io/pub/v/firebase_core_tizen.svg)](https://pub.dev/packages/firebase_core_tizen) | No |
| [**firebase_functions_tizen**](packages/firebase_functions) | [firebase_functions](https://github.com/firebase/flutterfire/tree/master/packages/cloud_functions) | [![pub package](https://img.shields.io/pub/v/firebase_functions_tizen.svg)](https://pub.dev/packages/firebase_functions_tizen) | No |
| [**flutter_app_badger_tizen**](packages/flutter_app_badger) | [flutter_app_badger](https://github.com/g123k/flutter_app_badger) (3rd-party) | [![pub package](https://img.shields.io/pub/v/flutter_app_badger_tizen.svg)](https://pub.dev/packages/flutter_app_badger_tizen) | No |
| [**flutter_secure_storage_tizen**](packages/flutter_secure_storage) | [flutter_secure_storage](https://github.com/mogol/flutter_secure_storage) (3rd-party) | [![pub package](https://img.shields.io/pub/v/flutter_secure_storage_tizen.svg)](https://pub.dev/packages/flutter_secure_storage_tizen) | No |
| [**flutter_tts_tizen**](packages/flutter_tts) | [flutter_tts](https://github.com/dlutton/flutter_tts) (3rd-party) | [![pub package](https://img.shields.io/pub/v/flutter_tts_tizen.svg)](https://pub.dev/packages/flutter_tts_tizen) | No |
Expand Down Expand Up @@ -61,6 +62,7 @@ The _"non-endorsed"_ status means that the plugin is not endorsed by the origina
| [**connectivity_plus_tizen**](packages/connectivity_plus) | 4.0 | ✔️ | ⚠️ | ✔️ | ✔️ | Returns incorrect connection status |
| [**device_info_plus_tizen**](packages/device_info_plus) | 4.0 | ✔️ | ✔️ | ✔️ | ✔️ |
| [**firebase_core**](packages/firebase_core) | 4.0 | ✔️ | ✔️ | ✔️ | ✔️ |
| [**firebase_functions**](packages/firebase_functions) | 4.0 | ✔️ | ✔️ | ✔️ | ✔️ |
| [**flutter_app_badger_tizen**](packages/flutter_app_badger) | 4.0 | ✔️ | ✔️ ||| API not supported |
| [**flutter_secure_storage_tizen**](packages/flutter_secure_storage) | 4.0 | ✔️ | ✔️ | ✔️ | ✔️ |
| [**flutter_tts_tizen**](packages/flutter_tts) | 4.0 | ✔️ | ✔️ | ✔️ | ✔️ |
Expand Down
30 changes: 30 additions & 0 deletions packages/firebase_functions/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Miscellaneous
*.class
*.log
*.pyc
*.swp
.DS_Store
.atom/
.buildlog/
.history
.svn/
migrate_working_dir/

# IntelliJ related
*.iml
*.ipr
*.iws
.idea/

# The .vscode folder contains launch configuration and tasks you configure in
# VS Code which you may wish to be included in version control, so this line
# is commented out by default.
#.vscode/

# Flutter/Dart/Pub related
# Libraries should not include pubspec.lock, per https://dart.dev/guides/libraries/private-files#pubspeclock.
/pubspec.lock
**/doc/api/
.dart_tool/
.packages
build/
3 changes: 3 additions & 0 deletions packages/firebase_functions/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
## 0.1.0

* Initial release.
29 changes: 29 additions & 0 deletions packages/firebase_functions/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
BSD-3-Clause
------------

Copyright (c) 2016-present Invertase Limited <[email protected]> & Contributors

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.

2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.


Creative Commons Attribution 3.0 License
----------------------------------------

Copyright (c) 2016-present Invertase Limited <[email protected]> & Contributors

Documentation and other instructional materials provided for this project
(including on a separate documentation repository or it's documentation website) are
licensed under the Creative Commons Attribution 3.0 License. Code samples/blocks
contained therein are licensed under the BSD-3-Clause License (the "License"), as above.

You may obtain a copy of the Creative Commons Attribution 3.0 License at

https://creativecommons.org/licenses/by/3.0/
18 changes: 18 additions & 0 deletions packages/firebase_functions/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# firebase_functions_tizen

A new Flutter plugin project.

## Getting Started

This project is a starting point for a Flutter
[plug-in package](https://flutter.dev/developing-packages/),
a specialized package that includes platform-specific implementation code for
Android and/or iOS.

For help getting started with Flutter development, view the
[online documentation](https://flutter.dev/docs), which offers tutorials,
samples, guidance on mobile development, and a full API reference.

The plugin project was generated without specifying the `--platforms` flag, no platforms are currently supported.
To add platforms, run `flutter create -t plugin --platforms <platforms> .` in this directory.
You can also find a detailed instruction on how to add platforms in the `pubspec.yaml` at https://flutter.dev/docs/development/packages-and-plugins/developing-packages#plugin-platforms.
46 changes: 46 additions & 0 deletions packages/firebase_functions/example/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# Miscellaneous
*.class
*.log
*.pyc
*.swp
.DS_Store
.atom/
.buildlog/
.history
.svn/

# IntelliJ related
*.iml
*.ipr
*.iws
.idea/

# The .vscode folder contains launch configuration and tasks you configure in
# VS Code which you may wish to be included in version control, so this line
# is commented out by default.
#.vscode/

# Flutter/Dart/Pub related
**/doc/api/
**/ios/Flutter/.last_build_id
.dart_tool/
.flutter-plugins
.flutter-plugins-dependencies
.packages
.pub-cache/
.pub/
/build/

# Web related
lib/generated_plugin_registrant.dart

# Symbolication related
app.*.symbols

# Obfuscation related
app.*.map.json

# Android Studio will place build artifacts here
/android/app/debug
/android/app/profile
/android/app/release
16 changes: 16 additions & 0 deletions packages/firebase_functions/example/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# example

A new Flutter project.

## Getting Started

This project is a starting point for a Flutter application.

A few resources to get you started if this is your first Flutter project:

- [Lab: Write your first Flutter app](https://flutter.dev/docs/get-started/codelab)
- [Cookbook: Useful Flutter samples](https://flutter.dev/docs/cookbook)

For help getting started with Flutter, view our
[online documentation](https://flutter.dev/docs), which offers tutorials,
samples, guidance on mobile development, and a full API reference.
93 changes: 93 additions & 0 deletions packages/firebase_functions/example/lib/main.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
// ignore_for_file: require_trailing_commas, public_member_api_docs, library_private_types_in_public_api
// 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.

import 'dart:core';

import 'package:cloud_functions/cloud_functions.dart';
import 'package:firebase_core/firebase_core.dart';
import 'package:flutter/material.dart';

FirebaseOptions get firebaseOptions => 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',
);

late FirebaseFunctions functions;

Future<void> main() async {
WidgetsFlutterBinding.ensureInitialized();
await Firebase.initializeApp(options: firebaseOptions);
functions = FirebaseFunctions.instance
..useFunctionsEmulator('localhost', 5001);
runApp(MyApp());
}

class MyApp extends StatefulWidget {
MyApp({Key? key}) : super(key: key);
@override
_MyAppState createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
List fruit = [];

@override
void initState() {
super.initState();
}

@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: const Text('Firebase Functions Example'),
),
body: Center(
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
// are using for this example
final callable = functions.httpsCallable('listFruit',
options: HttpsCallableOptions(
timeout: const Duration(seconds: 5)));

await callable().then((v) {
setState(() {
fruit.clear();
// ignore: avoid_dynamic_calls
v.data.forEach((f) {
fruit.add(f);
});
});
}).catchError((e) {
ScaffoldMessenger.of(context).showSnackBar(SnackBar(
content: Text('ERROR: $e'),
));
});
},
label: const Text('Call Function'),
icon: const Icon(Icons.cloud),
backgroundColor: Colors.deepOrange,
),
),
),
);
}
}
21 changes: 21 additions & 0 deletions packages/firebase_functions/example/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: firebase_functions_tizen_example
description: An example application demonstrating calls to Firebase Functions.
publish_to: 'none' # Remove this line if you wish to publish to pub.dev

version: 1.0.0

environment:
sdk: ">=2.12.0 <3.0.0"

dependencies:
cloud_functions:
firebase_core:
firebase_core_tizen:
path: ../../firebase_core
firebase_functions_tizen:
path: ../
flutter:
sdk: flutter

flutter:
uses-material-design: true
5 changes: 5 additions & 0 deletions packages/firebase_functions/example/tizen/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
flutter/
.vs/
*.user
bin/
obj/
20 changes: 20 additions & 0 deletions packages/firebase_functions/example/tizen/App.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
using Tizen.Flutter.Embedding;

namespace Runner
{
public class App : FlutterApplication
{
protected override void OnCreate()
{
base.OnCreate();

GeneratedPluginRegistrant.RegisterPlugins(this);
}

static void Main(string[] args)
{
var app = new App();
app.Run(args);
}
}
}
19 changes: 19 additions & 0 deletions packages/firebase_functions/example/tizen/Runner.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<Project Sdk="Tizen.NET.Sdk/1.1.7">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>tizen40</TargetFramework>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="$(FlutterEmbeddingPath)" />
</ItemGroup>

<ItemGroup>
<FlutterEphemeral Include="flutter\ephemeral\**\*" />
<TizenTpkUserIncludeFiles Include="@(FlutterEphemeral)">
<TizenTpkSubDir>%(RecursiveDir)</TizenTpkSubDir>
</TizenTpkUserIncludeFiles>
</ItemGroup>

</Project>
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
16 changes: 16 additions & 0 deletions packages/firebase_functions/example/tizen/tizen-manifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest package="org.tizen.firebase_functions_tizen_example" version="1.0.0" api-version="4.0" xmlns="http://tizen.org/ns/packages">
<profile name="common"/>
<ui-application appid="org.tizen.firebase_functions_tizen_example" exec="Runner.dll" type="dotnet" multiple="false" nodisplay="false" taskmanage="true">
<label>firebase_functions_tizen_example</label>
<icon>ic_launcher.png</icon>
<metadata key="http://tizen.org/metadata/prefer_dotnet_aot" value="true"/>
</ui-application>
<tv-info api-version="8.8.0">
<infolink>T-INFOLINK2021-1000</infolink>
</tv-info>
<feature name="http://tizen.org/feature/screen.size.all"/>
<privileges>
<privilege>http://tizen.org/privilege/internet</privilege>
</privileges>
</manifest>
23 changes: 23 additions & 0 deletions packages/firebase_functions/lib/desktop_utils.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// ignore_for_file: require_trailing_commas

import 'package:cloud_functions/cloud_functions.dart';
import 'package:firebase_core_dart/firebase_core_dart.dart' as core_dart;
import 'package:firebase_functions_dart/firebase_functions_dart.dart'
as functions_dart;

/// Given a [FirebaseApp], a [core_dart.FirebaseApp] is returned.
core_dart.FirebaseApp app([String? name]) {
return name != null ? core_dart.Firebase.app(name) : core_dart.Firebase.app();
}

/// Given a dart error, a [FirebaseFunctionsException] is returned.
FirebaseFunctionsException convertFirebaseFunctionsException(
functions_dart.FirebaseFunctionsException exception,
[StackTrace? stackTrace]) {
return FirebaseFunctionsException(
code: exception.code,
message: exception.message!,
stackTrace: stackTrace,
details: exception.details,
);
}
Loading

0 comments on commit ed98e4a

Please sign in to comment.