mirror of
https://github.com/aljazceru/breez-sdk-docs.git
synced 2025-12-18 22:34:19 +01:00
Merge pull request #117 from breez/android-notifications
android notifications docs
This commit is contained in:
@@ -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)
|
||||
|
||||
18
src/guide/android_notification_foreground_service.md
Normal file
18
src/guide/android_notification_foreground_service.md
Normal 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).
|
||||
@@ -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).
|
||||
|
||||
Reference in New Issue
Block a user