Skip to content

Make web compatible calls for locale and skip PackageInfo #395

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jun 11, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,15 @@ It's possible to add other parameters to work with your instance of Parse Server
coreStore: await CoreStoreSharedPrefsImp.getInstance()); // Local data storage method. Will use SharedPreferences instead of Sembast as an internal DB
```


#### Early Web support
Currently this requires adding `X-Parse-Installation-Id` as an allowed header to parse-server.
When running directly via docker, set the env var `PARSE_SERVER_ALLOW_HEADERS=X-Parse-Installation-Id`.
When running via express, set [ParseServerOptions](https://parseplatform.org/parse-server/api/master/ParseServerOptions.html) `allowHeader: ['X-Parse-Installation-Id']`.

Be aware that for web ParseInstallation does include app name, version or package identifier.


## Objects
You can create custom objects by calling:
```dart
Expand Down
1 change: 1 addition & 0 deletions lib/parse_server_sdk.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import 'dart:convert';
import 'dart:io';
import 'dart:math';
import 'dart:typed_data';
import 'dart:ui' as ui;

import 'package:devicelocale/devicelocale.dart';
import 'package:flutter/foundation.dart' show kIsWeb;
Expand Down
12 changes: 7 additions & 5 deletions lib/src/objects/parse_installation.dart
Original file line number Diff line number Diff line change
Expand Up @@ -83,18 +83,20 @@ class ParseInstallation extends ParseObject {
}

//Locale
final String locale = await Devicelocale.currentLocale;
final String locale = kIsWeb ? ui.window.locale.toString() : await Devicelocale.currentLocale;
if (locale != null && locale.isNotEmpty) {
set<String>(keyLocaleIdentifier, locale);
}

//Timezone

//App info
final PackageInfo packageInfo = await PackageInfo.fromPlatform();
set<String>(keyAppName, packageInfo.appName);
set<String>(keyAppVersion, packageInfo.version);
set<String>(keyAppIdentifier, packageInfo.packageName);
if (!kIsWeb) {
final PackageInfo packageInfo = await PackageInfo.fromPlatform();
set<String>(keyAppName, packageInfo.appName);
set<String>(keyAppVersion, packageInfo.version);
set<String>(keyAppIdentifier, packageInfo.packageName);
}
set<String>(keyParseVersion, keySdkVersion);
}

Expand Down