Currently, to be able to implement a notification flow for a certain app, this app must be registered in the push gateway config. This can result in a centralization point for developers who want to use such feature and some expenses and efforts on support of the current gateway.
For the Polygon ID wallet, this push service is used: http://push.polygonid.me.
Current notification flow:
- User creates a device push token. After scanning the authorization request, the user must prepare an authorization response according to the current rules, but with an addition: the inclusion of the DID document. This DID document contains the user DID and service to send push notifications. The user encrypts the device push token with the Push Gateway public encryption key and embeds it onto the DID document.
- Verifier sends a message to Push Gateway with information from the user DID document.
- Push Gateway decrypts push token, stores messages, and sends the push notification to the wallet.
- The wallet gets the message with the message ID and PPG URL. The application fetches notifications from the service, handles protocol messages and asks the user if he wants to perform a needed action, e.g. fetch credential.
- wallet - mobile application published by Polygon.
- verifier - backend for Polygon Verify application that verifies user documents.
- Push Gateway (PG) - service to deliver push notifications to the wallet app.
- Push notification - notification that contains a link to protocol message or protocol message itself that is delivered through the notification provider.
How to run a server
- Go to this link and follow the instructions to run your own push notification service.
- For a Push Gateway service a sygnal is used. Sygnals can send notifications to Android and Apple devices. For Android devices, a sygnal has integration with FCM; for Apple devices, the sygnal has APNS integration. Also, we can add any other provider like SNS. For this we must implement the next flow.
- Default algorithm for encryption is
- Register your application on a Firebase provider and update config.
- Get public key of notification service for further encryption actions.
How to send an AuthorizationResponse from mobile with push information
- Create a simple DID document
You can add information about keys / authentication info optionally. Follow this specification
- Create encrypted device information. Device information must be a valid JSON and encrypted with the public key of the Push Gateway. Apply base64 encoding to encrypted byte array. An encryption key must be used from the notification service.
"pushkey": "push key",
Add push service for DID document to service section
Include the DID document as a
did_docfield in the authorization response message https://iden3-communication.io/authorization/1.0/response/ Notification message format that is expected to be sent to mobile. URL field is a valid URL to fetch a message. Fetch request must be HTTP GET request with no authorization required. The message is available for 24 hours on Push gateway or deleted after the fetch request.
How to send a push from verifier
Parse a dDIDd document from the authorization response
Proxy device info to push service using serviceEndpoint using the following format
- Message is the protocol message that is meant to be delivered to users
- Devices is an object from the push notification service from user DID document
"message": "JSON stringlied message",