using Foundation;
using UIKit;
using Xamarin.Forms;

namespace TINK.iOS
{
	// The UIApplicationDelegate for the application. This class is responsible for launching the 
	// User Interface of the application, as well as listening (and optionally responding) to 
	// application events from iOS.
	[Register("AppDelegate")]
	public partial class AppDelegate : global::Xamarin.Forms.Platform.iOS.FormsApplicationDelegate
	{
		//
		// This method is invoked when the application has loaded and is ready to run. In this 
		// method you should instantiate the window, load the UI into it and then make the window
		// visible.
		//
		// You have 17 seconds to return from this method, or iOS will terminate your application.
		//
		public override bool FinishedLaunching(UIApplication app, NSDictionary options)
		{
			global::Xamarin.Forms.Forms.Init ();

			new iOS.Device.AppInfo(NSBundle.MainBundle.InfoDictionary[new NSString("CFBundleShortVersionString")]?.ToString() ?? string.Empty);

            Forms.ViewInitialized += (object sender, ViewInitializedEventArgs e) => {
                // http://developer.xamarin.com/recipes/testcloud/set-accessibilityidentifier-ios/
                if (null != e.View.AutomationId)
                {
                    e.NativeView.AccessibilityIdentifier = e.View.AutomationId;
                }
            };
            LoadApplication (new App ());

            // Required for initialization of Maps, see https://developer.xamarin.com/guides/xamarin-forms/user-interface/map/
            Xamarin.FormsGoogleMaps.Init("000000000000000000000000000000000000000");

            // Required for initialization of binding package, see  https://github.com/nuitsjp/Xamarin.Forms.GoogleMaps.Bindings.
            Xamarin.FormsGoogleMapsBindings.Init();

            return base.FinishedLaunching (app, options);
		}
	}
}