Synchra.24
menu_bookDocumentation
Practical guides for setup and development

Find guides for getting started, building workflows and adding your own tools to your company workspace.

folderEmbedded services

Quick start

A quick deployment scenario for a micro-application.

Machine translation

In this scenario, we don't start with an empty project, but take a ready-made example. synchra24/app_example we deploy it, connect it to our company in Synchra.24 and check the bridge in the real application.

This way is suitable if you need to quickly:

  • raise the working template of the internal service;
  • check how the WebView application communicates with the mobile client;
  • Understand how the API, theme, navigation, user selection, files, camera, and other native features work.;
  • get a starting point for your microapplication.

This quick start describes external URL application and mobile WebView. If you are creating an embedded web service in the Synchra editor, use Embedded Services Guide: the SDK is already provided by the engine there. Sending custom events emitEvent It belongs to this web mode and is not yet supported by the mobile bridge. It does not require transferring user tokens to the code or accessing a third-party webhook.

What will be needed

Before starting, prepare:

  • installed Node.js;
  • access to a company where you can create internal services;
  • the public URL where the web application will be available;
  • a smartphone with the Synchra.24 app for verification.

What will we use

SDK for integration

Package @synchra24/app — this is a bridge SDK for hybrid applications inside Synchra.24.

Through it, the web application gets access to:

  • allowed API requests;
  • provider's context;
  • Synchra.24 theme;
  • geographical positions;
  • users' choice;
  • selecting files and photos;
  • QR scanner;
  • snackbar, modal, and internal navigation.

A ready-made example

The Repository synchra24/app_example — this is a working demo project, in which the main bridge methods are already connected.

How Synchra opens a microapplication

In the mobile application, the service opens in the built-in window.:

  • The URL of the service is uploaded to WebView;
  • the service token is transferred to your application;
  • bridge verifies the token before performing native operations;
  • The WebView gets the theme, the provider context, and access to the allowed actions.

In practice, this means that your application remains a regular web application, but runs inside a Synchra.24 controlled container.

Step 1. Expand the finished example

Clone the repository:

git clone https://github.com/synchra24/app_example.git
cd app_example

Install the dependencies:

npm install

Run the project locally:

npm run dev

After that, the example will be available locally, usually via the Vite dev server.

If you just want to quickly check the logic in the browser, that's enough. But to run inside Synchra.24 need a public URL.

Step 2. Publish the application using a public URL

The internal service in the company opens url, which you specify when creating the service. Therefore, the application must be accessible from the outside.

Any familiar options will do.:

  • Vercel;
  • your nginx / static hosting;
  • test tunnel for dev verification;
  • any publication of the collected frontend over HTTPS.

For a production build:

npm run build

At this step, the result is simple: you should have a URL that opens app_example in the browser.

Step 3. Create an internal service in the company

Open the settings of the desired company in the mobile application and go to Services.

In the service creation form, fill in:

  • Title — what will the service be called for users;
  • Link — the public URL of the published app_example;
  • Icon — any suitable icon from the list;
  • Authorization — if necessary, if you want to restrict access to individual permissions;
  • Available to employees — either all or only selected users.

After Synchra is saved.24 will create a service and issue it for it service token.

This is the token your web application needs to work with bridge.

Step 4. Insert the service token in the example

An instance of the client is created inside example:

import { SynchraApp } from '@synchra24/app';

const synchra = new SynchraApp('SERVICE_TOKEN');

Replace SERVICE_TOKEN to a token that was created in the company's services section.

After that, republish the application or update the deployment if you changed the code locally.

Step 5. Open a service from the company

Now open the desired company in the mobile application and go to the applications/ services section.

Select the created service. If everything is set up correctly:

  • your account will open app_example inside Synchra.24;
  • isSynchraIntegrated() it will return true;
  • The application will be able to call bridge methods.;
  • The company's theme and context will be available inside the WebView.

Step 6. Check the basic integration

It is better to do the first smoke test on three things:

Checking the integration

const integrated = await synchra.isSynchraIntegrated();

If the method returns false That means:

  • the application is not open inside Synchra.24;
  • the service token is invalid;
  • or you have opened a regular web version without a bridge container.

Getting the provider context

const provider = await synchra.getProviderContext();

console.log(provider.provider_id);
console.log(provider.profile_id);
console.log(provider.role);

This step is useful because it immediately shows that the application is running in the right company and receives the user's working context.

Calling the snackbar

await synchra.showSnackbar({
  message: 'Интеграция работает',
  type: 'success',
});

This is an easy way to make sure that bridge is responding correctly.

What a ready-made example can already do

In app_example There are already examples of calling basic bridge methods.:

  • requestApi
  • getProviderContext
  • getGeoPosition
  • selectUsers
  • takePhoto
  • pickPhoto
  • pickFile
  • scanQr
  • selectDate
  • selectDateRange
  • selectTime
  • showSnackbar
  • openModal
  • navigate
  • getSynchraTheme
  • onSynchraThemeChange

That is, after launching, you no longer get an empty template, but a working sandbox for checking integration.

How to connect the service to your company correctly

In order for the service not to look just like an “external link”, it is usually worth thinking about right away:

  • who exactly will it be available to;
  • do I need a separate permission;
  • should it be open to all employees or only parts of the team?;
  • whether it should use the company's API, documents, tasks, users, or files.

If you have multiple roles, it is better to immediately restrict access so that only the right employees can see the service.

A typical path after a quick start

Usually, the team follows this scenario further.:

  1. Checks app_example as it is.
  2. Makes sure that the token and bridge are working.
  3. Changes the interface to fit your case.
  4. Connects the necessary API requests via requestApi.
  5. Adds roles, filters, forms, and scripts.
  6. Transfers the service from demo to a working internal tool.

What can be changed in the example in the first place?

If you want to quickly turn demo into your service, it usually makes sense to replace it first.:

  • main screen;
  • names of buttons and scripts;
  • demo method calls to your company's real APIs;
  • the texts and structure of the cards;
  • integration check and initial fallback.

Common reasons why the service is not working

Most often, the problem is one of these:

  • the wrong one is specified in the service. url;
  • the token is not substituted in SynchraApp(...);
  • the old version of the application has been published;
  • The service is not open inside Synchra.24, but in a regular browser.;
  • The required bridge method requires the device's system permissions.;
  • the user does not have access to the service by roles or permission.

The minimum result worth getting

If you follow this quick start, this scenario is considered a good first result.:

  • the service was created in the company;
  • example opens from Synchra.24;
  • isSynchraIntegrated() returns true;
  • getProviderContext() returns company data;
  • showSnackbar() and at least one additional bridge method is being worked out successfully.

After that, you already have a real working base for developing your own microapplication inside Synchra.24.