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.
This method enables wallets to receive push notifications from WalletConnect’s Push Server via Firebase Cloud Messaging. This means you will have to setup your project with Firebase before being able to call registerDeviceToken()
method.
To register a wallet to receive WalletConnect push notifications, call WalletKit.registerDeviceToken
and pass the Firebase Access Token.
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.
The PushMessagingService
is a wrapper around the FirebaseMessagingService
. The PushMessagingService
class needs to be implemented for WalletKit to be able to decrypt and notify wallets of a push notification sent from the Dapp in the background. This service also needs to be registered in the AndroidManifest.xml
file similar to the example in the FCM documentation.
Was this page helpful?