wt1.0 bug fixing, push notification

This commit is contained in:
Bossanyi Tibor
2020-07-12 14:17:59 +02:00
parent f0f0136d65
commit 4e38d3da22
67 changed files with 1472 additions and 213 deletions
+7 -4
View File
@@ -1,4 +1,5 @@
import 'dart:convert';
import 'package:aitrainer_app/util/common.dart';
import 'package:flutter/cupertino.dart';
import 'package:http/http.dart' as http;
import 'package:aitrainer_app/model/auth.dart';
@@ -39,16 +40,18 @@ class APIClient extends ChangeNotifier {
);
authToken = responseJson['token'];
}
final response = await http.post(url,
headers: {
'Content-Type': 'application/json',
'Content-Type': 'application/json; charset=UTF-8',
'Authorization' : "Bearer " + authToken
},
body: body
body: body,
);
print(" ------------ response: " + response.body.toString());
String decodedResponse = Common.utf8convert(response.body);
print(" ------------ response: " + decodedResponse);
notifyListeners();
return response.body;
return decodedResponse;
}
static dynamic authenticateUser(String email, String password) async {
+15 -4
View File
@@ -37,8 +37,13 @@ class CustomerApi {
final String responseBody = await _client.post(
"registration",
body);
Customer customer = Customer.fromJson(jsonDecode(responseBody));
Auth().afterRegistration(customer);
Customer customer;
try {
customer = Customer.fromJson(jsonDecode(responseBody));
Auth().afterRegistration(customer);
} on FormatException catch(exception) {
throw new Exception(responseBody);
}
}
@@ -48,10 +53,16 @@ class CustomerApi {
final String responseBody = await _client.post(
"login",
body);
Customer customer = Customer.fromJson(jsonDecode(responseBody));
Auth().afterRegistration(customer);
Customer customer;
try {
customer = Customer.fromJson(jsonDecode(responseBody));
Auth().afterRegistration(customer);
} on FormatException catch(exception) {
throw new Exception(responseBody);
}
}
Future<void> getCustomer(int customerId) async {
String body = "";
print(" ===== get the customer by id: " + customerId.toString() );