[Flutter] Force a username before subscribing
This commit is contained in:
@@ -5,6 +5,7 @@ import 'package:simplecloudnotifier/api/api_client.dart';
|
||||
import 'package:simplecloudnotifier/state/app_settings.dart';
|
||||
import 'package:simplecloudnotifier/state/app_auth.dart';
|
||||
import 'package:simplecloudnotifier/state/application_log.dart';
|
||||
import 'package:simplecloudnotifier/state/globals.dart';
|
||||
import 'package:simplecloudnotifier/utils/notifier.dart';
|
||||
import 'package:simplecloudnotifier/utils/toaster.dart';
|
||||
import 'package:simplecloudnotifier/utils/ui.dart';
|
||||
@@ -65,22 +66,31 @@ class _DebugActionsPageState extends State<DebugActionsPage> {
|
||||
onPressed: _sendTokenToServer,
|
||||
text: 'Send FCM Token to Server',
|
||||
),
|
||||
SizedBox(height: 4),
|
||||
UI.button(
|
||||
big: false,
|
||||
onPressed: _updateClient,
|
||||
text: 'Update Client on Server',
|
||||
),
|
||||
SizedBox(height: 20),
|
||||
UI.button(
|
||||
big: false,
|
||||
onPressed: () => Notifier.showLocalNotification('', 'TEST_CHANNEL', "Test Channel", "Channel for testing", "Hello World", "Local Notification test", null, null),
|
||||
text: 'Show local notification (generic)',
|
||||
),
|
||||
SizedBox(height: 4),
|
||||
UI.button(
|
||||
big: false,
|
||||
onPressed: () => Notifier.showLocalNotification('', 'TEST_CHANNEL', "Test Channel", "Channel for testing", "Hello World", "Local Notification test", null, 0),
|
||||
text: 'Show local notification (Prio = 0)',
|
||||
),
|
||||
SizedBox(height: 4),
|
||||
UI.button(
|
||||
big: false,
|
||||
onPressed: () => Notifier.showLocalNotification('', 'TEST_CHANNEL', "Test Channel", "Channel for testing", "Hello World", "Local Notification test", null, 1),
|
||||
text: 'Show local notification (Prio = 1)',
|
||||
),
|
||||
SizedBox(height: 4),
|
||||
UI.button(
|
||||
big: false,
|
||||
onPressed: () => Notifier.showLocalNotification('', 'TEST_CHANNEL', "Test Channel", "Channel for testing", "Hello World", "Local Notification test", null, 2),
|
||||
@@ -128,6 +138,26 @@ class _DebugActionsPageState extends State<DebugActionsPage> {
|
||||
}
|
||||
}
|
||||
|
||||
void _updateClient() async {
|
||||
try {
|
||||
final auth = AppAuth();
|
||||
|
||||
final clientID = auth.getClientID();
|
||||
if (clientID == null) {
|
||||
Toaster.error("Error", "No Client set");
|
||||
return;
|
||||
}
|
||||
|
||||
final newClient = await APIClient.updateClient(auth, clientID, agentModel: Globals().deviceModel, name: Globals().nameForClient(), agentVersion: Globals().version);
|
||||
auth.setClientAndClientID(newClient);
|
||||
|
||||
Toaster.success("Success", "Client updated");
|
||||
} catch (exc, trace) {
|
||||
Toaster.error("Error", "An error occurred while updating the client: ${exc.toString()}");
|
||||
ApplicationLog.error("An error occurred while updating the client: ${exc.toString()}", trace: trace);
|
||||
}
|
||||
}
|
||||
|
||||
void _copyToken() async {
|
||||
try {
|
||||
final fcmToken = await FirebaseMessaging.instance.getToken();
|
||||
|
||||
@@ -135,7 +135,7 @@ class _DebugRequestViewPageState extends State<DebugRequestViewPage> {
|
||||
void _copyCurl() {
|
||||
final method = '-X ${widget.request.method}';
|
||||
final header = widget.request.requestHeaders.entries.map((v) => '-H "${v.key}: ${v.value}"').join(' ');
|
||||
final body = widget.request.requestBody.isNotEmpty ? '-d "${widget.request.requestBody}"' : '';
|
||||
final body = widget.request.requestBody.isNotEmpty ? '-d \'${widget.request.requestBody}\'' : '';
|
||||
|
||||
final curlParts = ['curl', method, header, '"${widget.request.url}"', body];
|
||||
|
||||
|
||||
Reference in New Issue
Block a user