Alpay Çalışır
Alpay Çalışır

Reputation: 187

Intune SDK Integration Causes UIBarButtonItem State Issue in .Net Maui

I'm working on a .Net Maui app where I need to disable the share button (UIBarButtonItem) in the previewed item navigation bar and toolbar. However, when the app is integrated with the Intune SDK , it seems that the button remains enabled even after I set item.Enabled = false. Here is the code I am using to control the state of the share button

public void ActionMenuControl()
{
   try
   {
      if (this.ChildViewControllers != null && this.ChildViewControllers.Length > 0)
      {
         foreach (UINavigationController navigationController in this.ChildViewControllers.OfType<UINavigationController>())
         {
            if (navigationController.View.Subviews != null && navigationController.View.Subviews.Length > 0)
            {
               foreach (UINavigationBar navigationBar in navigationController.View.Subviews.OfType<UINavigationBar>())
               {
                  if (navigationBar.Items != null && navigationBar.Items.Length > 0)
                  {
                     foreach (UIBarButtonItem item in navigationBar.Items[0].RightBarButtonItems)
                     {
                        if (item.AccessibilityIdentifier == "QLOverlayDoneButtonAccessibilityIdentifier")
                        {
                           item.Enabled = true; // Keep "Done" button enabled
                        }
                        else
                        {
                           item.Enabled = false; // Disable share button
                        }
                     }
                  }
    
                  TitleMenuControl(navigationBar);
               }
            }
    
            if (navigationController.Toolbar != null && navigationController.Toolbar.Items != null && navigationController.Toolbar.Items.Length > 0)
            {
               foreach (UIBarButtonItem item in navigationController.Toolbar.Items)
               {
                  if (item.AccessibilityIdentifier == "QLOverlayDoneButtonAccessibilityIdentifier")
                  {
                     item.Enabled = true; // Keep "Done" button enabled
                  }
                  else
                  {
                     item.Enabled = false; // Disable share button
                  }
               }
            }
         }
      }
   }
   catch (Exception ex)
   {
      App._logger.LogError(Helper.GetMethodInfo(MethodBase.GetCurrentMethod()), ex);
      Debug.WriteLine($"Exception in ActionMenuControl: {ex.Message}");
   }
}

Before integrating the Intune SDK , this code worked correctly, and the share button was properly disabled. However, after integrating Intune, even though I set item.Enabled = false for the share button, it remains enabled and visible as active when the app runs. How can I disable the share button (UIBarButtonItem) in my app, independently of Intune SDK App Protection policies?

Any help or suggestions would be greatly appreciated!

Upvotes: 1

Views: 36

Answers (0)

Related Questions