...
This article explains how to use APIs to creating PWA apps from a Master account available to partners.
Overall steps
You will need to:
- Complete basic auth to recieve JWT tokens
- Refresh JWT tokens according to our general API policy, as with any other Mobsted API call
- Use the methods described below to create our PWAless wrapping for the websites you need.
...
The overall logic is on a drawing below:
...
Your partner Mobsted account has ability to create PWA container apps in two ways:
...
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.
...
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.
...
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 converted App in Master or Client 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: |
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 | ||
---|---|---|
| ||
"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:
If you need to close the prompt/widget that you have just opened, use the following:
Code Block | ||
---|---|---|
| ||
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.
...