mirror of
https://codeberg.org/tom79/Fedilab.git
synced 2025-03-27 09:09:57 +02:00
Unregister push endpoint onUnregistered
This commit is contained in:
parent
b26b10c651
commit
ec60b63c68
2 changed files with 25 additions and 1 deletions
app/src/main/java/app/fedilab/android/mastodon
|
@ -45,6 +45,23 @@ import retrofit2.converter.gson.GsonConverterFactory;
|
|||
|
||||
public class PushNotifications {
|
||||
|
||||
public static void unregisterPushNotifications(Context context, String slug) {
|
||||
new Thread(() -> {
|
||||
String[] slugArray = slug.split("@");
|
||||
BaseAccount accountDb = null;
|
||||
try {
|
||||
accountDb = new Account(context).getUniqAccount(slugArray[0], slugArray[1]);
|
||||
} catch (DBException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
if (accountDb == null) {
|
||||
return;
|
||||
}
|
||||
MastodonNotificationsService mastodonNotificationsService = init(context, accountDb.instance);
|
||||
mastodonNotificationsService.deletePushsubscription(accountDb.token);
|
||||
});
|
||||
}
|
||||
|
||||
public static void registerPushNotifications(Context context, PushEndpoint pushEndpoint, String slug) {
|
||||
|
||||
|
|
|
@ -56,6 +56,13 @@ public class PushServiceImpl extends PushService {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void onUnregistered(@NonNull String s) {
|
||||
public void onUnregistered(@NonNull String slug) {
|
||||
Context context = getApplicationContext();
|
||||
if (context != null) {
|
||||
synchronized (this) {
|
||||
PushNotifications
|
||||
.unregisterPushNotifications(context, slug);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue