Skip to content

Repository files navigation

urban-enigma

do an android nang cao sgu app cua hang giao do an

Chu y

  1. ⚠ 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
  2. ⚠ xem update mới ngày Wed May 15 2024 00:42:23 GMT+0700 (Indochina Time): kết nối qua internet
  3. ⚠ xem update mới ngày Mon May 20 2024 01:14:49 GMT+0700 (Indochina Time): đổi format log ip access control

thông tin setup để chạy local

Backend

  1. backend nằm trong /backend/backend-nodejs
  2. hình lưu ở /backend/public/images, route up hình POST /images, route tải hình GET /images.[uuidv4.png], hình cho push lên github luôn

Frontend app

  1. app nằm trong frontend/customer-app & frontend/shipper-app

Firebase

  1. lên firebase console tạo project
  2. image
  3. vào project, vào authentication
  4. image
  5. sign-in method, add new provider, bật email/password, phone lên
  6. image
  7. bấm edit configuration của phone
  8. image
  9. add 1 vài số dt và mã code để test số ảo không tốn tiền
  10. image
  11. vào users, add user, email firebase-test-user@example.com, pass firebasetestuser
  12. image
  13. vào project overview, add app, android
  14. image
  15. mở project frontend customer-app, execute gradle task
  16. image
  17. gradle signingReport
  18. image
  19. lấy sha1 của variant debug và config debug
  20. image
  21. quay lại firebase console, nhập app package name com.doansgu.cafectm và sha1
  22. image
  23. tải file google-services.json rồi để như hướng dẫn
  24. image
  25. bấm tiếp tục bước 3 và 4 (không bấm tắt cũng không làm theo)
  26. quay lại firebase console, add app, web
  27. image
  28. chọn use a <script> tag, copy firebaseConfig
  29. image
  30. backend/app/public/firebase-auth-test.html, thay đổi firebaseConfig thành cái vừa copy
  31. image
  32. quay lại firebase console, vô project settings, service account, generate new private key
  33. image
  34. tải file key về bỏ vào /backend/app/config
  35. thay đổi const serviceAccount = require thành tên file đúng file mới tải
  36. image
  37. lệnh npm start lên thấy Connect Firebase without errorsFirebase connection test success là xong
  38. image
Add app shipper to firebase
  1. image
  2. add thêm 1 app với package name com.example.delivery_app vào, sha1 nhập như của app customer đã nhập
  3. image

Mongodb

  1. mongodb atlas và tạo database + collection, lấy driver uri connect chắc biết rồi nhỉ
  2. vào https://account.mongodb.com/account/login đăng nhập google
  3. image
  4. bấm bỏ qua mấy trang khảo sát
  5. ở trang Overview bấm connect, Drivers
  6. image
  7. copy connection string này, nhưng cần phải thay <username>:<password> mới xong
  8. image
  9. xem mục security, database access
  10. image
  11. bấm add new database user, nhập username password
  12. image
  13. sau khi bấm add user nó quay về thấy hiện user mới tạo ở bảng là được
  14. image
  15. thay đổi phần <username>:<password> trong connection string đã copy thành cái mới tạo
  16. vào backend/app/config/_APP.js
  17. tự thay dổi DATABASE_CONNECTION_URLDATABASE_NAME theo cài đặt của mình
  18. image
  19. lệnh npm start thấy Connected to MongoDB là xong
  20. image

connecting over the internet

CHÚ Ý

  1. chỉ dùng cho thiết bị thật kết nối khi lên báo cáo
  2. nên thực hiện xong thông tin setup để chạy local trước khi tiếp tục
  3. bước whitelist ip cho backend phải thực hiện lại khi đổi ip.
  4. Tránh commit file config tránh để bị lộ IP nếu không thích.
  5. ℹ️ 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
whitelist ip on backend
  1. 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
  2. image
  3. đọ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ào WHITELIST_IPS trong /backend/app/config/_APP.js. thì thêm cả 2 cái IP ::ffff:127.0.0.12402:0000:0000:0000:0000:0000:0000:9cba.
  4. image
  5. restart server, bảo đảm đã GET /helloworld được, hoặc vào được trang chủ, log show _ accessed
  6. image

Ngrok

  1. vào https://dashboard.ngrok.com/login đăng nhập google
  2. image
  3. đăng ký xong, vào Your authtoken copy dòng lệnh ngrok config add-authtoken được chỉ dẫn
  4. image
  5. chạy npx <lệnh đã copy> trong terminal của backend (đã được install bằng npm)
  6. image
  7. mở thêm 1 terminal, cái để chạy server, cái để chạy npx ngrok http 3001. CHÚ Ý port server mặc định 3001, nếu muốn đổi server mở port khác thì ghi port đó vào
  8. image
  9. lấy link Forwarding đã được ngrok mở cho
  10. image
  11. visit site
  12. image
  13. hãy xem kết nối được
  14. image
  15. như vầy là server chưa chạy hoặc sai port hoặc abcxyz
  16. image
  17. như vầy là sai link ngrok
  18. image

About

do an android nang cao sgu app cua hang giao do an

Resources

Security policy

Stars

1 star

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages