This documentation is for BIDMC Digital Psychiatry internal use only.
The mindLAMP apps for both iOS and Android enable two additional features beyond what is offered by simply logging into the dashboard and bookmarking the tab on the user's mobile device:
- sensor data collection, and
- push notification scheduling for Activities.
However, sending a push notification from a LAMP server to a mobile device requires encrypted communication with official Apple and Google gateway servers (called Apple Push Notification Service, or APNS, and Google Firebase Cloud Messaging, or FCM). These gateways are only authorized to receive push notification requests from servers with an approved developer certificate (a file with the extention
.p12) and developers must be granted access to this feature.
Apple and Google both require BIDMC Digital Psychiatry to maintain records of approved IRB documents or clinical protocols (if not a research study) to allow external collaborators' LAMP servers to communicate with the native iOS and Android apps. This is because both apps are published under
John Torous's developer accounts.
As a result, the LAMP Platform includes an App Gateway component (located at
app-gateway.lamp.digital) that acts as an intermediary:
- A patient logs in to the mindLAMP iOS app on a collaborator's LAMP server.
- The collaborator's LAMP server schedules push notifications to be sent to the new iOS device registered.
- At time of notification, the collaborator's LAMP server sends the notification to the App Gateway hosted by BIDMC.
- This notification request contains the collaborator's unique API Key. These API Keys should NEVER be shared with others.
- The App Gateway verifies the included notification's API Key but does NOT have access to the notification contents, to ensure privacy.
- If the API Key is valid, the App Gateway forwards the notification request to either Apple or Google servers automatically.
- If the API Key is NOT valid, an error message is returned to the collaborator's LAMP server.
This App Gateway component MUST NOT be self-hosted by external collaborators, unless they also intend to self-publish the iOS and Android apps as well (which is highly discouraged). The App Gateway supports multiple destinations, and each has a unique
- Apple Push Notification Service (iOS/macOS devices;
- Google Firebase Cloud Messaging (Android devices;
- Amazon Web Services Simple Email Service (Email;
- Amazon Web Services Simple Notification Service (SMS;
- Slack Webhooks (Slack channels;
External collaborators are NOT PERMITTED to use
slack: destinations. More information on sending messages through the App Gateway from the command line can be found here.
Generating API Keys
To allow external collaborators to send push notifications to users' iOS and Android devices, the following steps must be completed:
- collaborator organization must complete the consortium enrollment form
- collaborator organization must make the request for an API Key on the community forum (emailed requests ARE NOT PERMITTED)
- a BIDMC team member must save this information to the
Projects → LAMP Platform → Documents → People Pipeline → Consortium Membersdatabase in the internal team Notion.
- the BIDMC team member must generate a new API Key in the terminal using this command:
openssl rand -base64 12
- An API Key is actually just a randomly generated string to uniquely identify an external collaborator, and contains no other information.
- Should an API Key need to be replaced, a new one can be generated and replaced in this database (but all previously generated keys must be recorded in the
- the BIDMC team member must add this API Key to the App Gateway service in the internal Docker console (located at
- Once logged in, locate
mindLAMP → Stacks → LAMP → Editor (tab)and scroll down to find
- Edit this YAML configuration under
environment → API_KEYS: add the new API Key at the end of this list, separated by a comma. (DO NOT include a trailing comma.)
- Press the
Update the Stackbutton.
- Once logged in, locate
- the BIDMC team member should respond to the collaborator organization via private DM on the forum with this new API Key.
- the collaborator organization fills in the API Key in their LAMP Platform configuration (see here for more info)
Should an API Key be revoked, follow the above procedures to remove the API Key from the Docker console and notify the external collaborator organization.
The utility functions provided by Cortex should be preferred over making raw API calls to the App Gateway. However, an example of the raw API call using
cURL is provided below.
curl -XPOST "https://app-gateway.lamp.digital/push" \
-H 'Content-Type: application/json' \
--data-binary @- <<'EOF'
"alert": "Hello world!",
The flow of data is shown below:
Automations Worker component handles all push notification scheduling working in tandem with the API Server using the
LAMP-js SDK. It caches CRON expressions matching to Activity IDs and Participant IDs for delivery. The workflow is shown below: