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

commented firebase notification code #1503

Merged
merged 4 commits into from
Dec 18, 2023
Merged
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
23 changes: 0 additions & 23 deletions .env.sample
Original file line number Diff line number Diff line change
Expand Up @@ -50,29 +50,6 @@ SMTP_PORT=
SMTP_SSL_TLS=


# androidFirebaseOptions
# These environment variables are used for configuring notification service
# on android devices.

apiKey=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
appId=1:XXXXXXXXXXXX:android:XXXXXXXXXXXXXXXXXXXXXX
messagingSenderId=XXXXXXXXXXXX
projectId=appname-XXXXXX
storageBucket=appname-XXXXXX.appspot.com


# iosFirebaseOptions
# These environment variables are used for configuring notification service
# on iOS devices.

iOSapiKey=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
iOSappId=1:XXXXXXXXXXXX:ios:XXXXXXXXXXXXXXXXXXXXXX
iOSmessagingSenderId=XXXXXXXXXXXX
iOSprojectId=appame-XXXXXX
iOSstorageBucket=appame-XXXXXX.appspot.com
iosClientId=XXXXXXXXXXXX-XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX.apps.googleusercontent.com
iosBundleId=com.appname.app

# Email for the first user who will be super admin
# The user with the email address set with this parameter will automatically be elevated to Super Admin status on registration.
#
Expand Down
85 changes: 0 additions & 85 deletions INSTALLATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,6 @@ This document provides instructions on how to set up and start a running instanc
- [Setting up Logger configurations _(optional)_](#setting-up-logger-configurations-optional)
- [Setting up COLORIZE_LOGS in .env file](#setting-up-colorize_logs-in-env-file)
- [Setting up LOG_LEVEL in .env file](#setting-up-log_level-in-env-file)
- [Configuring Google Firebase](#configuring-google-firebase)
- [Generate Firebase Keys for the Talawa Notification Service](#generate-firebase-keys-for-the-talawa-notification-service)
- [(Mobile Developers Only) Applying the Firebase Keys to the Talawa Mobile App](#mobile-developers-only-applying-the-firebase-keys-to-the-talawa-mobile-app)
- [Importing Sample Database](#importing-sample-database)
- [Syntax:](#syntax)
- [Examples:](#examples)
Expand Down Expand Up @@ -529,88 +526,6 @@ There are different logging levels that can be configured by setting this parame
<br><br>
For our application, the most appropriate setting is `LOG_LEVEL = info` since most of information logged on the console are error messages, warnings or info texts.

## Configuring Google Firebase

You need to have a `google` account to follow the following steps.

<br/>

### Generate Firebase Keys for the Talawa Notification Service

We use firebase for mobile app notifications. To configure the notification service create a new firebase project and follow these steps:-

1. Create a new Firebase project for Talawa-API
1. When created you will automatically enter the project's console area
1. Click on the settings icon beside the `Project Overview` heading
1. Click on `Project Settings`
1. Click on the `Service Accounts` tab
1. Click on the `Node.js` radio button
1. Click on `Generate New Private Key` button
1. Confirm by clicking on `Generate Key`. This will automatically download the private keys in your browser.
1. Securely store the `JSON` file containing the private key. These will be used in the next section.

### (Mobile Developers Only) Applying the Firebase Keys to the Talawa Mobile App

The key generated in the previous step is in a format suitable for use in a mobile app. We need to convert it for use by the API. This will require you to do some work in the talawa repository to do the necessary conversion. The resulting output will be stored in a `lib/firebase_options.dart` file. Some of the contents of this file will then need to be added to the API's `.env` file. Here we go.

1. Clone the talawa mobile app in a separate directory that is not under your Talawa-API directory.
1. Enter that directory as you will need to edit files there
1. Run the following commands to set the key in the environment variable for your respective operating system:

1. `Linux/macOS:`

export GOOGLE_APPLICATION_CREDENTIALS="/PATH/TO/JSON/FILE/filename.json"

1. `Windows:`

$env:GOOGLE_APPLICATION_CREDENTIALS="C:\PATH\TO\JSON\FILE\filename.json"

1. Install the [Firebase CLI](https://firebase.google.com/docs/cli#install_the_firebase_cli).
1. Save the original copy the `lib/firebase_options.dart` file as it will be modified.
1. Run the following commands in the project directory of talawa mobile app:

firebase login

dart pub global activate flutterfire_cli

1. Run any commands about exporting variables from the previous `dart` command.
1. Run the following command to configure the application for Firebase
`flutterfire configure`
1. Select the project you created in the firebase console.
1. Add `iOS` and `android` platforms to the project.
1. Overwrite the `firebase_options.dart` file if asked so.
1. The command will generate keys for the `iOS` and `android` platforms respectively and place them in the `firebase_options.dart` file.
1. Edit the `firebase_options.dart` file.
1. Add the parameters in the `static const FirebaseOptions android = FirebaseOptions` section of the `firebase_options.dart` file to the Talawa API `.env` file under the `androidFirebaseOptions` heading.

1. Replace any parameters that are already there in that section.
1. Remove any trailing commas on the lines you have added.
1. Remove any leading spaces on the lines you have added.
1. The final result in the `.env` file should look like this

apiKey: '9f6297b283db701dab7766c993c48b',
appId: '1:261699118608:android:366ff7dbdfba5c5a9e8392',
messagingSenderId: '261699118608',
projectId: 'talawa-thingy',
storageBucket: 'talawa-thingy.appspot.com',

1. Add the parameters in the `static const FirebaseOptions ios = FirebaseOptions` section of the `firebase_options.dart` file to the Talawa API `.env` file under the `iosFirebaseOptions` heading. Replace any paramters that are already there.

1. Replace any parameters that are already there in that section.
1. Remove any trailing commas on the lines you have added.
1. Remove any leading spaces on the lines you have added.
1. The final result in the `.env` file should look like this

apiKey: 'c2d283aa45f4e858c9cbfe32c58c67',
appId: '1:261699118608:ios:1babbb3c07b8461ebdcb2',
messagingSenderId: '261699118608',
projectId: 'talawa-thingy',
storageBucket: 'talawa-thingy.appspot.com',
iosClientId: '261699118608-d519b739e43c6214374c0da62feaef.apps.googleusercontent.com',
iosBundleId: 'com.example.talawa',

1. Undo the changes made to the `firebase_options.dart` file by overwriting it with the version you saved at the beginning of this section.

# Importing Sample Database

Talawa API contains a sample database importing function which can be used to import sample database.
Expand Down
Loading
Loading