fedilab-Android-App/app/src/main/java/app/fedilab/android/helper/PushNotifications.java

46 lines
1.3 KiB
Java
Raw Normal View History

2021-02-21 17:18:37 +01:00
package app.fedilab.android.helper;
import android.content.Context;
import android.util.Base64;
2021-02-23 18:34:58 +01:00
import org.unifiedpush.android.connector.Registration;
import java.util.List;
2021-02-21 17:18:37 +01:00
import java.util.Random;
2021-02-23 18:34:58 +01:00
import app.fedilab.android.activities.BaseMainActivity;
2021-02-23 19:08:45 +01:00
import app.fedilab.android.client.Entities.Account;
2021-02-23 18:34:58 +01:00
2021-02-21 17:18:37 +01:00
public class PushNotifications {
2021-02-23 19:08:45 +01:00
public void registerPushNotifications(Context context, Account account, String endpoint, String server_key) {
2021-02-21 17:18:37 +01:00
ECDH ecdh = new ECDH();
2021-02-23 19:08:45 +01:00
String pubKey = ecdh.getPublicKey(context, account);
2021-02-21 17:18:37 +01:00
byte[] randBytes = new byte[16];
new Random().nextBytes(randBytes);
String auth = Base64.encodeToString(randBytes, Base64.DEFAULT);
//register
ecdh.saveServerKey(context, server_key);
}
2021-02-23 18:34:58 +01:00
public static void getDistributors(Context context) {
List<String> distributors = new Registration().getDistributors(context);
if (distributors.isEmpty()) {
} else {
}
}
2021-02-23 19:08:45 +01:00
public void displayNotification(Context context, Account account, String ciphered) {
2021-02-21 17:18:37 +01:00
ECDH ecdh = new ECDH();
2021-02-23 19:08:45 +01:00
byte[] secret = ecdh.getSecret(context, account);
2021-02-21 17:18:37 +01:00
//process with the event
// https://openacs.org/webpush-demo/report.html
// decrypt using AES 128 GCM
}
}