Skip to content

Commit 31d874b

Browse files
hellokidderphillwiggins
authored andcommitted
ParseObject.update/ParseInstallation.create/ParseSession.installationId (#264)
* Fix About Retrieving Sessions * parseObject.update/ParseInstallation.put/ParseSession.installation
1 parent 069048d commit 31d874b

File tree

4 files changed

+17
-6
lines changed

4 files changed

+17
-6
lines changed

lib/src/objects/parse_installation.dart

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ class ParseInstallation extends ParseObject {
99
_client = client ??
1010
ParseHTTPClient(
1111
sendSessionId:
12-
autoSendSessionId ?? ParseCoreData().autoSendSessionId,
12+
autoSendSessionId ?? ParseCoreData().autoSendSessionId,
1313
securityContext: ParseCoreData().securityContext);
1414
}
1515

@@ -130,11 +130,11 @@ class ParseInstallation extends ParseObject {
130130
final CoreStore coreStore = ParseCoreData().getStore();
131131

132132
final String installationJson =
133-
await coreStore.getString(keyParseStoreInstallation);
133+
await coreStore.getString(keyParseStoreInstallation);
134134

135135
if (installationJson != null) {
136136
final Map<String, dynamic> installationMap =
137-
json.decode(installationJson);
137+
json.decode(installationJson);
138138

139139
if (installationMap != null) {
140140
return ParseInstallation()..fromJson(installationMap);
@@ -161,11 +161,16 @@ class ParseInstallation extends ParseObject {
161161
try {
162162
final String uri = '${_client.data.serverUrl}$keyEndPointInstallations';
163163
final String body = json.encode(toJson(forApiRQ: true));
164+
final Map<String, String> headers = {
165+
keyHeaderContentType: keyHeaderContentTypeJson
166+
};
164167
if (_debug) {
165168
logRequest(ParseCoreData().appName, parseClassName,
166169
ParseApiRQ.create.toString(), uri, body);
167170
}
168-
final Response result = await _client.post(uri, body: body);
171+
172+
final Response result =
173+
await _client.post(uri, body: body, headers: headers);
169174

170175
//Set the objectId on the object after it is created.
171176
//This allows you to perform operations on the object after creation

lib/src/objects/parse_object.dart

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,9 @@ class ParseObject extends ParseBase implements ParseCloneable {
8484
final Uri url = getSanitisedUri(_client, '$_path/$objectId');
8585
final String body = json.encode(toJson(forApiRQ: true));
8686
_saveChanges();
87-
final Response result = await _client.put(url, body: body);
87+
final Map<String, String> headers = {keyHeaderContentType:keyHeaderContentTypeJson};
88+
final Response result =
89+
await _client.put(url, body: body, headers: headers);
8890
return handleResponse<ParseObject>(
8991
this, result, ParseApiRQ.save, _debug, parseClassName);
9092
} on Exception catch (e) {

lib/src/objects/parse_session.dart

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@ class ParseSession extends ParseObject implements ParseCloneable {
2727

2828
String get installationId => super.get<String>(keyVarInstallationId);
2929

30+
set installationId(String installationId) =>
31+
set<String>(keyVarInstallationId, installationId);
32+
33+
3034
Future<ParseResponse> getCurrentSessionFromServer() async {
3135
try {
3236

pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ dependencies:
1111
http: ^0.12.0+2
1212
flutter:
1313
sdk: flutter
14-
14+
1515
# Networking
1616
web_socket_channel: ^1.0.13
1717

0 commit comments

Comments
 (0)