Skip to content

Demo Application built in flutter leveraging the Yonomi Platform

License

Notifications You must be signed in to change notification settings

Yonomi/yonomi-flutter-demo

Repository files navigation

Yonomi Flutter Demo

Yonomi Flutter Demo CircleCI codecov


This demo application is built using Flutter and Yonomi's latest IoT API.


For Developers

This demo app is to help you get acquainted with Yonomi's developer tools. This app also follows best practices for building a Flutter application using Yonomi platform. You can fork this application as a starting point for your own IoT mobile and web applications and use it as a head start on development.

For Non-Technical Customers

This demo is a great place to start understanding the kind of applications you can build using Yonomi. You may use the instructions below to get an instance of this demo running on your local machine, or you can work with members of Yonomi's sales team to see this demo in action.

Table of contents

  1. Prerequisites
  2. Getting Started
  3. Brief App Overview
  4. Running tests
  5. License

Prerequisites

1. Install Flutter

You will need to have a machine set up with the Flutter SDK.

1. Follow the official guide on how to install the Flutter SDK on your machine:

https://flutter.dev/docs/get-started/install

2. You will need to be set up with our platform

You will need a tenant ID and a private key to get started. Once you have a private key, the private key file should be placed in the assets folder, with filename jwtRS256.key

It is NOT recommended that this file is added in source control and only be generated during CI/CD process.

If you need guidance on obtaining any of these, please contact our sales team to help you get started using our platform.

Getting Started

Configuring the app

Add your configuration

Add your tenant ID and private key to the app:

  1. Create a file .env in your app's assets folder.

  2. Add the following entries in your .env file. Make sure to replace YOUR-TENANT-ID with your Tenant ID and YOUR-PRIVATE-KEY with your private key.

TENANT_ID: YOUR-TENANT-ID
PRIVATE_KEY: YOUR-PRIVATE-KEY
  1. Double-check your pubspec.yaml file to make sure that the file is defined under the assets section:
flutter:
  ...
  assets:
    - assets/.env

Update the config.yaml file

  1. Open assets/config.yaml and update url with the platform's graphQL endpoint:
URL: https://platform.yonomi.cloud/graphql
  1. Double-check your pubspec.yaml file to make sure that this file is defined under the assets section:
flutter:
  ...
  assets:
    - assets/config.yaml

Configure with Firebase

We have used Firebase to collect crash logs and to easily distribute app builds. To correctly run the app you will need firebase related config files. Each for ios and android. Use the following guides below to set it up on your desired platform(s):

For Android

Firebase Android guide

Make sure you follow the steps under Add a Firebase Configuration File to know where to place your google-services.json file

For iOS

Firebase iOS guide

Make sure you follow the steps under Add a Firebase Configuration File to know where to place your GoogleService-Info.plist file.

Update gitignore to be able to track these files if needed by the organization.

Building a Request object

You will use YoRequest.request() to simplify making requests to the platform.

Example: Building a request object using user ID "1234"

Request request = await YoRequest.request("1234");

Note: This method builds a valid request by using the configured graphql endpoint, the user ID passed in as a parameter, the private key file named jwtRS256.key, and the configured tenant ID.

Configuring a device to run the app:

You can use either iOS or Android devices to run the demo app.

iOS

  1. Simulator
  2. Real device

Visit the following link to download XCode:

https://developer.apple.com/support/xcode/

Android

  1. Emulator
  2. Real device

Visit the following link to download Android Studio:

https://developer.android.com/studio

Brief App overview

When you open the app, you will be prompted for a User ID. You can input anything as your User ID or you can use one previously used to navigate to the next screen.

At the bottom you can select three tabs to navigate to the Home, Devices, or Settings screens.

To add an integration

Press the '+' floating action button and select an integration from the list.

You will be taken to that integration's authentication page.

Input your credentials for that account, and if you authenticated successfully, you will be taken back to the app and see all devices under that account.

Running tests

Prerequisites

  • Install lcov:

lcov (For test coverage)

brew install lcov

Run tests with coverage

flutter test --coverage
genhtml coverage/lcov.info -o coverage/html
open coverage/html/index.html

License

This application is released under the Apache license v2.0

License

About

Demo Application built in flutter leveraging the Yonomi Platform

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 3

  •  
  •  
  •  

Languages