WT1.1.5 In-app-purchase
This commit is contained in:
@@ -15,7 +15,7 @@ class CustomerExerciseDeviceApi with Logging {
|
||||
final body = await _client.get("customer_exercise_device/customer/" + customerId.toString(), "");
|
||||
final Iterable json = jsonDecode(body);
|
||||
devices = json.map((device) => CustomerExerciseDevice.fromJson(device)).toList();
|
||||
} on NotFoundException catch (e) {
|
||||
} on NotFoundException catch (_) {
|
||||
log("No devices found");
|
||||
}
|
||||
return devices;
|
||||
|
||||
@@ -165,41 +165,37 @@ class FirebaseApi with logging.Logging {
|
||||
Future<Map<String, dynamic>> signInWithGoogle() async {
|
||||
Map<String, dynamic> userData = Map();
|
||||
|
||||
try {
|
||||
// Trigger the authentication flow
|
||||
GoogleSignIn _googleSignIn = GoogleSignIn(
|
||||
scopes: [
|
||||
'email',
|
||||
'https://www.googleapis.com/auth/contacts.readonly',
|
||||
],
|
||||
);
|
||||
final GoogleSignInAccount googleUser = await _googleSignIn.signIn();
|
||||
// Trigger the authentication flow
|
||||
GoogleSignIn _googleSignIn = GoogleSignIn(
|
||||
scopes: [
|
||||
'email',
|
||||
'https://www.googleapis.com/auth/contacts.readonly',
|
||||
],
|
||||
);
|
||||
final GoogleSignInAccount googleUser = await _googleSignIn.signIn();
|
||||
|
||||
if (googleUser == null) {
|
||||
throw Exception("Google Sign In failed");
|
||||
}
|
||||
|
||||
// Obtain the auth details from the request
|
||||
final GoogleSignInAuthentication googleAuth = await googleUser.authentication;
|
||||
|
||||
// Create a new credential
|
||||
final GoogleAuthCredential credential = GoogleAuthProvider.credential(
|
||||
accessToken: googleAuth.accessToken,
|
||||
idToken: googleAuth.idToken,
|
||||
);
|
||||
|
||||
await FirebaseAuth.instance.signInWithCredential(credential);
|
||||
|
||||
if (googleUser != null) {
|
||||
log("GoogleUser: " + googleUser.toString());
|
||||
userData['email'] = googleUser.email;
|
||||
userData['id'] = googleUser.id;
|
||||
userData['name'] = googleUser.displayName;
|
||||
}
|
||||
} on Exception catch (ex) {
|
||||
log("Google exception: " + ex.toString());
|
||||
if (googleUser == null) {
|
||||
throw Exception("Google Sign In failed");
|
||||
}
|
||||
|
||||
// Obtain the auth details from the request
|
||||
final GoogleSignInAuthentication googleAuth = await googleUser.authentication;
|
||||
|
||||
// Create a new credential
|
||||
final GoogleAuthCredential credential = GoogleAuthProvider.credential(
|
||||
accessToken: googleAuth.accessToken,
|
||||
idToken: googleAuth.idToken,
|
||||
);
|
||||
|
||||
await FirebaseAuth.instance.signInWithCredential(credential);
|
||||
|
||||
if (googleUser != null) {
|
||||
log("GoogleUser: " + googleUser.toString());
|
||||
userData['email'] = googleUser.email;
|
||||
userData['id'] = googleUser.id;
|
||||
userData['name'] = googleUser.displayName;
|
||||
}
|
||||
|
||||
return userData;
|
||||
}
|
||||
|
||||
@@ -266,15 +262,16 @@ class FirebaseApi with logging.Logging {
|
||||
Cache().accessTokenFacebook = accessToken;
|
||||
// get the user data
|
||||
userData = await FacebookAuth.instance.getUserData();
|
||||
log("FB user data: " + userData.toString());
|
||||
|
||||
// Create a credential from the access token
|
||||
final FacebookAuthCredential facebookAuthCredential = FacebookAuthProvider.credential(accessToken.token);
|
||||
|
||||
// Once signed in, return the UserCredential
|
||||
final userCredential = await FirebaseAuth.instance.signInWithCredential(facebookAuthCredential);
|
||||
log("Email by FB: " + userData['email'] + " FB credential: " + userCredential.toString());
|
||||
|
||||
Cache().firebaseUid = userCredential.user.uid;
|
||||
log(userData.toString());
|
||||
} else {
|
||||
throw Exception("Facebook login was not successful");
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ class PurchaseApi with Logging {
|
||||
final Iterable json = jsonDecode(body);
|
||||
final List<Purchase> purchases = json.map((purchase) => Purchase.fromJson(purchase)).toList();
|
||||
Cache().setPurchases(purchases);
|
||||
} on NotFoundException catch (e) {
|
||||
} on NotFoundException catch (_) {
|
||||
log("No purchases found");
|
||||
}
|
||||
return purchases;
|
||||
|
||||
Reference in New Issue
Block a user