46 lines
1.2 KiB
Java
46 lines
1.2 KiB
Java
package app.fedilab.android.services;
|
|
|
|
import android.content.Context;
|
|
|
|
import org.jetbrains.annotations.NotNull;
|
|
import org.jetbrains.annotations.Nullable;
|
|
import org.unifiedpush.android.connector.MessagingReceiver;
|
|
import org.unifiedpush.android.connector.MessagingReceiverHandler;
|
|
|
|
import app.fedilab.android.helper.PushNotifications;
|
|
|
|
class handler implements MessagingReceiverHandler {
|
|
@Override
|
|
public void onNewEndpoint(@Nullable Context context, @NotNull String s) {
|
|
PushNotifications push = new PushNotifications();
|
|
push.registerPushNotifications(context, s);
|
|
}
|
|
|
|
@Override
|
|
public void onRegistrationFailed(@Nullable Context context) {
|
|
// Toast ?
|
|
}
|
|
|
|
@Override
|
|
public void onRegistrationRefused(@Nullable Context context) {
|
|
// Toast ?
|
|
}
|
|
|
|
@Override
|
|
public void onUnregistered(@Nullable Context context) {
|
|
// Remove endpoint & ServerKey
|
|
}
|
|
|
|
@Override
|
|
public void onMessage(@Nullable Context context, @NotNull String s) {
|
|
PushNotifications push = new PushNotifications();
|
|
push.displayNotification(context, s);
|
|
}
|
|
}
|
|
|
|
class UnifiedPushService extends MessagingReceiver {
|
|
public UnifiedPushService() {
|
|
super(new handler());
|
|
}
|
|
}
|