diff --git a/.gitignore b/.gitignore index c4f26e041..5cb586d1b 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,6 @@ .DS_Store .dart_tool/ - +.history .packages .pub/ pubspec.lock diff --git a/lib/src/objects/parse_installation.dart b/lib/src/objects/parse_installation.dart index dfec33f27..29b05a7f7 100644 --- a/lib/src/objects/parse_installation.dart +++ b/lib/src/objects/parse_installation.dart @@ -9,7 +9,7 @@ class ParseInstallation extends ParseObject { _client = client ?? ParseHTTPClient( sendSessionId: - autoSendSessionId ?? ParseCoreData().autoSendSessionId, + autoSendSessionId ?? ParseCoreData().autoSendSessionId, securityContext: ParseCoreData().securityContext); } @@ -130,11 +130,11 @@ class ParseInstallation extends ParseObject { final CoreStore coreStore = await ParseCoreData().getStore(); final String installationJson = - await coreStore.getString(keyParseStoreInstallation); + await coreStore.getString(keyParseStoreInstallation); if (installationJson != null) { final Map installationMap = - json.decode(installationJson); + json.decode(installationJson); if (installationMap != null) { return ParseInstallation()..fromJson(installationMap); @@ -161,11 +161,16 @@ class ParseInstallation extends ParseObject { try { final String uri = '${_client.data.serverUrl}$keyEndPointInstallations'; final String body = json.encode(toJson(forApiRQ: true)); + final Map headers = { + keyHeaderContentType: keyHeaderContentTypeJson + }; if (_debug) { logRequest(ParseCoreData().appName, parseClassName, ParseApiRQ.create.toString(), uri, body); } - final Response result = await _client.post(uri, body: body); + + final Response result = + await _client.post(uri, body: body, headers: headers); //Set the objectId on the object after it is created. //This allows you to perform operations on the object after creation diff --git a/lib/src/objects/parse_object.dart b/lib/src/objects/parse_object.dart index 2c790c2c8..797288a7e 100644 --- a/lib/src/objects/parse_object.dart +++ b/lib/src/objects/parse_object.dart @@ -82,7 +82,9 @@ class ParseObject extends ParseBase implements ParseCloneable { final Uri url = getSanitisedUri(_client, '$_path/$objectId'); final String body = json.encode(toJson(forApiRQ: true)); _saveChanges(); - final Response result = await _client.put(url, body: body); + final Map headers = {keyHeaderContentType:keyHeaderContentTypeJson}; + final Response result = + await _client.put(url, body: body, headers: headers); return handleResponse( this, result, ParseApiRQ.save, _debug, parseClassName); } on Exception catch (e) { @@ -104,8 +106,7 @@ class ParseObject extends ParseBase implements ParseCloneable { if (response != null) { if (response.success) { _savingChanges.clear(); - } - else { + } else { _revertSavingChanges(); } return response; @@ -175,8 +176,7 @@ class ParseObject extends ParseBase implements ParseCloneable { if (response.results[i] is ParseError) { // Batch request succeed, but part of batch failed. chunk[i]._revertSavingChanges(); - } - else { + } else { chunk[i]._savingChanges.clear(); } } diff --git a/lib/src/objects/parse_session.dart b/lib/src/objects/parse_session.dart index 642b89129..d4a1947fc 100644 --- a/lib/src/objects/parse_session.dart +++ b/lib/src/objects/parse_session.dart @@ -27,14 +27,15 @@ class ParseSession extends ParseObject implements ParseCloneable { String get installationId => super.get(keyVarInstallationId); + set installationId(String installationId) => + set(keyVarInstallationId, installationId); + + Future getCurrentSessionFromServer() async { try { - final Uri tempUri = Uri.parse(_client.data.serverUrl); - final Uri url = Uri( - scheme: tempUri.scheme, - host: tempUri.host, - path: '${tempUri.path}$keyEndPointSessions/me'); + const String path = '$keyEndPointSessions/me'; + final Uri url = getSanitisedUri(_client, path); final Response response = await _client.get(url); diff --git a/pubspec.yaml b/pubspec.yaml index 1223c4559..5ba07f795 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -10,7 +10,7 @@ environment: dependencies: flutter: sdk: flutter - + # Networking web_socket_channel: ^1.0.9 http: ^0.12.0