@appyourself/widget-mobile-app-service
v0.3.6
Published
AppYourself iframe widget
Downloads
139
Readme
AppYourself Mobile App Widget
Javascript module, which allows an iFrame to communicate with AppYourself app (both native and webapp).
Usage
Using ES6 module
import { MobileAppService } from '@appyourself/widget-mobile-app-service';
...
// get user id
const userId: string = await MobileAppService.getUserId();
// set custom data
await MobileAppService.setUserData('customDataKey', 'lorem ipsum');
// read custom data, should setup `lorem ipsum` string
const customUserData: string = await MobileAppService.getUserData('customDataKey');
Use JSON.stringify
and JSON.parse
if you want to get/set the whole object at once.
API
static isActive(): Promise<boolean>
- Check if the app is responding.static getUserId(): Promise<string>
- Get the unique mobile app user id.static getUserData(key: string): Promise<string>
- Get any custom user data, that has already been persisted by the website.static setUserData(key: string, value: string): Promise<void>
- Set any custom user data. The maximum size of akey
is 1500 bytes, where thevalue
can reach the max of 1,048,576 bytes (~ 1 MB).
Debug mode
All methods contain a debug boolean flag, that can be enabled to log communication details. Don't use on production!
await MobileAppService.isActive(true);
await MobileAppService.getUserId(true);
Further help
Please contact our support AppYourself Support.