mrtnetwork / flutter_windows_notification

A library for sending notifications on Windows using Flutter
MIT License
17 stars 4 forks source link

Compilation error in flutter_windows_notification plugin on Windows #24

Open Ergul opened 5 months ago

Ergul commented 5 months ago

I encountered a compilation error while building my Flutter application for Windows using the version 1.2.0. The error occurs when using the flutter_windows_notification plugin. Below are the details of the error messages:

C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\cppwinrt\winrt/base.h(6508,17): error C2220: the following warning is treated as an error [C:\Users\eric\git\prostoreapp\build\windows\x64\plugins\windows_notification\windows_notification_plugin.vcxproj]
C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\cppwinrt\winrt/base.h(6508,17): warning C5205: deleting an abstract class 'winrt::impl::implements_delegate<winrt::Windows::UI::Core::DispatchedHandler,H>' which has a non-virtual destructor results in undefined behavior [C:\Users\eric\git\prostoreapp\build\windows\x64\plugins\windows_notification\windows_notification_plugin.vcxproj]
C:\Users\eric\git\prostoreapp\windows\flutter\ephemeral\.plugin_symlinks\windows_notification\windows\windows_notification_plugin.cpp(279,42): error C2039: 'UserInput' is not a member of 'winrt::Windows::UI::Notifications::ToastActivatedEventArgs' [C:\Users\eric\git\prostoreapp\build\windows\x64\plugins\windows_notification\windows_notification_plugin.vcxproj]
Error: Build process failed.

Steps to Reproduce

Add the flutter_windows_notification plugin to the pubspec.yaml file.

Build the Flutter application for Windows using flutter build windows.

My configuration

$ flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel stable, 3.22.1, on Microsoft Windows [version 10.0.17763.4974], locale fr-CH)
[√] Windows Version (Installed version of Windows is version 10 or higher)
[√] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
[√] Chrome - develop for the web
[√] Visual Studio - develop Windows apps (Visual Studio Build Tools 2019 16.11.36)
[√] Android Studio (version 2023.1)
[√] Connected device (3 available)
[√] Network resources

It appears that there are issues related to the winrt base header and the ToastActivatedEventArgs class, which may have changes or deprecated members.

Please provide guidance on how to resolve these compilation errors.

Thank you.

mrtnetwork commented 5 months ago

I encountered a compilation error while building my Flutter application for Windows using the version 1.2.0. The error occurs when using the flutter_windows_notification plugin. Below are the details of the error messages:

C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\cppwinrt\winrt/base.h(6508,17): error C2220: the following warning is treated as an error [C:\Users\eric\git\prostoreapp\build\windows\x64\plugins\windows_notification\windows_notification_plugin.vcxproj]
C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\cppwinrt\winrt/base.h(6508,17): warning C5205: deleting an abstract class 'winrt::impl::implements_delegate<winrt::Windows::UI::Core::DispatchedHandler,H>' which has a non-virtual destructor results in undefined behavior [C:\Users\eric\git\prostoreapp\build\windows\x64\plugins\windows_notification\windows_notification_plugin.vcxproj]
C:\Users\eric\git\prostoreapp\windows\flutter\ephemeral\.plugin_symlinks\windows_notification\windows\windows_notification_plugin.cpp(279,42): error C2039: 'UserInput' is not a member of 'winrt::Windows::UI::Notifications::ToastActivatedEventArgs' [C:\Users\eric\git\prostoreapp\build\windows\x64\plugins\windows_notification\windows_notification_plugin.vcxproj]
Error: Build process failed.

Steps to Reproduce

Add the flutter_windows_notification plugin to the pubspec.yaml file.

Build the Flutter application for Windows using flutter build windows.

My configuration

$ flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel stable, 3.22.1, on Microsoft Windows [version 10.0.17763.4974], locale fr-CH)
[√] Windows Version (Installed version of Windows is version 10 or higher)
[√] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
[√] Chrome - develop for the web
[√] Visual Studio - develop Windows apps (Visual Studio Build Tools 2019 16.11.36)
[√] Android Studio (version 2023.1)
[√] Connected device (3 available)
[√] Network resources

It appears that there are issues related to the winrt base header and the ToastActivatedEventArgs class, which may have changes or deprecated members.

Please provide guidance on how to resolve these compilation errors.

Thank you.

Hi, i cant checked now, i don't have any windows machine

Levi-Lesches commented 5 months ago

Hi, I'm having the same issue. The plugin does not compile on Windows on versions 1.2, 1.1, or 1.0.

@mrtnetwork Any ideas? I'm looking to use this package but not compiling is a pretty big deal. If you have any leads on what's happening I can try to debug on my end and submit a PR but I am very unfamiliar with these APIs and would need guidance.

mrtnetwork commented 5 months ago

Hi, I'm having the same issue. The plugin does not compile on Windows on versions 1.2, 1.1, or 1.0.

@mrtnetwork Any ideas? I'm looking to use this package but not compiling is a pretty big deal. If you have any leads on what's happening I can try to debug on my end and submit a PR but I am very unfamiliar with these APIs and would need guidance.

Hi, I can't check without a windows machine. Do you see this? Maybe it's related

Levi-Lesches commented 5 months ago

Hm, I'm taking a look instead at bringing full Windows support to package:flutter_local_notifications, as that's looking pretty promising right now.

Malay1121 commented 4 months ago

Go to the file: C:\Users\{user}\AppData\Local\Pub\Cache\hosted\pub.dev\windows_notification-1.2.0\windows\include\windows_notification and edit windows_notification_plugin.h. For me name of the file was windows_notification_plugin_c_api.h.

Add #pragma comment(lib, "windowsapp") at the top of the file. And you are done!

image

Do run flutter pub get after making changes to the file.

Levi-Lesches commented 4 months ago

Not to detract from the work done in this plugin, but my work on flutter_local_notifications is complete and the PR should be merged shortly. In the meantime you can set a dependency override to my branch:

# pubspec_overrides.yaml

dependency_overrides:
  flutter_local_notifications: 
    git:
      url: https://github.com/Levi-Lesches/flutter_local_notifications
      path: flutter_local_notifications
      ref: windows-ffi
  flutter_local_notifications_platform_interface: 
    git:
      url: https://github.com/Levi-Lesches/flutter_local_notifications
      path: flutter_local_notifications_platform_interface
      ref: windows-ffi
  flutter_local_notifications_windows: 
    git:
      url: https://github.com/Levi-Lesches/flutter_local_notifications
      path: flutter_local_notifications_windows
      ref: windows-ffi

Only posting this because cross platforms apps with notifications will need support for other platforms besides Windows, so having one solution is preferable.

Malay1121 commented 4 months ago

Not to detract from the work done in this plugin, but my work on flutter_local_notifications is complete and the PR should be merged shortly. In the meantime you can set a dependency override to my branch:

# pubspec_overrides.yaml

dependency_overrides:
  flutter_local_notifications: 
    git:
      url: https://github.com/Levi-Lesches/flutter_local_notifications
      path: flutter_local_notifications
      ref: windows-ffi
  flutter_local_notifications_platform_interface: 
    git:
      url: https://github.com/Levi-Lesches/flutter_local_notifications
      path: flutter_local_notifications_platform_interface
      ref: windows-ffi
  flutter_local_notifications_windows: 
    git:
      url: https://github.com/Levi-Lesches/flutter_local_notifications
      path: flutter_local_notifications_windows
      ref: windows-ffi

Only posting this because cross platforms apps with notifications will need support for other platforms besides Windows, so having one solution is preferable.

Is there any documentation on how to use flutter_local_notifications for windows?

Levi-Lesches commented 4 months ago

The readme still has to be documented, but that branch has WindowsDetails with a whole bunch of options -- progress bars, images, buttons -- and those have thorough documentation. Those docs aren't published to pub yet, but your IDE's autocomplete should help, and you can look directly at the code for WindowsDetails to see everything it accepts and the docs on there.

Main notes in general:

If you encounter any issues, be sure to open an issue on my fork and I'll fix it asap