ℹ️ Info
Version: 3.9.1
💬 Description
I can't get my Flutter app's custom URI to work after I package my app with MSIX, and I'm trying to figure out if it's a bug with protocol_handler that creates and registers the URI, or if it's something to do with MSIX.
Here's what I've done:
- I run my Flutter app which registers a custom URI.
- I run the app in the debugger.
- Hitting my custom URI in a web browser, such as
myapp://test opens my app.
- After packaging with
flutter pub run msix:create and signing the MSIX, then running the app on another computer, the app runs, but hitting the custom URI does not open the app.
I have confirmed the issue across two apps:
- The first app uses a redirect from the Dropbox API – works in debug mode, fails after MSIX packaging.
- The second app uses an auth redirect from Supabase – works in debug mode, fails after MSIX packaging.
📜 Pubspec.yaml
msix_config:
display_name: Pilot Pro
publisher_display_name: Labrum Co
identity_name: LabrumCo.PilotPro
publisher: CN=<*****>
msix_version: 5.7.7.0
logo_path: C:\Users\clift\OneDrive\Desktop\PilotPro\assets\images\windows.png
store: true
🖥️ Sample Project
Below is a minimal sample project. You will need to add these two packages:
flutter pub add msix
flutter pub add protocol_handler
After building the app on Windows, visit uritest://test in a web browser, and it should show this:

After clicking Open uri_test it will bring the app to the forefront and you should see this in the debug console:
Here are the contents of main.dart:
import 'package:flutter/material.dart';
import 'package:protocol_handler/protocol_handler.dart';
void main() async {
// Must add this line.
WidgetsFlutterBinding.ensureInitialized();
// Register a custom protocol
await protocolHandler.register('uritest');
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return const MaterialApp(
title: 'URI Test App',
home: MyHomePage(),
);
}
}
class MyHomePage extends StatefulWidget {
const MyHomePage({super.key});
@override
State<MyHomePage> createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> with ProtocolListener {
@override
void initState() {
protocolHandler.addListener(this);
super.initState();
}
@override
void dispose() {
protocolHandler.removeListener(this);
super.dispose();
}
@override
void onProtocolUrlReceived(String url) {
//::::: Confirm URL is received :::::
String log = 'Got it: $url';
print(log);
}
@override
Widget build(BuildContext context) {
return const Scaffold(
body: Center(
child: Text('Custom URI Test'),
),
);
}
}
You have to add the following to /windows/runner/main.cpp:
//Add this include at the top...
#include <protocol_handler/protocol_handler_plugin.h>
//Just inside the existing method here...
int APIENTRY wWinMain(_In_ HINSTANCE instance, _In_opt_ HINSTANCE prev,
_In_ wchar_t *command_line, _In_ int show_command) {
//Add this...
HWND hwnd = ::FindWindow(L"FLUTTER_RUNNER_WIN32_WINDOW", L"uri_test");
if (hwnd != NULL) {
DispatchToProtocolHandler(hwnd);
::ShowWindow(hwnd, SW_NORMAL);
::SetForegroundWindow(hwnd);
return EXIT_FAILURE;
}
...
After you package this with MSIX, you must launch it on another user account or computer. This is because (as far as I can tell) the registry edits are already made on your machine with the debug version of the app running.
Could you please check if this is something to do with MSIX or not? This is blocking me on launching two apps on Windows. 😅 Thank you!
ℹ️ Info
Version:
3.9.1💬 Description
I can't get my Flutter app's custom URI to work after I package my app with MSIX, and I'm trying to figure out if it's a bug with protocol_handler that creates and registers the URI, or if it's something to do with MSIX.
Here's what I've done:
myapp://testopens my app.flutter pub run msix:createand signing the MSIX, then running the app on another computer, the app runs, but hitting the custom URI does not open the app.I have confirmed the issue across two apps:
📜 Pubspec.yaml
🖥️ Sample Project
Below is a minimal sample project. You will need to add these two packages:
After building the app on Windows, visit
uritest://testin a web browser, and it should show this:After clicking Open uri_test it will bring the app to the forefront and you should see this in the debug console:
Here are the contents of
main.dart:You have to add the following to
/windows/runner/main.cpp:After you package this with MSIX, you must launch it on another user account or computer. This is because (as far as I can tell) the registry edits are already made on your machine with the debug version of the app running.
Could you please check if this is something to do with MSIX or not? This is blocking me on launching two apps on Windows. 😅 Thank you!