YehudaKremer / msix

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

[BUG] Not displaying win_toast notifications #226

Open AnAlpaca opened 11 months ago

AnAlpaca commented 11 months ago

:information_source: Info

Version: e.g. v3.16.1

:speech_balloon: Description

Hi there, firstIy I want to start off by saying a huge thank you for developing this package and I see how active you have been in helping out members of the community.

I have succesfully created an msix package for my app. The installer works perfectly! However I am having issues with getting windows notifications to appear. I have provided the all the details necessary for toast activation (from what i have read and understood). I have also done a lot of research into the notifications setup, reading past commits of yours and from win_toast as well as other problems people have had with this in the issues section. I have followed and checked all of this, each time trying small changes thinking that I had uncovered the silver bullet to solve the problem.

Notifications work perfectly in debug and release builds and then break after packaging it into an msix.

Any assistance would be greatly appreciated

Have a great day.

:scroll: Pubspec.yaml

name: pageMe
description: Chat securely and privately.
publish_to: none
version: 0.1.2+38

environment:
  sdk: ">=3.0.0 <4.0.0"

dependencies:
  async: ^2.11.0
  adaptive_dialog: ^1.9.0
  adaptive_theme: ^3.0.0
  animations: ^2.0.7
  badges: ^2.0.3
  blurhash_dart: ^1.1.0
  callkeep: ^0.3.2
  chat_bubbles: ^1.3.1
  chewie: ^1.5.0
  collection: ^1.16.0
  connectivity_plus: ^3.0.2
  contextmenu: ^3.0.0
  convert: ^3.1.1
  cupertino_icons: any
  desktop_drop: ^0.4.0
  desktop_lifecycle: ^0.1.0
  desktop_notifications: ^0.6.3
  device_info_plus: ^9.0.0
  dynamic_color: ^1.6.0
  email_validator: ^2.0.1
  emoji_picker_flutter: ^1.5.1
  emoji_proposal: ^0.0.1
  emojis: ^0.9.9
  equatable: any
  fcm_shared_isolate:
    git:
      url: https://gitlab.com/CalvinVW/fcm_shared_isolate.git
      ref: '30861b0a'
  firebase_core: ^2.15.0
  firebase_messaging: ^14.6.5
  ffi: ^2.0.2
  file_picker: ^5.3.0
  flutter:
    sdk: flutter
  flutter_apns_only: ^1.6.0
  flutter_app_badger: ^1.5.0
  flutter_app_lock: ^3.0.0
  flutter_background: ^1.2.0
  flutter_bloc: ^8.1.1
  flutter_blurhash: ^0.7.0
  flutter_cache_manager: ^3.3.0
  flutter_foreground_task: ^6.0.0
  flutter_highlighter: ^0.1.1
  flutter_hms_gms_availability: ^3.0.0
  flutter_html: ^3.0.0-beta.2
  flutter_html_table: ^3.0.0-beta.2
  flutter_inappwebview: ^5.7.2+3
  flutter_keyboard_visibility: ^5.4.0
  flutter_linkify: ^6.0.0
  flutter_local_notifications: ^12.0.4
  flutter_localizations:
    sdk: flutter
  flutter_map: ^3.1.0
  #flutter_matrix_html: ^1.1.0
  flutter_menu: ^0.4.1
  flutter_olm: ^1.2.0
  flutter_openssl_crypto: ^0.1.0
  flutter_persistent_keyboard_height: ^1.0.5
  flutter_quill: ^7.2.3
  flutter_quill_extensions: ^0.3.2
  flutter_ringtone_player: ^3.1.1
  flutter_secure_storage: ^7.0.1
  flutter_sticky_header: ^0.6.5
  flutter_svg: ^2.0.3
  flutter_typeahead: ^4.3.7
  flutter_web_auth: ^0.5.0
  flutter_webrtc: ^0.9.32
  future_loading_dialog: ^0.2.3
  geolocator: ^9.0.2
  google_api_availability: ^3.0.1
  google_fonts: ^4.0.3
  grouped_list: ^5.1.2
  handy_window: ^0.1.9
  hive: ^2.2.3
  hive_flutter: ^1.1.0
  http: ^0.13.4
  huawei_hmsavailability: ^6.6.0+300
  huawei_push: ^6.5.0+300
  image: ^4.0.15
  image_compression_flutter: ^1.0.3
  #image_editor_plus:
  #  #path: /home/csvw/Software/Projects/Flutter/image_editor_plus
  #  git:
  #    url: https://github.com/AnAlpaca/image_editor_plus.git
  #    ref: '99624e4'
  image_picker: ^0.8.6
  introduction_screen: ^3.1.2
  intl: any
  isolate: ^2.1.1
  just_audio: ^0.9.30
  just_audio_mpv: ^0.1.6
  keyboard_shortcuts: ^0.1.4
  launch_at_startup: ^0.2.2
  localstorage: ^4.0.0+1
  logger: ^1.1.0
  lottie: ^2.0.0
  matrix: ^0.22.0
  matrix_homeserver_recommendations: ^0.3.0
  matrix_link_text: ^2.0.0
  native_imaging: ^0.1.0
  open_filex: ^4.3.2
  open_mail_app: ^0.4.5
  package_info_plus: ^4.0.1
  pageme_client:
    git:
      url: https://gitlab.com/CalvinVW/pageme_client.git
      ref: 85c2839a
  path: ^1.8.2
  path_provider: ^2.0.9
  permission_handler: ^10.2.0
  pin_code_text_field: ^1.8.0
  provider: ^6.0.4
  punycode: ^1.0.0
  purchases_flutter: ^5.6.0
  qr_code_scanner: ^1.0.1
  qr_flutter: ^4.0.0
  receive_sharing_intent: ^1.4.5
  record: ^4.4.4
  scroll_to_index: ^3.0.1
  searchbar_animation: ^0.0.4
  sentry: ^6.3.0
  serverpod_flutter: ^1.1.1
  serverpod_auth_shared_flutter: ^1.1.1
  serverpod_auth_email_flutter: ^1.1.1
  share_plus: ^4.5.3
  shared_preferences: ^2.0.15
  slugify: ^2.0.0
  snapping_sheet: ^3.1.0
  stop_watch_timer: ^2.0.0
  swipe_to: ^1.0.2
  swipeable: ^1.1.0
  thumbnailer: ^2.2.0
  uni_links: ^0.5.1
  unifiedpush: ^4.0.0
  universal_html: ^2.0.8
  url_launcher: ^6.1.7
  uuid: ^3.0.7
  vibration: ^1.7.4-nullsafety.0
  video_compress: ^3.1.1
  video_player: ^2.2.18
  vrouter: ^1.2.1
  vsc_quill_delta_to_html: ^1.0.2
  wakelock: ^0.6.2
  webrtc_interface: ^1.0.10
  window_manager: 0.3.2
  win_toast: ^0.3.0
  pdfx: ^2.4.0

dev_dependencies:
  dart_code_metrics: ^4.10.1
  flutter_launcher_icons: ^0.12.0
  flutter_lints: ^2.0.1
  flutter_native_splash: ^2.0.3+1
  flutter_test:
    sdk: flutter
  import_sorter: ^4.6.0
  integration_test:
    sdk: flutter
  msix: ^3.6.2

flutter_native_splash:
  color: "#d2e5ff"
  color_dark: "#000000"
  image: assets/pageme_app_logo_ transparent_splash_screen.png
  image_dark: assets/pageme_app_logo_ transparent_splash_screen.png
  branding: assets/matrix_logo.png
  branding_dark: assets/matrix_logo.png
  branding_mode: bottom

  android_12:
    color: "#d2e5ff"
    color_dark: "#000000"
    icon_background_color: "#d2e5ff"
    icon_background_color_dark: "#000000"
    image: assets/pageme_app_logo_ transparent_splash_screen.png
    image_dark: assets/pageme_app_logo_ transparent_splash_screen.png
    branding: assets/matrix_logo.png
    branding_dark: assets/matrix_logo.png
    branding_mode: bottom

flutter:
  generate: true
  uses-material-design: true
  assets:
    - assets/
    - assets/sounds/
    - assets/js/
    - assets/js/package/
    - assets/html/index.html

  fonts:
    - family: Roboto
      fonts:
        - asset: fonts/Roboto/Roboto-Regular.ttf
        - asset: fonts/Roboto/Roboto-Italic.ttf
          style: italic
        - asset: fonts/Roboto/Roboto-Bold.ttf
          weight: 700
    - family: NotoEmoji
      fonts:
        - asset: fonts/NotoEmoji/NotoColorEmoji.ttf

msix_config:
  display_name: PageMe Business
  publisher_display_name: PageMe
  publisher: CN=PageMe, O=PAGEME (PTY) LTD, L=Matrix, S=Internet, C=EU
  identity_name: com.pageme.business
  logo_path: assets/pageme_app_logo.png
  capabilities: internetClient, location, microphone, webcam
  protocol_activation: https
  app_uri_handler_hosts: com.pageme.business, matrix.to
  execution_alias: pageme_business
  certificate_path: C:\Documents\CERTIFICATE.pfx
  certificate_password: <sensitive>
  toast_activator: #<-- toast notifications configuration
    clsid: A1232234-1234-1234-1234-123412341234 #this is not real but i put the same on as FlavorConfig.applicationGUID
    arguments: "-ToastActivated"
    display_name: "PageMe Business"

dependency_overrides:
  # This otherwise breaks on linux with flutter 3.7.0, let's override it for now.
  flutter_math_fork: ^0.7.1
  file_selector: ^0.9.2+2
  file_selector_linux: ^0.9.1
  flutter_svg: ^2.0.3
  # fake secure storage plugin for Windows
  # See: https://gitlab.com/gitlab-com/gl-infra/reliability/-/issues/15161
  flutter_secure_storage_windows:
    git:
      url: https://gitlab.com/TheOneWithTheBraid/flutter_secure_storage_windows.git
      ref: main
  #geolocator_android:
  #  hosted:
  #    name: geolocator_android
  #    url: https://hanntech-gmbh.gitlab.io/free2pass/flutter-geolocator-floss
  # waiting for null safety
  # Upstream pull request: https://github.com/AntoineMarcel/keyboard_shortcuts/pull/13
  matrix_api_lite: ^1.6.1
  keyboard_shortcuts:
    git:
      url: https://github.com/AnAlpaca/keyboard_shortcuts.git
      ref: calv-002
  swipeable:
    git:
      url: https://github.com/ereio/swipeable.git
      ref: 867b117f15f51404e31597d8ab9d5325f6b52938

  wakelock_windows:
    git:
      url: https://github.com/formigas/wakelock.git
      path: wakelock_windows/
      ref: main

:scroll: Flutter Code

  Future<void> _initializeWinToast() async {
    Logs().i('[Windows Notifications: Initializing]');
    //final installationPath = getInstallationPath();
    //final iconPath = p.join(installationPath, 'assets\\pageme_business_logo.png');
    //Logs().i( iconPath);
    final ret = await windowsNotifications!.initialize(
      aumId: FlavorConfig.appId,
      displayName: FlavorConfig.applicationName,
      iconPath: '', // Optional: Path to your app's icon
      clsid: FlavorConfig.applicationGUID,
    );
    setState(() {
      initializedWinToast = ret;
    });

    windowsNotifications!.setActivatedCallback((notification) {
      final Map<String, dynamic> args = jsonDecode(notification.argument);
      switch (args['action']) {
        case 'openChat':
          VRouter.of(navigatorContext).toSegments(['rooms', args['roomId']]);
          break;
        case 'markAsRead':
          final room = client.getRoomById(args['roomId']);
          if (room != null) {
            final event = Event.fromJson(args['event'], room);
            room.setReadMarker(event.eventId, mRead: event.eventId);
          }
          break;
      }
    });
    Logs().i('[Windows Notifications: Initialized result: $ret]');
  }

:scroll: MSIX Config

msix_config:
  display_name: PageMe Business
  publisher_display_name: PageMe
  publisher: CN=PageMe, O=PAGEME (PTY) LTD, L=Matrix, S=Internet, C=EU
  identity_name: com.pageme.business
  logo_path: assets/pageme_app_logo.png
  capabilities: internetClient, location, microphone, webcam
  protocol_activation: https
  app_uri_handler_hosts: com.pageme.business, matrix.to
  execution_alias: pageme_business
  certificate_path: C:\Documents\CERTIFICATE.pfx
  certificate_password: <sensitive>
  toast_activator: #<-- toast notifications configuration
    clsid: A1232234-1234-1234-1234-123412341234 #this is not real but i put the same on as FlavorConfig.applicationGUID
    arguments: "-ToastActivated"
    display_name: "PageMe Business"
AnAlpaca commented 11 months ago

Okay so I have done some more digging, and so far I think I have found the problem, but I may need some guidance for a solution.

So looking in Windows Event Viewer I found the following after install:

An application was registered with the following parameters: PageMe.PageMe-Business_0.1.2.38_x64__xacta6rn58wma [PackageFullName] PageMe.PageMe-Business_xacta6rn58wma!pageMe [AppUserModelId] 0x4007F00 [Settings] 268435456 [AppType] The operation completed successfully. [ErrorCode].

Then triggering what should be a notification in the app I see the following:

Toast with notification tracking id 28979 is being delivered to PageMe.PageMe-Business_xacta6rn58wma!PageMe.PageMe-Business on session 2.

So clearly we can see that the AUMID being called verus registered is different. PageMe.PageMe-Business_xacta6rn58wma!pageMe PageMe.PageMe-Business_xacta6rn58wma!PageMe.PageMe-Business

Now in the in my pubspec I have the following config.

msix_config:
  display_name: PageMe Business
  publisher_display_name: PageMe
  publisher: E=info@pageme.co.za, CN=pageme, OU=Development, O=PAGEME (PTY) LTD, L=Durban, S=KwaZulu Natal, C=ZA
  identity_name: PageMe.PageMe-Business
  msix_version: 0.1.2.38
  logo_path: assets/pageme_business_logo_rounded.png
  capabilities: internetClient, location, microphone, webcam
  protocol_activation: https
  app_uri_handler_hosts: com.pageme.business, matrix.to
  execution_alias: pageme_business
  certificate_path: C:\Users\calvi\Documents\PageMe Admin\CERTIFICATE.pfx
  certificate_password: <hidden>
  output_name: pageme_business_0.1.2_windows_installer
  install_certificate: true
  #output_path: C:\Users\calvi\Documents\PageMe Admin
  app_installer:
    publish_folder_path: C:\Users\calvi\Documents\PageMe Admin
    automatic_background_task: true
    update_blocks_activation: true
    show_prompt: true
  enable_at_startup: true
  toast_activator:
    clsid: "f843b11f-2d5e-4782-a17e-505ed576715d"
    arguments: "-ToastActivated"
    display_name: "PageMe Business"

And in the WinToast initialization:

   Future<void> _initializeWinToast() async {
    Logs().i('[Windows Notifications: Initializing]');
    final ret = await windowsNotifications!.initialize(
      aumId: 'PageMe.PageMe-Business',
      displayName: FlavorConfig.applicationName,
      iconPath: '', // Optional: Path to your app's icon
      clsid: FlavorConfig.applicationGUID, //this is the same clsid as pubspec
    );
    setState(() {
      initializedWinToast = ret;
    });

So i have the same Identity_name and aumid as PageMe.PageMe-Business

But then the it is calling the wrong aumid for the actual notification. Any advice here.

Looking at it now, this seems borderline as to whether this should be on your repo or win_toast

gmgm60 commented 6 months ago

any updates ?