## Capacitor version Currently supported capacitor version is **v5.*** ## Supported capacitor plugins 1. [Capacitor Http](https://capacitorjs.com/docs/apis/http) and [Capacitor Cookies](https://capacitorjs.com/docs/apis/cookies) are enabled by default as part of [@capacitor/core](https://www.npmjs.com/package/@capacitor/core?activeTab=versions) package 2. [@capacitor/app](https://capacitorjs.com/docs/apis/app) 3. [@capacitor/haptics](https://capacitorjs.com/docs/apis/haptics) 4. [@capacitor/keyboard](https://capacitorjs.com/docs/apis/keyboard) 5. [@capacitor/geolocation](https://capacitorjs.com/docs/apis/geolocation) 6. [@capacitor/camera](https://capacitorjs.com/docs/apis/camera) 7. [@capacitor/status-bar](https://capacitorjs.com/docs/apis/status-bar) 8. [@capacitor/preferences](https://capacitorjs.com/docs/apis/preferences) 9. [@capacitor/browser](https://capacitorjs.com/docs/apis/browser) 10. [@capacitor/share](https://capacitorjs.com/docs/apis/share) 11. [@capacitor/filesystem](https://capacitorjs.com/docs/apis/filesystem) 12. [@capacitor/clipboard](https://capacitorjs.com/docs/apis/clipboard) 13. [@capacitor/device](https://capacitorjs.com/docs/apis/device) 14. [@capacitor-community/sqlite](https://github.com/capacitor-community/sqlite) 15. [@capacitor/local-notifications](https://capacitorjs.com/docs/apis/local-notifications) ## Initial Context Initial Context is an application configuration that defines the set of attributes passed to the web application upon launch and required to complete initialization. can be retreived using `getInitialContext` function from `@ionic/portals` package | Attribute Name | Attribute Type | Description | | --- | --- | --- | | url | String | URL of the partner backend environment used by application to fetch and update data | | authToken | String | auth token issued to mobile app user that should be used to authenticate web application requests to the partner backend | | language | String | User locale. Default is “en-US” | | startingRoute | String | Initial URL of web application opened after launch. The value depends on the feature presentation type (e.g. whether it is opened in fullscreen mode or as a widget, **/home** or **/widget**) | | lightPrimaryColorprimaryColorprimaryTextColorsecondaryColordashboardBackgroundColor | String | Color scheme used to render application content. Support of dynamic colors allows to simplify customization to different clients and share a common look & feel between web and native parts. Represented as 6 digits HEX code starting with # (e.g. “#00C4DC”) | | showLogger | "true" | "false" | Show or hide [egym mwa logger](https://github.com/egym/lib-mwa-logger) - the logic should be implemented | | exerciserUuid | UUID | Exerciser Id | | gymLocation | UUID | Id of the user's home location | | gender | "MALE" | "FEMALE" | Gender of the exerciser | | measurementSystem | "METRIC" | "IMPERIAL" | Measurement system configured by the user in the profile settings | | dateOfBirth | YYYY-MM-DD | Exerciser's date of birth | | email | test@mailinator.com | Exerciser's email | | linking | Example: { ..., "linking": { "status": "linked", "egymEmail": "test@mailinator.com", }, ... } | EGYM ID linking | | preferences | Example: { ..., "preferences": { "localizedTitle": { en: "hello", de: "hallo", ... }, "showLogWorkoutButton": true, }, ... } | Preferences for the MWA widget set in BMA dynamic feature framework config. **Fields provided only if they configured in the DFF config** | | mwaProtocolVersion | 1.0 | version of Native<->MWA interface communication useful for resolving backward compatibility issues | ## Native <-> web interface/commands The table below provides details about supported commands Request data identifies the command has corresponding publish API, which can be sent by using `publish` function from `@ionic/portals` Response details identifies the command has corresponding subscription API, which can be read by using `subscribe` function from `@ionic/portals` | Command Type | Description | Request Data (publish) | Response Details (subscribe) | | --- | --- | --- | --- | | authToken | Request authentication token for app user, can be used for refresh token functionality | data: { "type": "authToken", "data": null,}, | User identity token that can be used to authenticate user in partner backend | | exerciserInfo | Request [exerciser profile data](#exerciser-profile-data) | data: { "type": "exerciserInfo", "data": null,}, | Exerciser profile as described in data model section | | openFeature | Navigate to web app feature by tapping on a widget | Payload should include relative feature URL opened in web app data: { "type": "openFeature", "data": { "startingRoute": "/classes/:id:" } } | | | openNativeFeature | Navigate to a native app feature inside of BMA application | Payload should include unique feature identifier data: { "type": "openNativeFeature", "data": { "featureId": "advancedChallenges" } } | | | openWebView | Display webview and define closing action to send redirect URL back to web application. Each redirect URL will be checked against set of patterns passed in "endFlowUrlPatterns" payload section | Payload should include starting URL and URL patterns checked for redirect chain data: { "type": "openWebView", "data": { "url": "https://example.com/", "endFlowUrlPatterns": [ "https://example.com/success", "https://example.com/failure" ] }} | URL matching to one or multiple requested patterns | | openUrlExternally | Open passed URL in native browser and send back a configuration whether user navigated to that URL | URL to be opened in native browser data: { "type": "openUrlExternally", "data": { "url": "https://example.com/" }} | Boolean indicating if URL was opened in native browser | | trackEvent | Request native app to track Analytics event | Payload should include event name (required) and parameters (optional) data: { "type": "trackEvent", "data": { "name": "Book_A_Class", "parameters": [ "source": "classes_list", "trainer_details_available": "true" ] }} | | | dismiss | Request native app to close MWA screen | data: { "type": "dismiss",}, | | | contentLoadingDidFinish | Request native app to hide skeleton loader on custom MWA widget | data: { "type": "contentLoadingDidFinish",}, | | | setWidgetHeight | Set widget height dynamically | data: { "type": "setWidgetHeight", "data": { height: 200 } }, | | | linking | Request native app to provide EGYM ID linking details | data: { "type": "linking",}, | Subsciption to "linking" event - returns the same data structure as in the initial context - "linking": { "status": "linked", "egymEmail": "test@mailinator.com",}, | | refresh | Notify MWA that the webview was reactivated, e.g. device went back from background, user returned back to BMA dashboard | | Only native to web. Only iOS. On Android use an alternative builtin method in @capacitor/app - [resume event](https://capacitorjs.com/docs/apis/app#addlistenerresume-) | In case of command failure, native application will return error object as shown in the following example ```json { "type": "openUrl", "code": 404, "url": "https://example.com/", "message": null } ``` Required `type` attribute will identify the failed command. Optional code, url and message fields will be populated depending on a command and provide details of failed request. ### Exerciser Profile Data In order to obtain the profile details of an authenticated app user, it is necessary to send the `exerciserInfo` command to the native mobile application through the [Portals Plugin](#portals-plugin). The table below describes the available attributes: | Attribute Name | Attribute Type | Description | | --- | --- | --- | | gymLocationId | UUID | Identifier of exerciser’s gym location. | | email | String | User email | | firstName | String | User first name | | lastName | String | User last name | | userLocale | String | Locale of user | | tenantLocale | String | Locale of gym brand | | userPicture | String | URL of profile image specified by user | | membershipSubType | String | Type of the user membership as defined in gym membership system | | membershipStatus | String | Status of user membership in gym membership system | | startOfContract | Timestamp | Start date of membership contract | | endOfContract | Timestamp | End date of membership contract |