Client side of openMessaging Mobile App integration

Overview

flutter-openMessaging

This is designed as an example only for using a Flutter Mobile App as the client for the firebase BaaS in openMessaging for Genesys Cloud OpenMessaging. This repo is the client side of the Middleware and there is another repo I have created that is the server side written as a Firebase/JavaScript project. This example requires you to have experience with firebase & Flutter. Before starting this project I recommend doing the server side of the middleware that can be found here

1. Flutter & Firebase setup

First of all ensure you have Flutter installed and setup as well as android studio for the emulator. This example will not go through these steps, details of this can be found at the Flutter website. You will also be using the Firebase project setup that was done in the last project with the server side elements.

The Over view design on this is below and this is focused on the mobile app side of the design.

2. Firebase Authentication

Ensure that in the Firebase you have Google setup as the "provider" for authentication as that is what this Flutter example application is using. You can use a different provider but in that case you will need to update the Dart code to reflect this change.

3. Firebase Firestore

In the Firebase firestore create a "collection" called

users

The other "documents" you can see below get automaticlly created as users authenticate with the App as well as start to send messages. Using the Firestore enables you to control the history cache that loads to allow for much more threading time then the max 72hours as well as from a data loading and offline viewing it has been designed by firebase to scale as well as allowing for multiply clients to "subscribe" to changes without needing to use websockets. This is all handeled by the firebase SDK and saves a LOT of pain in building this at scale.

In the "Rules" for the database ensure you set the below options to ensure that it is secured. The below will only allow someone who has a valid token and only access to the users messages based on their UUID.

rules_version = '2';
service cloud.firestore {
match /databases/{database}/documents {
    match /users/{userId}/messages/{document=**} {
    allow read, write: if
        request.auth != null && request.auth.uid == userId
    }
    match /users/{userId}/profile/{document=**} {
        allow read, write: if
            request.auth != null && request.auth.uid == userId
    }
}
}

4. Firebase Storage

If you want to allow images to be sent by the Mobile App you will need to allow a storage location for the attachments. For this I'm using the Girestore Storage which is a GCP Bucket under the hood. When you create a folder ensure its called

uploads/

on the root dir. This is what the App will look for in the design. For the "Rules" ensure that you have the below configured.

rules_version = '2';
service firebase.storage {
match /b/{bucket}/o {
    match /{allPaths=**} {
    allow read, write: if request.auth != null;
    }
}
}

5. Firebase Functions

You should notice that there are already 2x Clound Functions in your Firebase project (as long as you went through the server side project first).

As these are deployed in the same project they are seen as a trusted server side function so the Auth is taken care of for you in GCP/Firebase.

6. Firebase Cloud Messaging

Make sure that you have enabled and configured firebase cloud messaging to get the push notifications even when the app is closed. For this the API (V1) is used.

7. Project Settings

Create an "Android" App in the project settings for this you will need to generate a SHA key both 256 and 1 there are details on how to do this here. In my example I also created an HTML one to also run this App in Web but you only need to do it for the platfrom your planning to use. Once you have done this you will need to download the json file. The "Package name" is set to "com.example.open_messaging" as this is what it is set to in the Flutter application.

google-services.json

Now that you have the json file with connection detials for your environment you will need to paste this into the directory

/open_messaging/app/

8. Flutter App

Now you can run a build on the Android APK and run the App.

Login Screen:

Account Selection:

Usage:

Notifications:

You can recieve notifications even when the app is fully closed.

9. Agent Restart

I have not included this code but you can have a Cloud Function that will operate as the "Agentless Message" API to allow you to build out a simple Agent based UI to allow the agent to "restart" the conversation once its disconnected rather then waiting for the customer to reply with the Mobile App.

This is an easy extension of the above example and if there is a requirement I may add that example code into another repo in the future.

Flutter Web Build

To build this app as a Flutter for Web application I have updated the required packages as well as the index.html file in the /open_messaging/web/ dir. In this file you will notice that the firebase CDNs are now listed as well as a new file called:

firebaseconfig.js

You will need to create this file and host it in the root Dir of the Flutter for web project once its built. To build the file simply go to your Firebase project and get the CDN configuration,

From this you can copy the firebaseConfig JSON object with the settings from your project. Use this to create the "firebaseconfig.js" file:

var firebaseConfig = {
    apiKey: "YOUR_API_KEP",
    authDomain: "YOUR_DOMAIN",
    databaseURL: "YOUR_URL",
    projectId: "YOUR_PROJECTID",
    storageBucket: "YOUR_BUCKET",
    messagingSenderId: "YOURID",
    appId: "YOUR_APPID",
    measurementId: "YOUR_MEASURMENTID"
};

firebase.initializeApp(firebaseConfig);

Save this and once you have ran the command to build the web app

Flutter build web

In the /build/web/ location save this new config js file and now when you run the index.html file it will load all your settings. Where ever you host this website build you will need to ensure that you also have that domain allowed in the OAuth provider you have used in this example that is Google in the Firebase Auth providers.

You might also like...

As a beginner , this is my own side project by using flutter & dart , Firebase . This app still in progress .

helpful_app A new Flutter application. Getting Started This project is a starting point for a Flutter application. A few resources to get you started

Nov 23, 2021

Demo app with continuous integration setup for auto across android/iOS app stores

demo_flutter_ci A new Flutter project. Getting Started This project is a starting point for a Flutter application. A few resources to get you started

Dec 25, 2021

A GraphQL client for Flutter, bringing all the features from a modern GraphQL client to one easy to use package. Built after react apollo

Flutter GraphQL Table of Contents Flutter GraphQL Table of Contents About this project Installation Usage GraphQL Provider [Graphql Link and Headers]

Nov 9, 2022

A GraphQL client for Flutter, bringing all the features from a modern GraphQL client to one easy to use package.

A GraphQL client for Flutter, bringing all the features from a modern GraphQL client to one easy to use package.

GraphQL Flutter 📌 Bulletin See the v3 - v4 Migration Guide if you're still on v3. Maintenance status: Low. Follow #762 for updates on the planned ar

Jan 5, 2023

An easy to use side menu in flutter and can used for navigations

An easy to use side menu in flutter and can used for navigations

Easy Sidemenu Easy sidemenu is An easy to use side menu (bar) for flutter that you can use for navigations in your application. Sidemenu is a menu tha

Dec 29, 2022

A side drawer using Flutter_advanced_drawer package

advanced_drawer A new Flutter project. Getting Started This project is a starting point for a Flutter application. A few resources to get you started

Feb 10, 2022

A Side Menu plugin for flutter and compatible with liquid ui for flutter

A Side Menu plugin for flutter and compatible with liquid ui for flutter

Liquid Shrink Side Menu A Side Menu plugin for flutter and compatible with liquid ui Side Menu Types There are 8 configuration of Liquid shrink side m

Nov 24, 2022

Flutter drawer (dynamic ready side menu)

Flutter drawer (dynamic ready side menu)

Flutter side menu (Drawer) Getting Started Use KFDrawer widget as Scaffold's body with items property (ListKFDrawerItem) you should define onPressed

Dec 5, 2022

Adds a side menu in all screens with debug information

Adds a side menu in all screens with debug information

Adds a side menu in all screens with debug information. You can decide which information to show and create new modules to include more information.

Oct 7, 2022
Owner
null
Integration test - Copy of the official Flutter integration test plugin

integration_test This package enables self-driving testing of Flutter code on de

null 0 Jan 5, 2022
Flutter-fb-integration - Flutter And firebase integration Guide

Quickstart Guide This project still use my firebase server config, if you want t

Naufal Aldy Pradana 0 Feb 2, 2022
FLutter Api Integration - Flutter Rest API Integration

Flutter_Rest_Api_integration Flutter_Rest_Api_integration. Preview How To Use To

Rahul Ranjan Singh 0 Feb 17, 2022
Vrchat mobile client - VRChat Unofficial Mobile Client For Flutter

VRChatMC VRChatの非公式なAPIを利用したVRChatのモバイルクライアント Flutterで作成されたシンプルなUIが特徴的です iosビルドは

ふぁ 8 Sep 28, 2022
Client-side Application for NITTFEST

Nittfest-Client Client Application for NITTFEST. Flutter Requirements Java-Versi

Delta Force 4 Nov 14, 2022
Nimbostratus is a reactive data-fetching and client-side cache management library built on top of Cloud Firestore.

Nimbostratus ?? Nimbostratus is a reactive data-fetching and client-side cache management library built on top of Cloud Firestore. The Cloud Firestore

Dan Reynolds 13 Dec 15, 2022
Inspired by PocketBase provide client side SQLite database, schema generator and admin UI

Firebase SQLite Taking Cloud Firestore ODM to the next level. Admin UI The Admin UI is a web interface for managing your database in firestore and is

Rody Davis 12 Dec 11, 2022
Full Feature Todos Flutter Mobile app with fireStore integration.

IONICFIREBASEAPP DOWNLOAD TODO APP Marketplace for Mobile app and Backend that developed on leading Enterprise Technologies with as well as with your

Ionicfirebaseapp 138 Nov 4, 2022
An open-source unofficial GitHub mobile client, that aims to deliver the ultimate GitHub experience on mobile devices.

DioHub for Github Summary Features Roadmap Support Screenshots Build Instructions Summary DioHub is an open-source unofficial GitHub mobile client, th

Naman Shergill 401 Jan 4, 2023
Passwall-mobile - A mobile client for PassWall API written with Flutter

passwall-mobile PassWall Mobile is a mobile client for PassWall API written with Flutter. Getting Started Clone the server app and build it. Install F

Abuzer Emre Osmanoğlu 104 Nov 22, 2022