alpha-wallet-android
alpha-wallet-android copied to clipboard
Implement push notification
Summary: upon silent/data push, fetch transaction history in the background and if we can find the transaction (why not?), show the user a notification
- AlphaWallet apps calls and the server endpoint to register a wallet 0xb0b
- Server monitors 0xb0b for change of receive of native crypto, ERC-20, ERC-721, ERC-1155
- Server sends a silent push to all AlphaWallet apps device tokens that registered for 0xb0b
- Upon receive a silent push for 0xb0b, AlphaWallet apps fetches/refreshes transaction history for 0xb0b in the background
- AlphaWallet displays a notification that "0xb0b has received X ETH" or "0xb0b has received Some App 123"
- User tap the notification to see that transaction/activity
- Verify we get notifications for receiving of native crypto, ERC-20, ERC-721, ERC-1155 (did I miss anything?) on Ethereum mainnet.
- iOS test getting pushes too like Android did
- We build it in AlphaWallet and try it for a few hardcoded wallets that we own. Ship it
- Extend it to more people or everyone (depending on confidence level and how much work to rollout) and ship it.
Makes sense? Did I miss anything? So I think you can proceed with (1) and (3) and on iOS side, we'll do (1) and (2).
Just to be safe, remember gate it with a feature flag in case it isn't ready.
Just to add more information -
There are two things needed to start receiving data messages:
- Call the server endpoint via
POST /subscriptions - Subscribe to topic via Firebase. The string format is
{wallet}-{chainId}e.g0xb0b-1
This is a sample data message:
{
"body": {
"to": "0x11b815efB8f581194ae79006d24E0d814B7697F6",
"from": "0x96974F62Ce2a72959e9B1A682886D70E20B51A0c",
"chain": 1,
"event": "transfer",
"contract": "0xdAC17F958D2ee523a2206206994597C13D831ec7",
"blockNumber": 16879409,
"contractType": "erc20"
},
"title": {
"contract": "0xdAC17F958D2ee523a2206206994597C13D831ec7",
"wallet": "0x11b815efB8f581194ae79006d24E0d814B7697F6",
"createdAt": "1679442974168",
"chainId": "1",
"event": "transfer"
}
}
If it's a swap from X to Y token. What notifications do we get?
- AlphaWallet apps calls and the server endpoint to register a wallet 0xb0b
do we send request to this endpoint only when we create a new wallet, and when register already created wallet. do we need to handle on client wether we've registered wallet or we able to make multiple calls? or response of POST /subscriptions would return subscriptions mapped to wallet address, and chain id?
do we need to handle server changing here enable/disable with calling appropriate method subscribe/unsubscribe for each subscribed wallet?
AlphaWallet apps calls and the server endpoint to register a wallet 0xb0b
do we send request to this endpoint only when we create a new wallet, and when register already created wallet. do we need to handle on client wether we've registered wallet or we able to make multiple calls? or response of POST /subscriptions would return subscriptions mapped to wallet address, and chain id?
Make the registration calls as soon as (or delay if there's a good reason) we know the user creates or imports a wallet. This is for the server to start fetching and tracking transactions for that wallet. BTW, only Ethereum mainnet is supported at the moment, but I think we don't have to specifically handle that in the app.
do we need to handle on client wether we've registered wallet or we able to make multiple calls?
If this is to handle the case where we tried to register but failed or didn't make the call, then yes, we should be able to handle that. The servers should handle multiple invocations. So I guess we can check after making the register call and if it's successful, set a flag. Subsequently only call if that local flag is false?
do we need to handle server changing here enable/disable with calling appropriate method subscribe/unsubscribe for each subscribed wallet?
Server as in user changing which changes are enabled? — Then, no.
I don't think there's an unsubscribe function, yet :P
do we need to handle server changing here enable/disable with calling appropriate method subscribe/unsubscribe for each subscribed wallet?
Server as in user changing which changes are enabled? — Then, no.
I don't think there's an unsubscribe function, yet :P
Unsubscribe function is available too :)
Haha. When do you call it?
Haha. When do you call it?
For now, when wallet is deleted
@justindg could u please share a base url for subscriptions, in case u have it, and wallet address for testing, in dm please.