Webapp for the Simple Ride platform based on Ionic 3.x.x and Meteor framework >1.4 as backend
npm install -g meteor-client-bundler
In case you are some releases ahead Meteor required version, downgrade using the following steps:
$ sudo rm /usr/local/bin/meteor
$ rm -rf ~/.meteor
$ sudo chown -R $(whoami) ~/.npm
$ curl "https://install.meteor.com/?release=1.6.0.1" | sh
REMEMBER to configure environment variabled under api
script definition in the packages.json
file.
REMEMBER to copy your iOS push certificates into api/private/push_certs
$ cd api && meteor npm install
$ npm run api # Configure api script parameters accordingly in the packages.json file
npm install
$ cd api
$ meteor [--release 1.6.0.1] remove angular2-compilers barbatus:angular2-polyfills
$ meteor [--release 1.6.0.1] add ecmascript
$ cd ..
$ npm run meteor-client:bundle # Configure meteor-client.config.json accordingly
$ ionic cordova run [android|ios] # run on a connected device
$ ionic cordova run [android|ios] --prod --release # run on a connected device for production testing
vi meteor-client-bundler
line 35 to -> Execa.sync("meteor", ["create", "--release", "1.6.0.1", tempDir], {
line 79 to -> Execa.sync("meteor", ["--release", "1.6.0.1", "build", "--debug", "--directory", "."], {
uint8
and uint32
are giving problems on some browsers and iOS devices with OS < 10. To avoid this, comment these lines on node_modules/meteor-client.js
_require('core-js/modules/es6.typed.uint8-array'); // 56
_require('core-js/modules/es6.typed.uint32-array'); // 57
ionic cordova plugin add cordova-plugin-file-transfer@1.6.3 --force
Generate keystore file
$HOME/platforms/android $ keytool -genkey -v -keystore simpleride.keystore -alias SimpleRide -keyalg RSA -keysize 2048 -validity 10000
When running the app on an android device, Gradle might give you problems, so add the following to the end of platforms/android/build.gradle
file:
configurations.all {
resolutionStrategy.eachDependency { DependencyResolveDetails details ->
def requested = details.requested
if (requested.group == 'com.android.support') {
if (!requested.name.startsWith("multidex")) {
details.useVersion '25.3.1'
}
}
}
}
platforms/android
:mv build-extras.gradle.example platforms/android/build-extras.gradle
android {
...
...
flavordimensions "default"
...
...
NSLocationWhenInUseUsageDescription: string description
NSCameraUsageDescription: string description
NSPhotoLibraryUsageDescription: string description of the need of accessing the user photo library
NSMotionUsageDescription: string description of the need of accesing the user geolocation while he is in motion
SimpleRide.pod
file should appear as an error. You must delete it under Build Phases/Embed Pods Frameworks
server/main.js
fileimport "./imports/push.js"; // ENABLE PUSH NOTIFICATIONS
$ openssl x509 -in aps_development.cer -inform DER -outform PEM -out SimpleRide-dev.pem
$ openssl pkcs12 -in CertificateDev.p12 -out SimpleRideKey-dev.pem -nodes
$ openssl x509 -in aps.cer -inform DER -outform PEM -out SimpleRide-prod.pem
$ openssl pkcs12 -in CertificateProd.p12 -out SimpleRideKey-prod.pem -nodes
# Development
$ openssl s_client -connect gateway.sandbox.push.apple.com:2195 -cert meteorApp-cert-dev.pem -key meteorApp-key-dev.pem
# Production
$ openssl s_client -connect gateway.push.apple.com:2195 -cert meteorApp-cert-prod.pem -key meteorApp-key-prod.pem
private/push_certs
folderserver/main.js
file:// For testing push notifications under development
declare var process;
process.env.NODE_ENV = "development";
Configure the server/imports/push.js
file accordingly
Remember to enable Push Notifications on XCode before Archiving the app to be uploaded to the App Store, or for local development
You need to obtain a Server API Key and a SENDERID from the Firebase Cloud Messaging console
Update the SENDERID value on the src/app/pages/login/login.component.mobile.ts
component
Update the FCM API key on the file server/imports/push.js
If you are testing push notifications under development, enable the following lines on the server/main.js
file:
// For testing push notifications under development
declare var process;
process.env.NODE_ENV = "development";
api/package.json
script accordinglyConfigure api/.deploy/mup.js
accordingly. REMEMBER to set the path
property to the location of the local api sourcecode
Run the following commands:
cd api/.deploy
mup setup
mup deploy
More info about conf: click here
cd api/.deploy
mup logs -f
To run the app locally, you need an NGINX instance with the following configuration:
server {
listen 80;
server_name <API-SERVER-IP-ADDRESS>;
location / {
proxy_pass http://<MOBILEAPP-CLIENT-IP-ADDRESS>:8100;
}
location ~ ^/(_oauth|packages|ufs) {
proxy_pass http://<API-SERVER-IP-ADDRESS>:3000;
}
location /sockjs {
proxy_pass http://<API-SERVER-IP-ADDRESS>:3000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
}
For a complete config file example, take a look to the nginx.conf.example file.
To restart nginx service you can use the following commands:
$ kill -QUIT $( cat /run/nginx.pid )
$ /usr/sbin/nginx -t -c /etc/nginx/nginx.conf # IF YOU WANT TO TEST THE CONFIG FILE FIRST
$ /usr/sbin/nginx -c /etc/nginx/nginx.conf # START THE SERVICE. In UBUNTU, you can use systemctl [stop|start] nginx.service
Finally, to start serving the mobile app in your local machine, run the following command:
ionic serve # run on the desktop
In order to develop/test admin features make sure to specity port 3000 in the ROOT_URL environment variable on the api
script defined in the packages.json file. For example: ROOT_URL=http://<local_IP_address>:<3000>
. This is very important to configure if you don't have to experiment any issues with facebook login
Make sure to shutdown any NGINX server configured to make the mobile app work locally.
A development environment is available in this instance on Heroku
If deploying to Heroku for the first time, follow the instructions in this link. On the other hand, if you want to deploy the app into an existing Heroku instance, run heroku git:clone -a simpleride
and add the origin remote to sync the repo.
In case your Heroku instance is not already configured, remember to configure the following environment variables in order to successfully deploy the app
heroku config:add APN_CERT="$(cat $PATH_TO_SimpleRide-dev.pem)"
heroku config:add APN_CERT="$(cat $PATH_TO_SimpleRideKey-dev.pem)"
heroku config:add BUILDPACK_PRELAUNCH_METEOR=1
heroku config:add METEOR_APP_DIR=api/
heroku config:add METEOR_SETTINGS="$(cat $PATH_TO_settings.json)"
heroku config:add MONGODB_URI=$URL_TO_mLab_INSTANCE
heroku config:add ROOT_URL=https://simpleride.herokuapp.com # in case you're using existing Heroku instance 'simpleride'