lightning-kmp icon indicating copy to clipboard operation
lightning-kmp copied to clipboard

Server ACK for FCM token registration

Open robbiehanson opened this issue 4 years ago • 0 comments

There is currently a mechanism for registering FCM tokens with the server. (For push notifications.) This is already implemented, but could be improved.

Theoretically, the (node_id, fcm_token) tuple only needs to be registered once. And after that, only if the tuple changes (e.g. different fcm_token). However, in practice, this optimization isn't feasible for the client. Since the server doesn't send any kind of ack/confirmation, the client doesn't have a clean hook with which it can say, "OK, FCM token xyz has been successfully registered. I'm now free to optimize the client flow to skip sending the FCM token next time."

Because the server doesn't send an ack/confirmation, the client-side registers the FCM token every app launch.

I originally thought this was a minor optimization, but a recent phoenix-kmm issue has me re-thinking this.

The issue was that:

  • there was a bug in the kotlin code that resulted in the FCM token not being sent to the server
  • without the ACK, the user interface has no way of knowing whether or not the token has been properly registered
  • we generally only discover the bug after we start missing incoming payments

If the server sends an ack/confirmation, then the clients can be updated to display this confirmation somewhere within the user interface. I think this would prove very helpful, especially for debugging background payments. I can imagine receiving bug reports from users:

"I can't receive a payment when Phoenix is running in the background?!?! Help me!"

It would be wonderful if we could say respond with something like:

"Go into settings and tap on X. Does it say 'push token registered' ?"

robbiehanson avatar Feb 04 '21 16:02 robbiehanson