YehudaKremer / msix

Create Msix installer for flutter windows-build files.
https://pub.dev/packages/msix
MIT License
280 stars 70 forks source link

Notifications have weird app name and possibly other issues when app is packaged as msix #118

Closed sidevesh closed 2 years ago

sidevesh commented 2 years ago

:information_source: Info

Version: v3.4.0

:speech_balloon: App name on notifications from msix packaged version is incorrect

image The name of the app on notifications seems to be some combination of app identifier, publisher name and some random code, this happens with both win_toast https://github.com/MixinNetwork/flutter-plugins/issues/64 as well as WIP Windows support of flutter_local_notifications

Initially I thought win_toast isn't working because its meant for Win32 apps and not msix packaged apps but looks like that's not the case since the same thing happens with flutter_local_notifications' WIP implementation too.

My msix config is:

msix_config:
  store: true
  display_name: Tomatoro
  publisher_display_name: Entropy Positive
  identity_name: com.sidevesh.tomatoro
  publisher: XX=XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXX
  msix_version: 1.0.26.30
  architecture: x64
  capabilities: internetClient
  languages: en-us
  logo_path: ./assets/icon/icon.transparent.png
  toast_activator:
    clsid: d3eaf1f0-abaa-4ac3-9e39-1dcb81b79db0

:scroll: Pubspec.yaml

name: tomatoro
description: Be productive, grow tomatoes

publish_to: none

# The following defines the version and build number for your application.
# A version number is three numbers separated by dots, like 1.2.43
# followed by an optional build number separated by a +.
# Both the version and the builder number may be overridden in flutter
# build by specifying --build-name and --build-number, respectively.
# In Android, build-name is used as versionName while build-number used as versionCode.
# Read more about Android versioning at https://developer.android.com/studio/publish/versioning
# In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion.
# Read more about iOS versioning at
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
version: 1.0.26+30

environment:
  sdk: '>=2.7.0 <3.0.0' # Replace with '>=2.16.1 <3.0.0' when we are ready to migrate to null safety

dependencies:
  badges: ^1.1.0
  bitsdojo_window: ^0.1.1+1
  duration: ^3.0.10
  duration_picker: ^1.1.0+1
  fading_edge_scrollview: ^2.0.1
  flutter:
    sdk: flutter
  flutter_acrylic: ^1.0.0+1
  flutter_dotenv: ^5.0.2
  flutter_local_notifications:
    git:
      url: https://github.com/sidevesh/flutter_local_notifications.git
      ref: windows-impl
      path: flutter_local_notifications
  http: ^0.13.4
  oktoast: ^3.1.5
  package_info_plus: 1.3.0
  path_provider: ^2.0.9
  platform_device_id: ^1.0.1
  sentry_flutter: ^6.3.0
  shared_preferences: ^2.0.13
  sqflite: ^2.0.2
  sqflite_common_ffi: ^2.1.0+2
  sqlite3_library_linux: ^2.1.0+1
  sqlite3_library_windows: ^2.1.0
  url_launcher: ^6.0.20
  uuid: ^3.0.6

dev_dependencies:
  flutter_launcher_icons: ^0.9.2
  # The 'flutter_lints' package below contains a set of recommended lints to
  # encourage good coding practices. The lint set provided by the package is
  # activated in the `analysis_options.yaml` file located at the root of your
  # package. See that file for information about deactivating specific lint
  # rules and activating additional ones.
  flutter_lints: ^1.0.0
  flutter_test:
    sdk: flutter
  msix: ^3.3.1

flutter:
  uses-material-design: true
  assets:
    - assets/.env
    - assets/icon/
    - assets/images/
  fonts:
    - family: FiraSans
      fonts:
        - asset: assets/fonts/FiraSans/FiraSans-Thin.ttf
          weight: 100
        - asset: assets/fonts/FiraSans/FiraSans-ThinItalic.ttf
          style: italic
          weight: 100
        - asset: assets/fonts/FiraSans/FiraSans-ExtraLight.ttf
          weight: 200
        - asset: assets/fonts/FiraSans/FiraSans-ExtraLightItalic.ttf
          style: italic
          weight: 200
        - asset: assets/fonts/FiraSans/FiraSans-Light.ttf
          weight: 300
        - asset: assets/fonts/FiraSans/FiraSans-LightItalic.ttf
          style: italic
          weight: 300
        - asset: assets/fonts/FiraSans/FiraSans-Regular.ttf
          weight: 400
        - asset: assets/fonts/FiraSans/FiraSans-Italic.ttf
          style: italic
          weight: 400
        - asset: assets/fonts/FiraSans/FiraSans-Medium.ttf
          weight: 500
        - asset: assets/fonts/FiraSans/FiraSans-MediumItalic.ttf
          style: italic
          weight: 500
        - asset: assets/fonts/FiraSans/FiraSans-SemiBold.ttf
          weight: 600
        - asset: assets/fonts/FiraSans/FiraSans-SemiBoldItalic.ttf
          style: italic
          weight: 600
        - asset: assets/fonts/FiraSans/FiraSans-Bold.ttf
          weight: 700
        - asset: assets/fonts/FiraSans/FiraSans-BoldItalic.ttf
          style: italic
          weight: 700
        - asset: assets/fonts/FiraSans/FiraSans-ExtraBold.ttf
          weight: 800
        - asset: assets/fonts/FiraSans/FiraSans-ExtraBoldItalic.ttf
          style: italic
          weight: 800
        - asset: assets/fonts/FiraSans/FiraSans-Black.ttf
          weight: 900
        - asset: assets/fonts/FiraSans/FiraSans-BlackItalic.ttf
          style: italic
          weight: 900

flutter_icons:
  image_path_android: assets/icon/icon.transparent.png
  image_path_ios: assets/icon/icon.solid.png
  android: launcher_icon
  ios: true
  adaptive_icon_background: '#e44b34'
  adaptive_icon_foreground: assets/icon/icon.foreground.png

msix_config:
  store: true
  display_name: Tomatoro
  publisher_display_name: Entropy Positive
  identity_name: com.sidevesh.tomatoro
  publisher: XX=XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXX
  msix_version: 1.0.26.30
  architecture: x64
  capabilities: internetClient
  languages: en-us
  logo_path: ./assets/icon/icon.transparent.png
  toast_activator:
    clsid: d3eaf1f0-abaa-4ac3-9e39-1dcb81b79db0
sidevesh commented 2 years ago

It looks like the string that is there in place of app name is actually the AUMID of the app.

sidevesh commented 2 years ago

@azchohfi would you have any pointers on why this issue is happening ? I went through the relevant Microsoft documentation on this, seems like this issue could happen if a shortcut isn't added to Start with the AUMID, but is for Win32 apps I think and msix apps don't create the shortcuts themselves so that doesn't seem relevant. Also went through source code for the notification plugins as well as your PR adding toast support but with my very limited Windows development knowledge I couldn't figure it out.

azchohfi commented 2 years ago

@andrewleader could you please advise on what can possibly be happening here?

azchohfi commented 2 years ago

Ok, I've spoken with @andrewleader, and he told me that the reason this is likely happening is because both libs are using the ToastNotificationManager.CreateToastNotifier with the AUMID, and not the version without parameters of this method, which is what should be used with packaged apps (in the vast majority of cases).

The Windows Community Toolkit implements the required logic to detect if an app is packaged or unpackaged, to call the proper API (but it is all C#, not C++): https://github.com/CommunityToolkit/WindowsCommunityToolkit/blob/3bf88b8e6ea1e30b4bb027d3128345446aea141e/Microsoft.Toolkit.Uwp.Notifications/Toasts/Compat/Desktop/DesktopBridgeHelpers.cs

On Andrew's words: "HasIdentity: True if MSIX or sparse packaged app (if you want to support sparse packaged apps, that throws another layer of complexity onto it) IsContainerized: True only if MSIX packaged (false for sparse and unpackaged) For most cases, all you need to care about is HasIdentity... For deciding whether to use the overloaded method... HasIdentity true = CreateToastNotifier() HasIdentity false = CreateToastNotifier(myAumid)"

I hope this helps.

To summarize, the issue opened here is not an issue on @YehudaKremer's MSIX package, but a misunderstanding of the respective APIs that each of the reported libraries are calling.

sidevesh commented 2 years ago

Hey @azchohfi , Thanks for helping debug this and as it turns out that does solve the issue for both the libraries. Although after the change I have noticed another issue which wasn't happening before. If I click on the notification, it ends up creating a new window, which wasn't the case before and this happens with both the libraries.

YehudaKremer commented 2 years ago

Hey @azchohfi , Thanks for helping debug this and as it turns out that does solve the issue for both the libraries. Although after the change I have noticed another issue which wasn't happening before. If I click on the notification, it ends up creating a new window, which wasn't the case before and this happens with both the libraries.

duplicate https://github.com/YehudaKremer/msix/issues/136