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_ID = 'fluffychat_push';
|
||||||
static const String CHANNEL_NAME = 'FluffyChat push channel';
|
static const String CHANNEL_NAME = 'FluffyChat push channel';
|
||||||
static const String CHANNEL_DESCRIPTION = 'Push notifications for FluffyChat';
|
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 {
|
static Future<void> setupFirebase(Client client, String clientName) async {
|
||||||
if (Platform.isIOS) iOS_Permission();
|
if (Platform.isIOS) iOS_Permission();
|
||||||
|
@ -39,17 +42,45 @@ abstract class FirebaseController {
|
||||||
);
|
);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
await client.setPushers(
|
final pushers = await client.getPushers();
|
||||||
token,
|
final currentPushers = pushers.where((pusher) => pusher.pushkey == token);
|
||||||
"http",
|
if (currentPushers.length == 1 &&
|
||||||
"chat.fluffy.fluffychat",
|
currentPushers.first.kind == 'http' &&
|
||||||
clientName,
|
currentPushers.first.appId == APP_ID &&
|
||||||
client.deviceName,
|
currentPushers.first.appDisplayName == clientName &&
|
||||||
"en",
|
currentPushers.first.deviceDisplayName == client.deviceName &&
|
||||||
"https://janian.de:7023/",
|
currentPushers.first.lang == 'en' &&
|
||||||
append: false,
|
currentPushers.first.data.url == GATEWAY_URL &&
|
||||||
format: "event_id_only",
|
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",
|
||||||
|
APP_ID,
|
||||||
|
clientName,
|
||||||
|
client.deviceName,
|
||||||
|
"en",
|
||||||
|
GATEWAY_URL,
|
||||||
|
append: false,
|
||||||
|
format: PUSHER_FORMAT,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
Function goToRoom = (dynamic message) async {
|
Function goToRoom = (dynamic message) async {
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -124,8 +124,8 @@ packages:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
path: "."
|
path: "."
|
||||||
ref: "4b2d4913b3e720f62698c46dfa6b17d5f0e1aa49"
|
ref: "2525b3d9f156fa303ca9283a96fd8cf8db154dd9"
|
||||||
resolved-ref: "4b2d4913b3e720f62698c46dfa6b17d5f0e1aa49"
|
resolved-ref: "2525b3d9f156fa303ca9283a96fd8cf8db154dd9"
|
||||||
url: "https://gitlab.com/famedly/famedlysdk.git"
|
url: "https://gitlab.com/famedly/famedlysdk.git"
|
||||||
source: git
|
source: git
|
||||||
version: "0.0.1"
|
version: "0.0.1"
|
||||||
|
|
|
@ -27,7 +27,7 @@ dependencies:
|
||||||
famedlysdk:
|
famedlysdk:
|
||||||
git:
|
git:
|
||||||
url: https://gitlab.com/famedly/famedlysdk.git
|
url: https://gitlab.com/famedly/famedlysdk.git
|
||||||
ref: 4b2d4913b3e720f62698c46dfa6b17d5f0e1aa49
|
ref: 2525b3d9f156fa303ca9283a96fd8cf8db154dd9
|
||||||
|
|
||||||
localstorage: ^3.0.1+4
|
localstorage: ^3.0.1+4
|
||||||
bubble: ^1.1.9+1
|
bubble: ^1.1.9+1
|
||||||
|
|
Loading…
Reference in a new issue