wt1.0 bug fixing, push notification
This commit is contained in:
@@ -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 {
|
||||
|
||||
@@ -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() );
|
||||
|
||||
Reference in New Issue
Block a user