-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[firebase_functions] Add Firebase Cloud Functions plugin
- Loading branch information
Showing
19 changed files
with
484 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
## 0.1.0 | ||
|
||
* Initial release. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, | ||
), | ||
), | ||
), | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
flutter/ | ||
.vs/ | ||
*.user | ||
bin/ | ||
obj/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
16
packages/firebase_functions/example/tizen/tizen-manifest.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, | ||
); | ||
} |
Oops, something went wrong.