10 Replies Latest reply: Jul 21, 2017 7:18 AM by scywinski RSS

Xamarin.Forms iOS App Blank Screen after Good SDK Authentication

bradley.holbrook Newbie

I am trying to integrate the Good SDK into a Xamarin.Forms iOS app.

 

This issue has happened with multiple SDK versions, Forms versions, and XCode/OSX versions. Current setup:

iPad Air 2 running iOS 10.2.1

Xamarin Forms 2.3.3.180

Blackberry Dynamics SDK for iOS v3.0.2.51

Bindings for Xamarin iOS 3.0

Dump from About Xamarin Studio attached.

 

After the app authenticates to Good with an email address and access code, or switches back and forth from an authentication delegate application during Easy Activation, the Splash screen flashes, the Forms app MainPage flashes, then a white screen appears and the app is unusable. The app works fine without the GDSDK. Also, when I four-finger-swipe up, or double tap the home button, to access the multitasking screen, the Forms MainPage (my UI) flashes for a second.

 

This is the closest related post I’ve seen https://forums.xamarin.com/discussion/69317/white-screen-when-starting-on-iphone-6s. We’re not using any of those references, however.

 

As far as I can tell, it appears that a GDDefaultViewController is being displayed on top of my app UI. It could be that the GDSDK is “hijacking” the app Window and not giving it back, or I need some additional step to make my App Window KeyAndVisible after authentication. Any help is appreciated.

 

AppDelegate attached. Follows this guide http://blog.westmonroepartners.com/implementing-the-good-dynamics-sdk-with-xamarin-forms-on-ios/

App class and main page class attached - kept default “Hello World” Forms app

Full application output attached illustrating opening and closing the multitasking screen.

No app related Xcode device logs come in, nothing interesting in the Xcode Instruments trace.

 

Relevant section of application output:

 

Showing the splash controller when the app enters the background

Jan 31 12:03:25  FormsBoilerplate.iOS[237] <Notice>: UI NSObject: UIApplicationDelegate: WillResignActive

Jan 31 12:03:25  FormsBoilerplate.iOS[237] <Notice>: UI GDScreenList::addVC 28 GDScreenTypeSplash count=1 [1]

Jan 31 12:03:25  FormsBoilerplate.iOS[237] <Notice>: UI GDUIManager::windowUpdateLogic - 0 1

Jan 31 12:03:25  FormsBoilerplate.iOS[237] <Notice>: UI GDUIManager::windowUpdateLogic - there are GD screens to show [1,28]

Jan 31 12:03:25  FormsBoilerplate.iOS[237] <Notice>: UI GDWindowSwitcher::showGDWindow1

Jan 31 12:03:25  FormsBoilerplate.iOS[237] <Notice>: UI GDWindowSwitcher::showGDWindow2

Jan 31 12:03:25  FormsBoilerplate.iOS[237] <Notice>: UI GDSplashViewController:viewWillAppear: (animated = NO) <GDSplashViewController: 0x104a33090>

Jan 31 12:03:25  FormsBoilerplate.iOS[237] <Notice>: UI GDDefaultViewController:viewDidDisappear: (animated = NO) <GDDefaultViewController: 0x104b10780>

Jan 31 12:03:25  FormsBoilerplate.iOS[237] <Notice>: UI GDSplashViewController:viewDidAppear: (animated = NO) <GDSplashViewController: 0x104a33090>

 

reentering the foreground, and lastly, showing the GDDefaultViewController on top

Jan 31 12:03:27  FormsBoilerplate.iOS[237] <Notice>: UI NSObject: UIApplicationDelegate: DidBecomeActive

Jan 31 12:03:27  FormsBoilerplate.iOS[237] <Notice>: UI GDUIApplicationDelegate: didBecomeActive (IN)

Jan 31 12:03:27  FormsBoilerplate.iOS[237] <Notice>: SecurityPolicySettings::setAuthDelegatePolicy, auth delegate policy: com.good.gdgma

Jan 31 12:03:27  FormsBoilerplate.iOS[237] <Notice>: SecurityPolicySettings::setRequirePwdNotTouchIDPeriod m_requirePwdNotTouchIDPeriod = 8 hours

Jan 31 12:03:27  FormsBoilerplate.iOS[237] <Notice>: AUTH GDAuthDelegateSelector::selectAuthDelegatePolicyPair

Jan 31 12:03:27  FormsBoilerplate.iOS[237] <Notice>: AUTH GDAuthDelegateSelector::selectAuthDelegatePolicyPair, using primary auth delegate policy: com.good.gdgma

Jan 31 12:03:27  FormsBoilerplate.iOS[237] <Notice>: POL PolicyProcessor::enforceSecurityPolicy currentPwdType = 4 , newPwdType = 4

Jan 31 12:03:27  FormsBoilerplate.iOS[237] <Notice>: POL PolicyProcessor::enforceSecurityPolicy allowTouchID = 1 , touchIDwasChanged = 1

Jan 31 12:03:27  FormsBoilerplate.iOS[237] <Notice>: UI GDUIApplicationDelegate: didBecomeActive (OUT)

Jan 31 12:03:27  FormsBoilerplate.iOS[237] <Notice>: UI GDScreenList::removeScreen1 28 GDScreenTypeSplash count=2 [1,28]

Jan 31 12:03:27  FormsBoilerplate.iOS[237] <Notice>: UI GDUIManager::windowUpdateLogic - 1 1

Jan 31 12:03:27  FormsBoilerplate.iOS[237] <Notice>: UI GDUIManager::windowUpdateLogic - app is authorised and screen list is empty, so show app ui

Jan 31 12:03:27  FormsBoilerplate.iOS[237] <Notice>: UI GDWindowSwitcher::showApplicationWindow1

Jan 31 12:03:27  FormsBoilerplate.iOS[237] <Notice>: UI GDWindowSwitcher::showApplicationWindow2

Jan 31 12:03:27  FormsBoilerplate.iOS[237] <Notice>: UI GDWindowSwitcher::hideGDAlertWindow

Jan 31 12:03:27  FormsBoilerplate.iOS[237] <Notice>: UI GDSplashViewController:viewDidDisappear: (animated = NO) <GDSplashViewController: 0x104a33090>

Jan 31 12:03:27  FormsBoilerplate.iOS[237] <Notice>: UI GDDefaultViewController:viewDidAppear: (animated = NO) <GDDefaultViewController: 0x104b10780>

  • Re: Xamarin.Forms iOS App Blank Screen after Good SDK Authentication
    david210962 BlackBerry Employee

    Thanks for your comprehensive report. We will investigate this.

     

    David

  • Re: Xamarin.Forms iOS App Blank Screen after Good SDK Authentication
    josiwe Newbie

    For what it's worth I'm experiencing the same problem. Similar setup.

     

    You can fish the correct UIWindow and .MakeKeyAndVisible() during the GD OnAuthorized event, but that only works in the simulator. On devices the GDDefaultViewController window is always displayed over the Forms UI. Something about the GD Window logic seems to instantiate the default (blank) window and always gives it priority. It doesn't recognize the window from Xamarin Forms as the primary application UI.

     

    Edit: I'm also using the Good Launcher library in my app. Brad Holbrook are you?

  • Re: Xamarin.Forms iOS App Blank Screen after Good SDK Authentication
    scywinski BlackBerry

    Hi Bradley. The issue you are experiencing  is caused by the fact that GD SDK requires Application UI to be displayed in UIWindow that can be obtained from GDLibrary.GetWindow() and Xamarin.Forms uses its own instance of UIWindow to display the content. Neither GD nor XF provide method for setting their UIWindow. I think that the most reliable solution would be to Include Xamarin.Forms source code in your solution and modify FormsApplicationDelegate class so it uses GD SDK library.  Of course if you don’t want to do this, you can workaround the problem by not calling ‘base.FinishedLaunching ()’ and initializing root view controller inside your derived AppDelegate class. Please take note that by doing this you bypass some part of the Xamarin.Forms code, but it should work fine, unless you want to change App.MainPage during runtime.

     

    AppDelegate.cs

    public GDiOS GDLibrary { get; set; }
     
    private App _application;
    private MyGDDelegate _gdDelegate;
    private UIWindow _applicationWindow;
    
    public override bool FinishedLaunching(UIApplication app, NSDictionary options)
    {
         global::Xamarin.Forms.Forms.Init();
     
         GDLibrary = GDiOS.SharedInstance();
         _gdDelegate = new MyGDDelegate();
         _gdDelegate.OnGDAppEvent += OnGDAppEvent;
         GDLibrary.Delegate = _gdDelegate;
     
         _application = new App();
         LoadApplication(_application);
     
         _applicationWindow = GDLibrary.GetWindow();
         GDLibrary.Authorize();
         return true;
    }
    
    void OnAuthorized(object sender, GDAppEvent anEvent)
    {
         switch (anEvent.Code)
         {
              case GDAppResultCode.ErrorNone:
                   _applicationWindow.RootViewController = _application.MainPage.CreateViewController();
                   _applicationWindow.MakeKeyAndVisible();
    
                   _application.SendStart();
                   break;
              default:
                   Console.WriteLine("Unhandled unauthorized event");
                   break;
         }
    }
    
    
    
    

     

    App.xaml.cs

    internal void SendStart()
    {
         OnStart();
    }
    
    
    
    

     

    Thanks,

    Szymon.

     

    Edit:

    I attached sample solution (CoreData.zip), so anyone interested can build and debug it.

     

    Edit 2:

    There might occur an issue with GDAppEvents in the solution presented in the original answer, so I updated the code and attached sample.

    • Re: Xamarin.Forms iOS App Blank Screen after Good SDK Authentication
      josiwe Newbie

      Szymon Cywinski thank you! I can confirm this solution worked for me. We now have our xamarin forms app running on devices with the latest bits. I can confirm this approach also works with the Good Launcher - just added a few lines to get it up and running, and set up the binding to the launcher service in Good Control.

       

      // get the UIWindow that GD regards as the application UI window
      var applicationWindow = GDLibrary.GetWindow ();
      
      // set up the launcher view controller
      var uiRoot = _application.MainPage.CreateViewController ();
      var launcher = new GoodDynamics.iOS.Launcher.GTLauncherViewController (uiRoot);
      launcher.StartServicesWithOptions (GoodDynamics.iOS.Launcher.GTLauncherServicesStartupOptions.InternalGDAuthTokenAndPushConnectionManagement);
      
      // assign the root to the application window and make it key and visible
      applicationWindow.RootViewController = launcher;
      applicationWindow.MakeKeyAndVisible ();
      
    • Re: Xamarin.Forms iOS App Blank Screen after Good SDK Authentication
      bradley.holbrook Newbie

      This worked for me as well. Thank you! Have not tried the launcher yet.

  • Re: Xamarin.Forms iOS App Blank Screen after Good SDK Authentication
    janway Newbie

    We had the same problem and fixed it by moving the call to GDLibrary.Authorize to happen after base.FinishedLaunching, so that Forms can create the UIWindow before the GDWindowSwitcher grabs it.