Merge pull request #117 from breez/android-notifications

android notifications docs
This commit is contained in:
Roei Erez
2024-01-11 14:00:18 +02:00
committed by GitHub
3 changed files with 21 additions and 0 deletions

View File

@@ -11,6 +11,7 @@
- [Listing payments](guide/list_payments.md)
- [Receiving payments via mobile notifications](guide/payment_notification.md)
- [iOS](guide/ios_notification_service_extension.md)
- [Android](guide/android_notification_foreground_service.md)
- [Connecting to an LSP](guide/connecting_lsp.md)
- [Receiving an on-chain transaction](guide/receive_onchain.md)
- [Sending an on-chain transaction](guide/send_onchain.md)

View File

@@ -0,0 +1,18 @@
# Android: using foreground service
For Android, the app is required to use a foreground service to process reliably notifications in the background.
## Implementation steps
#### 1. Integrate foreground service
Add FirebaseMessagingService to your Android project. This service allows your app to process the incoming push notification. Then use the foreground service to process the notification in the background.
#### 2. Wake-up the app
When a push notification is received, the FirebaseMessagingService will be triggered, running the forground service.
#### 3. Connect with Breez SDK
In the foreground service, establish a connection with the Breez SDK to process the incoming payment.
#### 4. Wait for payment completion
Once connected, the app should wait for completion status from the Breez SDK that the payment has been received.
#### 5. Display a notification
After confirming the payment, display a notification.
## Reference implementation
For a complete reference, see how we implemented it in c-breez wallet: [BreezFcmService.kt](https://github.com/breez/c-breez/blob/main/android/app/src/main/kotlin/com/cBreez/client/BreezFcmService.kt).

View File

@@ -110,3 +110,5 @@ Register the constructed URL with the Breez SDK By calling the register-payment-
### Step 4: Handling notifications when the app isn't running
To ensure that your mobile application can handle payment notifications even when it is not actively running, specific implementations are required for both iOS and Android platforms. This involves waking up the app upon receiving a push notification, connecting with the Breez SDK, and then waiting for the payment to be fully received.
* For iOS, please follow the steps in [iOS NotificationServiceExtension](ios_notification_service_extension.md).
* For Android, please follow the steps in [Android foreground service](android_notification_foreground_service.md).