47 lines
1.2 KiB
Java
47 lines
1.2 KiB
Java
package app.fedilab.android.helper;
|
|
|
|
import android.content.Context;
|
|
import android.util.Base64;
|
|
|
|
import org.unifiedpush.android.connector.Registration;
|
|
|
|
import java.util.List;
|
|
import java.util.Random;
|
|
|
|
import app.fedilab.android.activities.BaseMainActivity;
|
|
|
|
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 static void getDistributors(Context context) {
|
|
List<String> distributors = new Registration().getDistributors(context);
|
|
if (distributors.isEmpty()) {
|
|
|
|
} else {
|
|
|
|
}
|
|
}
|
|
|
|
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
|
|
|
|
|
|
}
|
|
}
|