@appyourself/widget-mobile-app-service

AppYourself iframe widget

Usage no npm install needed!

<script type="module">
  import appyourselfWidgetMobileAppService from 'https://cdn.skypack.dev/@appyourself/widget-mobile-app-service';
</script>

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 a key is 1500 bytes, where the value 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.