Push Notifications
WalletKit provides the functionality for wallets to receive push notifications through Firebase Cloud Messaging (FCM) and Apple Push Notification Service (APNs) via the Push Server. This feature ensures that wallets are promptly notified of incoming signature requests. Each push notification contains the encrypted details of the signature request. Upon receiving the notification, it can be decrypted and presented to the developer, allowing for customization of the message according to their requirements.
Server setup
For the push notifications to be forwarded to FCM or APNs, the Push Server will need to be configured with your FCM or APNs server API credentials.
App setup
Register the device token
To enable a device for push notifications, it’s essential to register the device token using walletKit.registerDeviceToken
. This token can be obtained from either FCM or APNS, depending on the platform used.
To receive push notifications from WalletConnect’s Push Server via Firebase Cloud Messaging, you will need to setup Firebase in your project.
You can follow their documentation - Firebase documentation.
Once you have Firebase configured, you can obtain the device token by calling messaging().getToken()
. This unique token is used to identify each device.
The device token will be used to register for WalletConnect push notifications by calling walletKit.registerDeviceToken
and passing the token as an argument.
The registerDeviceToken
should be called every time the client is initialized.
With that the base setup is complete and you can start receiving push notifications from WalletConnect’s Push Server for your sessions.
Note, that from time to time, the device token is refreshed, so you must make sure to register it again.
Receiving push notifications
After the device token is registered, the next step involves setting up the notification service specific to the platform being used. This service will decrypt the incoming requests and forward them to the developer for further processing and integration.
To receive the actual push notifications, you will need to subscribe to firebase messaging events.
Now that we have the notifications listeners setup, we can start processing the incoming notifications.
Was this page helpful?