Skip to content

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

@Levi-Lesches

Description

@Levi-Lesches

💬 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions