Skip to content
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

[FEATURE REQUEST] Add function to determine if the app is running as an MSIX #292

Open
Levi-Lesches opened this issue Dec 31, 2024 · 1 comment · May be fixed by #294
Open

[FEATURE REQUEST] Add function to determine if the app is running as an MSIX #292

Levi-Lesches opened this issue Dec 31, 2024 · 1 comment · May be fixed by #294

Comments

@Levi-Lesches
Copy link

Levi-Lesches commented Dec 31, 2024

💬 Description

Some functionality or URIs are [different] if you're in an MSIX or not. The package flutter_local_notification offers a completely different experience in packaged vs non-packaged apps, for example.

A simple function like isMsix() would help determine at run-time whether MSIX package identity is available. The notifications package uses this function in C++:

#include <windows.h>  // <-- This must be the first Windows header
#include <appmodel.h>
#include <atlbase.h>
#include <VersionHelpers.h>

std::optional<bool> NativePlugin::checkIdentity() {
  if (!IsWindows8OrGreater()) return false;
  uint32_t length = 0;
  auto error = GetCurrentPackageFullName(&length, nullptr);
  if (error == APPMODEL_ERROR_NO_PACKAGE) {
    return false;
  } else if (error != ERROR_INSUFFICIENT_BUFFER) {
    return std::nullopt;
  }
  std::vector<wchar_t> fullName(length);
  error = GetCurrentPackageFullName(&length, fullName.data());
  if (error != ERROR_SUCCESS) return std::nullopt;
  return true;
}

Which can be translated to bool? isMsix() in Dart after some FFI. Happy to open a PR with this. Note that these functions aren't yet supported by package:win32, see halildurmus/win32#819.

❓ Platform

Windows

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant