do an android nang cao sgu app cua hang giao do an
- ⚠ xem update mới ngày
Tue May 14 2024 22:27:42 GMT+0700 (Indochina Time): nhập thêm app shipper vào firebase - ⚠ xem update mới ngày
Wed May 15 2024 00:42:23 GMT+0700 (Indochina Time): kết nối qua internet - ⚠ xem update mới ngày
Mon May 20 2024 01:14:49 GMT+0700 (Indochina Time): đổi format log ip access control
- backend nằm trong
/backend/backend-nodejs - hình lưu ở
/backend/public/images, route up hìnhPOST /images, route tải hìnhGET /images.[uuidv4.png], hình cho push lên github luôn
- app nằm trong
frontend/customer-app&frontend/shipper-app
- lên firebase console tạo project

- vào project, vào authentication

- sign-in method, add new provider, bật email/password, phone lên

- bấm edit configuration của phone

- add 1 vài số dt và mã code để test số ảo không tốn tiền

- vào users, add user, email firebase-test-user@example.com, pass firebasetestuser

- vào project overview, add app, android

- mở project frontend customer-app, execute gradle task

- gõ
gradle signingReport 
- lấy sha1 của variant debug và config debug

- quay lại firebase console, nhập app package name
com.doansgu.cafectmvà sha1 
- tải file
google-services.jsonrồi để như hướng dẫn 
- bấm tiếp tục bước 3 và 4 (không bấm tắt cũng không làm theo)
- quay lại firebase console, add app, web

- chọn
use a <script> tag, copyfirebaseConfig 
- vô
backend/app/public/firebase-auth-test.html, thay đổifirebaseConfigthành cái vừa copy 
- quay lại firebase console, vô project settings, service account, generate new private key

- tải file key về bỏ vào
/backend/app/config - thay đổi
const serviceAccount = requirethành tên file đúng file mới tải 
- lệnh
npm startlên thấyConnect Firebase without errorsvàFirebase connection test successlà xong 

- add thêm 1 app với package name
com.example.delivery_appvào, sha1 nhập như của app customer đã nhập 
- mongodb atlas và tạo database + collection, lấy driver uri connect chắc biết rồi nhỉ
- vào https://account.mongodb.com/account/login đăng nhập google

- bấm bỏ qua mấy trang khảo sát
- ở trang Overview bấm connect, Drivers

- copy connection string này, nhưng cần phải thay
<username>:<password>mới xong 
- xem mục security, database access

- bấm add new database user, nhập username password

- sau khi bấm add user nó quay về thấy hiện user mới tạo ở bảng là được

- thay đổi phần
<username>:<password>trong connection string đã copy thành cái mới tạo - vào
backend/app/config/_APP.js - tự thay dổi
DATABASE_CONNECTION_URLvàDATABASE_NAMEtheo cài đặt của mình 
- lệnh
npm startthấyConnected to MongoDBlà xong 
- chỉ dùng cho thiết bị thật kết nối khi lên báo cáo
- nên thực hiện xong thông tin setup để chạy local trước khi tiếp tục
- bước whitelist ip cho backend phải thực hiện lại khi đổi ip.
- Tránh commit file config tránh để bị lộ IP nếu không thích.
- ℹ️ các ip có ghi sẵn như
["127.0.0.1", "localhost", "::1", "10.0.2.2", "10.0.3.2"]là các ip loopback và loopback cho host của android studio emulator
- nếu kết nối local (test bằng GET
/helloworld) cũng bị403 Forbidden, this client IP ${chuoi gi do} is not whitelisted., hoặc muốn add ip qua mạng này vào danh sách 
- đọc log của server, ví dụ thấy
::ffff:127.0.0.1 (forwarded for 2402:0000:0000:0000:0000:0000:0000:9cba)bị chặn mà đó là của mình, thì thêm vàoWHITELIST_IPStrong/backend/app/config/_APP.js. thì thêm cả 2 cái IP::ffff:127.0.0.1và2402:0000:0000:0000:0000:0000:0000:9cba. 
- restart server, bảo đảm đã GET
/helloworldđược, hoặc vào được trang chủ, log show_ accessed 
- vào https://dashboard.ngrok.com/login đăng nhập google

- đăng ký xong, vào Your authtoken copy dòng lệnh
ngrok config add-authtokenđược chỉ dẫn 
- chạy
npx <lệnh đã copy>trong terminal của backend (đã được install bằng npm) 
- mở thêm 1 terminal, cái để chạy server, cái để chạy
npx ngrok http 3001. CHÚ Ý port server mặc định3001, nếu muốn đổi server mở port khác thì ghi port đó vào 
- lấy link
Forwardingđã được ngrok mở cho 
- visit site

- hãy xem kết nối được

- như vầy là server chưa chạy hoặc sai port hoặc abcxyz

- như vầy là sai link ngrok
