Code Monkey home page Code Monkey logo

po-meste-native's Introduction

Po meste

React Native Expo app. Mobility, public transport and multimodal planner for Bratislava.

This project is led by the Department of Innovation and Technology of the City of Bratislava. We’re making it open-source as we believe this promotes savings, collaboration, auditability and innovation in the public sector.

Our goal is to be transparent about services we’re developing and providing, as well as to invite other cities and municipalities to build on top of the same or similar open-source technologies we’ve already tested and used - to foster an ecosystem of collaboration between teams facing similar challenges. We’ll be happy to get in touch.

If you are an individual or a company who’d like to take part in these efforts, collaborate closely on development or report an issue, we’d love to hear from you! 🙌 Contact us using this repository or at [email protected]

Development

Install:

yarn

Run for all platforms

yarn start

This will guide you how to open it locally on iOs simulator (if available) or Android emulator (also if available). Running in web browser is possible but discouraged (react-native-mapview is still experimental in browser).

If you want to develop on your device, you can use Expo Go application.

To get Env keys:

For help reach to @mpinter (Martin Pinter) or @Balros (Adam Grund)

Patch-package note

List of temporary patches & why they are here:

  • react-native 0.69.6 - this is to make react-native-maps 0.31.1 work, which is the newest version supported by expo 0.46

Note about GOOGLE_PLACES_API_KEY

Since we are using this library for Places Autocomplete, we can't restrict the API key to just our bundle - this is not ideal and we may want to change it in the future. It's also the reason why all other google APIs are accessed by the iOs/Android keys, but the Places API is a separate one.

Running on device

You need the Expo Go application installed on your device. With Android you only need to scan the QR shown to you after yarn start. On iOs you may need access to the bratislava expo organization - ping Martin Pinter to get it.

Fetching data

We use React Query to fetch data - it's giving it's default configuration and behaviour a quick look here.

Fetching with React Query looks something like the following:

const { isLoading, data, error } = useQuery('uniqueKey', fetcherFunction)

The first (key) param is used as the cache key - useQuery used in two different places with the same key should

The fetcher functions reside in api.ts - please use the name of the fn as the key (as long as they all reside in same file this should guarantee uniqueness) - if the resource uses a parameter (i.e. you're fetching a resource by it's id), the key should be an array with the name of the functions and all parameters used:

useQuery('getStations', getStations)
useQuery(['getStationById', id], () => getStationsById(id))

Validating data

We use yup. Useful not only as a sanity check but also to provide you with types and autocomplete. Validations reside in validation.ts.

Release

TODO separate release channels for versions

When to bump version and when to bump just the buildNumber and versionCode ? BuildNumber and versionCode must change with every build (try to keep them in sync). We up the version every time we want to distribute something new to the end user through App/Play store.

Give new versions to testers over Expo Go

Testers can access the app here https://expo.dev/@bratislava/hybaj?release-channel=staging

On android you can just scan the QR code or follow the link, on iOs you need to be registered on Expo and added to the Bratislava organisation (Marin Pinter or Adam Grund can do that).

To publish a new version of app for testers:

yarn publish-staging

Update apps in production without submitting to App/Play store

Be sure you know what you are doing, running this updates the version for all live production users out in the wild

yarn publish-production
  1. app.config.js property version and android.versionCode and ios.buildNumber as well MUST be moddified
  2. yarn publish-production

Release new (Internal) Android version

To release new .apk to Play Store:

  1. Enviroment variable GOOGLE_PLACES_API_KEY_UNLOCKED needs to be changed to key that belongs to Android (GOOGLE_ANDROID_API_KEY)
  2. Bump buildNumber and versionCode in app.config.js - try keeping ios buildNumber and android versionCode in sync even if releasing to just one of the systems
  3. yarn create-production-apk - WARNING: THIS ALSO CAUSES ALL THE CURRENT DEPLOYMENTS TO UPDATE OVER-THE-AIR INSTANTLY BEFORE THE NATIVE BUILD, EVEN BEFORE YOU SUBMIT THE APP FOR REVIEW - modify the command with --no-publish flag if you don't wish to do this
  4. wait for Expo to build new .apk
  5. Download produced .apk
  6. Create new release to desired release channels, e.g. Internal testing
  7. Upload new .apk

Note about updating the testing version on Android - Google Play store often can't see the updated version if you already downloaded an older one - what always works is to 1. uninstall the app 2. from the settings, force quit Play store 3. from the same place, clear cache and delete all app data 4. download the app again.

Release (TestFlight) iOs version

You need a Mac with installed XCode or Transporter app

  1. Enviroment variable GOOGLE_PLACES_API_KEY_UNLOCKED needs to be changed to key that belongs to IOS (GOOGLE_IOS_API_KEY)
  2. Bump buildNumber and versionCode in app.config.js - try keeping ios buildNumber and android versionCode in sync even if releasing to just one of the systems
  3. yarn create-production-ipa - WARNING: THIS ALSO CAUSES ALL THE CURRENT DEPLOYMENTS TO UPDATE OVER-THE-AIR INSTANTLY BEFORE THE NATIVE BUILD, EVEN BEFORE YOU SUBMIT THE APP FOR REVIEW - modify the command with --no-publish flag if you don't wish to do this
  4. You will be asked to log in to your apple account and select organisation and provider - you need to have access to Bratislava apple organisation
  5. wait for Expo to build new .ipa
  6. Download produced .ipa & upload it to App Store connect using the Transporter app or XCode
  7. Go to app Testflight section and make the version available if needed - the processing usually takes up to an hour, but can get stuck for longer

Additional info

  1. When application is installed from play store, version installed is always from last .apk file uploaded to store, then OTA updates is applied.
  2. Map won't load. If API keys are changed, they won't work until produced .apk is uploaded in Play store. Then google store signs new release and activate new keys. Some info in Expo docs
  3. Google store id change is not possible. Info

po-meste-native's People

Contributors

balros avatar justmatys avatar lukybil avatar mpinter avatar barb0ra avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.