Skip to content

Commit

Permalink
Firebase integration (#32)
Browse files Browse the repository at this point in the history
* temp commit .. firebase setup

* first Firebase commit .. emulator works with functions & realtime DB

* removed functions/kilvish-private-key.json file from git

* calling helloWorld works

* updated Firebase setup instructions

* Firebase integration login

* Firebase integration login

---------

Co-authored-by: Ashish Sharma <[email protected]>
Co-authored-by: radheyshyamjat <radheyshyamjat>
  • Loading branch information
pocha and Ashish Sharma authored Feb 16, 2024
1 parent 6e207cc commit d8a52eb
Show file tree
Hide file tree
Showing 28 changed files with 9,232 additions and 125 deletions.
5 changes: 5 additions & 0 deletions .firebaserc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"projects": {
"default": "kilvish-aa125"
}
}
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,6 @@ app.*.map.json
/android/app/profile
/android/app/release

pubspec.lock
pubspec.lock

/functions/kilvish-aa125-firebase-adminsdk-wchi3-3a285f003c.json
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"java.configuration.updateBuildConfiguration": "interactive"
}
14 changes: 13 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,24 @@ More details at [kilvish.in](https://kilvish.in)
- [Download flutter](https://docs.flutter.dev/get-started/install)
- [Setup Editor](https://docs.flutter.dev/get-started/editor?tab=vscode)
- Run `flutter doctor` in your PC terminal to figure out anything that flutter needs that is not installed on your PC.
2. Run code
2. Run code (currently broken .. read Android Development steps)
- Run `git clone https://github.com/tamraj-kilvish/kilvish.git` in your PC terminal to clone the repository.
- Navigate to the directory of the cloned repository in your PC terminal.
- `flutter pub get` to install dependencies.
- `flutter run` will launch the app in debug mode.
- Your editor might have inbuilt capacity to run `flutter run` and `flutter pub get`. Eg. Visual Studio runs the app with Run command if you have the flutter extension installed.
3. Android Deployment
- Due to sharing related changes, android & iOS specific code is written which had broken the web or MacOS builds.
- `flutter build apk --debug && flutter install --debug` will build & install apk in an already running emulator
- To run an Android emulator, install Android Studio & launch an emulator with the AVD manager

## Firebase Setup

- Install [Firebase CLI](https://firebase.google.com/docs/cli?hl=en&authuser=0#install_the_firebase_cli) & login with `firebase login` on CLI
- Install FlutterFire CLI `dart pub global activate flutterfire_cli`
- Install Firebase Functions dependencies by doing `npm install` inside functions directory.
- Firebase functions are written in Typescript. Run `npm run build:watch` inside functions directory & it will listen for any changes in typescript, compile & update the respective javascript files. Leave it running.
- Launch emulator by running `firebase emulators:start` from the main directory. Access `http://127.0.0.1:5001/kilvish-aa125/us-central1/helloWorld` on the browser to check everything is working.

## Current app screenshots

Expand Down
3 changes: 3 additions & 0 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ if (flutterVersionName == null) {
}

apply plugin: 'com.android.application'
// START: FlutterFire Configuration
apply plugin: 'com.google.gms.google-services'
// END: FlutterFire Configuration
apply plugin: 'kotlin-android'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"

Expand Down
29 changes: 29 additions & 0 deletions android/app/google-services.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"project_info": {
"project_number": "14550226701",
"project_id": "kilvish-aa125",
"storage_bucket": "kilvish-aa125.appspot.com"
},
"client": [
{
"client_info": {
"mobilesdk_app_id": "1:14550226701:android:c9f384274cae633da58244",
"android_client_info": {
"package_name": "com.example.kilvish"
}
},
"oauth_client": [],
"api_key": [
{
"current_key": "AIzaSyAmc9XYW1fOMGyPa52R5y30xrUQG_-L4FI"
}
],
"services": {
"appinvite_service": {
"other_platform_oauth_client": []
}
}
}
],
"configuration_version": "1"
}
8 changes: 5 additions & 3 deletions android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@
package="com.example.kilvish">
<uses-permission android:name="android.permission.READ_CONTACTS" />
<uses-permission android:name="android.permission.WRITE_CONTACTS" />
<application
android:label="kilvish"

<application
android:name="${applicationName}"
android:icon="@mipmap/ic_launcher">
android:icon="@mipmap/ic_launcher"
android:label="kilvish"
android:usesCleartextTraffic="true">
<activity
android:name=".MainActivity"
android:exported="true"
Expand Down
3 changes: 3 additions & 0 deletions android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ buildscript {

dependencies {
classpath 'com.android.tools.build:gradle:7.1.2'
// START: FlutterFire Configuration
classpath 'com.google.gms:google-services:4.3.10'
// END: FlutterFire Configuration
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
Expand Down
7 changes: 7 additions & 0 deletions database.rules.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
/* Visit https://firebase.google.com/docs/database/security to learn more about security rules. */
"rules": {
".read": false,
".write": false
}
}
36 changes: 36 additions & 0 deletions firebase.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{
"database": {
"rules": "database.rules.json"
},
"emulators": {
"auth": {
"port": 9099
},
"database": {
"port": 9000
},
"ui": {
"enabled": true
},
"singleProjectMode": true,
"functions": {
"port": 5001
}
},
"functions": [
{
"source": "functions",
"codebase": "default",
"ignore": [
"node_modules",
".git",
"firebase-debug.log",
"firebase-debug.*.log"
],
"predeploy": [
"npm --prefix \"$RESOURCE_DIR\" run lint",
"npm --prefix \"$RESOURCE_DIR\" run build"
]
}
]
}
32 changes: 32 additions & 0 deletions functions/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
module.exports = {
root: true,
env: {
es6: true,
node: true,
},
extends: [
"eslint:recommended",
"plugin:import/errors",
"plugin:import/warnings",
"plugin:import/typescript",
"google",
"plugin:@typescript-eslint/recommended",
],
parser: "@typescript-eslint/parser",
parserOptions: {
project: ["tsconfig.json", "tsconfig.dev.json"],
sourceType: "module",
},
ignorePatterns: [
"/lib/**/*", // Ignore built files.
],
plugins: ["@typescript-eslint", "import"],
rules: {
"object-curly-spacing": [2, "always"],
"quote-props": ["error", "as-needed"],
semi: ["error", "never"],
quotes: ["error", "double"],
"import/no-unresolved": 0,
"max-len": ["error", { code: 90 }],
},
}
9 changes: 9 additions & 0 deletions functions/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Compiled JavaScript files
lib/**/*.js
lib/**/*.js.map

# TypeScript v1 declaration files
typings/

# Node.js dependency directory
node_modules/
Loading

0 comments on commit d8a52eb

Please sign in to comment.