diff --git a/README.md b/README.md index 828262637..c91dc05be 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/lib/parse_server_sdk.dart b/lib/parse_server_sdk.dart index fbbc463e4..74029eff3 100644 --- a/lib/parse_server_sdk.dart +++ b/lib/parse_server_sdk.dart @@ -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; diff --git a/lib/src/objects/parse_installation.dart b/lib/src/objects/parse_installation.dart index b9f35e290..d5d6be828 100644 --- a/lib/src/objects/parse_installation.dart +++ b/lib/src/objects/parse_installation.dart @@ -83,7 +83,7 @@ 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(keyLocaleIdentifier, locale); } @@ -91,10 +91,12 @@ class ParseInstallation extends ParseObject { //Timezone //App info - final PackageInfo packageInfo = await PackageInfo.fromPlatform(); - set(keyAppName, packageInfo.appName); - set(keyAppVersion, packageInfo.version); - set(keyAppIdentifier, packageInfo.packageName); + if (!kIsWeb) { + final PackageInfo packageInfo = await PackageInfo.fromPlatform(); + set(keyAppName, packageInfo.appName); + set(keyAppVersion, packageInfo.version); + set(keyAppIdentifier, packageInfo.packageName); + } set(keyParseVersion, keySdkVersion); }