Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Table of Contents



This article explains how to use APIs to creating PWA apps from a Master account available to partnersContain FULL partner API, but you only need this API if you create apps in bulk integrated with your other software solution!!!


For standard Partner reselling of 1-5 apps a day it makes no sense to integrate this API, as it is quicker to create such apps manually. 


NOTE - THE API IS FOR WRAPPER ONLY FOR NOW. THE API FOR JS CAPSULE IS IN WORKS.

Overall steps

You will need to:

  1. Complete basic auth to recieve JWT tokens
  2. Refresh JWT tokens according to our general API policy, as with any other Mobsted API call
  3. Use the methods described below to create our PWAless wrapping for the websites you need.

...

Image Removed


Your partner Mobsted account has ability to create PWA container apps in two ways: 

  • inside of your partner master account, all apps will be accessible from the same account, or
  • create client accounts, and then create PWA container Wrapper apps inside those new accounts



Info

NOTE - System app ID 1 in your Master account - is an important part of the system, which tracks all your “client accounts”, so please make sure you do not delete or modify that app in any way.

______________

(A) Pre-step: Authenticate your API calls

Use standard Mobsted methods to get JWT auth tokens for your API calls. After getting JWT tokens, use these tokens to perform the rest of “Web to PWA” APIs.

To receive JWT tokens, use the following API method with the login and password from your Mster account, an example:

GET https://ppp-admin.mbstmobsted.xyzcom/api/v8/[email protected]&password=12

...

Code Block
languagejs
GET https://ppp-admin.mbstmobsted.xyzcom/api/v8/auth?login=p@mobstedemail@mobsted.com&password=121234567


Where “ppp:

  • PPP-admin.

...

...

...

  • is the address of your server and your account at our server, provided by our team

...

  • "login" is the email you use to login into partner account
  • "password" is the password you use to login into partner account 


Receive access_token & refresh_token from response:

...

When sending the authenticated request, use it the ACESS_TOKEN in the auth header:

Code Block
languagejs
Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJwcHAtYWRtaW4ubWJzdC54eXoiLCJuYmYiOjE1OTg0xxxxxxxxxxxxxxxxxxxxxywidWlkIjoiMmIzZTRiN2ItODVjOC00MzEwLWE4MTctM2FlMGJiYzQyMWJmIiwic3ViIjoiYXBpIiwib2JqdXVpZCI6IiIsInVzZXJ1dWlkIjoiMTdmZWU2YTUtZDk4My00OWZkLTg4OWMtMWI1NjlkMTg3YWNmIn0.eVOoDwJ7yh_TVb2j7FW7_jsTKT_SMJ8CFL10NX6RyXQ

...

You can perform this auth action, starting with account’s login and password before every “client account/app” creation, but we advise to set up automatic JWT tokens refresh on your backend. 

___________


#1 API call - create a Client account/tenant


This method is called in contexts of your Master account/tenant, meaning using API address and tokens from your Master. This method only work if our team marked your account as Master/Partner.

...

Code Block
languagejs
POST https://ppp-admin.mbst.xyz/api/v8/partners

Type of parameters: raw (json)

An example:

{

    "email": "[email protected]"

}


Where, email is the email of who will access this new Client Account. It has to be a new unique email for every new sub account/tenant.

...

Code Block
languagejs
“url”: “https://a23r56k8-admin.mobsted.com”,

"authentication": {

     "email": "[email protected]",

                     "phone": "",

                          "password": "10ce7d73ae5fcc39g7064adc1ad03a03"

...

To use all other API methods, including to create an app in THAT NEW ACCOUNT, you need to receive JWT tokens for each of those accounts using the PRE-STEP above with address and login-password pair for that sub account.


____________

#2 Creating the

...

Wrapper Type App in Master or Client sub-account


Call this method in the context of either Master or Client account, depending on where you wish to create a PWA container app. Meaning - use address and auth tokens of the right account (Master or Client). Use only JWT tokens from method (A) above, for the targeted account.

...

Info

PLEASE NOTE - there are 3 similar fields with a family name “Widget”. 

The first - widgetDescription fills up data for the instant app saving prompt; second and third - pushWidgetDescription and saveWidgetDescription REPLACE default generic context of the managed prompts, created in each app automatically. These Push and Save fields ARE NOT REQUIRED to create an app, but we highly recommend filling these up as well, as changing it latter is slow and cumbersome..

The INSTANT method is enough for the most cases, but if you need to offer different context for saving the app, you could use MANAGED prompts and all it at the right times when needed, using API а call #4 below. Here is a useful table summarizing which prompt works where. If you need more than one context for Push prompt - contact our support. 

All three fields accept HTML only and the code example you see above would provide the following app saving prompts if you put it into WidgetDescription or saveWidgetDescription:

Image RemovedImage Added


The response to the call is:

...

  • unique ID of each app, so in case you wish to store matching pairs between your clients and container apps you could use “applicationId” or “id” (these are the same).


___________


#3 Searching for previously created sub-accounts/tenants


In case you create apps in sub accounts and do not store any info at your backend, you will need to create apps in it using those accounts login/pass pairs. To find the sub account you pre-created use the following method:

...

Code Block
languagejs
"data": [

        {

            "id": "1",

                "Email": "[email protected]",

                "ServerName": null,

                "TenantName": null,

                "UserLogin": null,

                "UserPassword": null,

            }

        }

    ]

    


___________

#4 Calling the “Managed” prompt/widget for Push and or Saving the app


This method is mostly needed for receiving Push permissions from a user, but is standard to call both Push and Saving prompts, when a user is inside the PWA container. It is a call from your resource to the container itself. 

...

showwidget: user a code-name for the widget ( ‘push’ and ‘save’ are default code names for the 2 pre-created ones), or you can find it in the platform (red mark ↓), when you add more prompts:

Image RemovedImage Added



If you need to close the prompt/widget that you have just opened, use the following:

Code Block
languagejs
parent.postMessage({ type: 'mobsted.api', hidewidget: 'push' }, '*'), 


______________

#5 Detecting if an App was already installed on the device's home screen.

You need this method in case you want to hide “Save our app” type buttons and popups at your website’s interface, when people who already installed the app are on your website or visiting the container from it’s weblink, not from an icon.

...

Info

NOTE - The only 100% fact of the app installed is at least one entry to the app by the user for both Android and iOS. All other data on installation differs in meaning between various versions of OS/browser combinations and are intentionally left out of the response

____________

#6 Sending Push messages to your users


There is a separate article on this subject - here. 

...