32 lines
893 B
Java
32 lines
893 B
Java
|
package app.fedilab.android.helper;
|
||
|
|
||
|
import android.content.Context;
|
||
|
import android.util.Base64;
|
||
|
import java.util.Random;
|
||
|
|
||
|
public class PushNotifications {
|
||
|
public void registerPushNotifications(Context context, String endpoint) {
|
||
|
ECDH ecdh = new ECDH();
|
||
|
String pubKey = ecdh.getPublicKey(context);
|
||
|
byte[] randBytes = new byte[16];
|
||
|
new Random().nextBytes(randBytes);
|
||
|
String auth = Base64.encodeToString(randBytes, Base64.DEFAULT);
|
||
|
|
||
|
//register
|
||
|
|
||
|
String server_key = ""; //fetch in the json
|
||
|
|
||
|
ecdh.saveServerKey(context, server_key);
|
||
|
}
|
||
|
|
||
|
public void displayNotification(Context context, String ciphered) {
|
||
|
ECDH ecdh = new ECDH();
|
||
|
byte[] secret = ecdh.getSecret(context);
|
||
|
//process with the event
|
||
|
// https://openacs.org/webpush-demo/report.html
|
||
|
// decrypt using AES 128 GCM
|
||
|
|
||
|
|
||
|
}
|
||
|
}
|