I have created a chat app and I'm using this library to handle push notifications when users share messages.
The is based on the logic of private and public keys, here's the workflow:
Generate a key pair once the user install the app, save locally the PRIVATE_KEY and upload to server the PUBLIC_KEY.
Send encrypted message to the server.
Once the server has received the message, it sends push notifications using the APNs for apple or FMC for google APIs.
The problem arise here, the content of the message is encrypted and the server can't decrypt it before sending the push notification since it doesn't has the PRIVATE_KEY of the user, and it's right.
So my solution is to send background notification to device and once received send a local notification with the decrypted message because I can access to the user's PRIVATE_KEY stored in the app.
The following method works fine to catch the remote background notifications, decrypt the body and send a local notification with readable content to the user:
But it only works if the app is open or in background.
Is there a way, like instagram or whatsapp do, to catch the remote push notification with encrypted body, decrypt it using local user private key and "update" the push notification content?
I know that a possible workaround is like Tinder does, using "USER sends you a message", but I'd like to make the content visible even if the app is closed.
I have created a chat app and I'm using this library to handle push notifications when users share messages. The is based on the logic of private and public keys, here's the workflow:
PRIVATE_KEY
and upload to server thePUBLIC_KEY
.The problem arise here, the content of the message is encrypted and the server can't decrypt it before sending the push notification since it doesn't has the
PRIVATE_KEY
of the user, and it's right.So my solution is to send background notification to device and once received send a local notification with the decrypted message because I can access to the user's
PRIVATE_KEY
stored in the app.The following method works fine to catch the remote
background
notifications, decrypt the body and send a local notification with readable content to the user:But it only works if the app is open or in background. Is there a way, like instagram or whatsapp do, to catch the remote push notification with encrypted body, decrypt it using local user private key and "update" the push notification content?
I know that a possible workaround is like Tinder does, using "USER sends you a message", but I'd like to make the content visible even if the app is closed.
Thank you.