Skip to content

Commit

Permalink
Merge pull request #117 from breez/android-notifications
Browse files Browse the repository at this point in the history
android notifications docs
  • Loading branch information
roeierez authored Jan 11, 2024
2 parents 45f13c7 + 0af5b54 commit 7fcd256
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
18 changes: 18 additions & 0 deletions src/guide/android_notification_foreground_service.md
Original file line number Diff line number Diff line change
@@ -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).
2 changes: 2 additions & 0 deletions src/guide/payment_notification.md
Original file line number Diff line number Diff line change
Expand Up @@ -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).

0 comments on commit 7fcd256

Please sign in to comment.