-
Notifications
You must be signed in to change notification settings - Fork 4
Getting Started
Sneha Canopas edited this page Mar 11, 2024
·
3 revisions
💥 Unity app uses firestore
database. 💥
Note: Flutter sdk vesion
'>=3.2.0 <4.0.0'
is recommended to run project.
$ git clone https://github.com/canopas/canopas-unity.git
- Rename the app package name (because this can affect the Firebase).
- You can do it manually or using this package Rename Package or look at this Stackoverflow Question.
- You'll need to create a Firebase instance. Follow the instructions at https://console.firebase.google.com.
- Go to the Firebase console for your new instance.
- Click "Authentication" in the left-hand menu.
- Click the "sign-in method" tab.
- Click the "Google" and enable it.
- Go to the Firebase Console.
- Click "Firestore Database" in the left-hand menu.
- Click the "Create Database" button.
- It will prompt you to set up, rules, for the sake of simplicity, let us choose test mode, for now.
- On the next screen, select any of the locations you prefer.
-
In the Firebase console, in the settings of your project.
-
Click on the Flutter Icon to add the Flutter app.
-
Follow the instructions to add the Flutter app.
-
It will create a
firebase_options.dart
file in thelib
folder.
-
Go to Google APIs console.
-
On the top bar, Choose your project from the drop-down menu if the selected default project is not your current project.
-
Click on the "API APIs and services".
-
On the left side menu, Select "Credentials".
-
Click on the "Web client(auto created by Google Service)".
-
Copy "Client Id" and "Client Secret" (We will use in next step).
- Add a new dart file named
desktop_credentials
in thelib
folder. - Add the below Code in the file.
const String googleClientId =
"YOUR_GOOGLE_CLIENT_ID";
const String authClientSecret = "YOUR AUTH_CLIENT_SECRET";
- Run the following command from the project folder to get your SHA-1 key:
keytool -list -v -keystore ~/.android/debug.keystore -alias androiddebugkey -storepass android -keypass android
- Open the Android app within your Firebase console.
- Add your SHA-1 key by clicking "Add Fingerprint".
- Download google-services.json.
- Replace it with the old
google_services.json
inandroid/app/
(You can also do it by Flutterfire CLI).
- Open XCode, right-click the Runner folder, select the "Add Files to 'Runner'" menu, and select the GoogleService-Info.plist file to add it to /ios/Runner in XCode.
- Open /ios/Runner/Info.plist in a text editor.
- Then add the CFBundleURLTypes attributes.
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleTypeRole</key>
<string>Editor</string>
<key>CFBundleURLSchemes</key>
<array>
<!-- TODO Replace this value: -->
<!-- Copied from GoogleService-Info.plist key REVERSED_CLIENT_ID -->
<string>com.googleusercontent.apps.861823949799-vc35cprkp249096uujjn0vvnmcvjppkn</string>
</array>
</dict>
</array>
- When running the app on the simulator for the first time, it may take a longer time to build.
- Open the "Credentials" page of the Google APIs console.
- Click on the
Web client (auto-created by Google Service)
. - Copy the
Client ID
located at the top left side of the page. - Open the web/index.html file, and add the following meta tag.
<meta name="google-signin-client_id" content="YOUR_GOOGLE_SIGN_IN_OAUTH_CLIENT_ID.apps.googleusercontent.com">
- Add localhost entries if you are running an app on a specific port on
Authorized JavaScript origins
or use the port that is already specified in this field. - Run
flutter run -d chrome --web-hostname localhost --web-port 7357
. - Replace the port with the one you added to the
Authorized JavaScript origins
fields.