Clean up pushers on start
This commit is contained in:
parent
975fb1a45c
commit
a6af658501
|
@ -22,6 +22,9 @@ abstract class FirebaseController {
|
|||
static const String CHANNEL_ID = 'fluffychat_push';
|
||||
static const String CHANNEL_NAME = 'FluffyChat push channel';
|
||||
static const String CHANNEL_DESCRIPTION = 'Push notifications for FluffyChat';
|
||||
static const String APP_ID = 'chat.fluffy.fluffychat';
|
||||
static const String GATEWAY_URL = 'https://janian.de:7023/';
|
||||
static const String PUSHER_FORMAT = 'event_id_only';
|
||||
|
||||
static Future<void> setupFirebase(Client client, String clientName) async {
|
||||
if (Platform.isIOS) iOS_Permission();
|
||||
|
@ -39,17 +42,45 @@ abstract class FirebaseController {
|
|||
);
|
||||
return;
|
||||
}
|
||||
final pushers = await client.getPushers();
|
||||
final currentPushers = pushers.where((pusher) => pusher.pushkey == token);
|
||||
if (currentPushers.length == 1 &&
|
||||
currentPushers.first.kind == 'http' &&
|
||||
currentPushers.first.appId == APP_ID &&
|
||||
currentPushers.first.appDisplayName == clientName &&
|
||||
currentPushers.first.deviceDisplayName == client.deviceName &&
|
||||
currentPushers.first.lang == 'en' &&
|
||||
currentPushers.first.data.url == GATEWAY_URL &&
|
||||
currentPushers.first.data.format == PUSHER_FORMAT) {
|
||||
debugPrint("[Push] Pusher already set");
|
||||
} else {
|
||||
if (currentPushers.isNotEmpty) {
|
||||
for (final currentPusher in currentPushers) {
|
||||
await client.setPushers(
|
||||
token,
|
||||
'null',
|
||||
currentPusher.appId,
|
||||
currentPusher.appDisplayName,
|
||||
currentPusher.deviceDisplayName,
|
||||
currentPusher.lang,
|
||||
currentPusher.data.url,
|
||||
append: true,
|
||||
);
|
||||
debugPrint("[Push] Remove legacy pusher for this device");
|
||||
}
|
||||
}
|
||||
await client.setPushers(
|
||||
token,
|
||||
"http",
|
||||
"chat.fluffy.fluffychat",
|
||||
APP_ID,
|
||||
clientName,
|
||||
client.deviceName,
|
||||
"en",
|
||||
"https://janian.de:7023/",
|
||||
GATEWAY_URL,
|
||||
append: false,
|
||||
format: "event_id_only",
|
||||
format: PUSHER_FORMAT,
|
||||
);
|
||||
}
|
||||
|
||||
Function goToRoom = (dynamic message) async {
|
||||
try {
|
||||
|
|
|
@ -124,8 +124,8 @@ packages:
|
|||
dependency: "direct main"
|
||||
description:
|
||||
path: "."
|
||||
ref: "4b2d4913b3e720f62698c46dfa6b17d5f0e1aa49"
|
||||
resolved-ref: "4b2d4913b3e720f62698c46dfa6b17d5f0e1aa49"
|
||||
ref: "2525b3d9f156fa303ca9283a96fd8cf8db154dd9"
|
||||
resolved-ref: "2525b3d9f156fa303ca9283a96fd8cf8db154dd9"
|
||||
url: "https://gitlab.com/famedly/famedlysdk.git"
|
||||
source: git
|
||||
version: "0.0.1"
|
||||
|
|
|
@ -27,7 +27,7 @@ dependencies:
|
|||
famedlysdk:
|
||||
git:
|
||||
url: https://gitlab.com/famedly/famedlysdk.git
|
||||
ref: 4b2d4913b3e720f62698c46dfa6b17d5f0e1aa49
|
||||
ref: 2525b3d9f156fa303ca9283a96fd8cf8db154dd9
|
||||
|
||||
localstorage: ^3.0.1+4
|
||||
bubble: ^1.1.9+1
|
||||
|
|
Loading…
Reference in a new issue