Ejemplo n.º 1
0
        public override bool FinishedLaunching(UIApplication uiApplication, NSDictionary launchOptions)
        {
            SensusServiceHelper.Initialize(() => new iOSSensusServiceHelper());

            // facebook settings
            Settings.AppID       = "873948892650954";
            Settings.DisplayName = "Sensus";

            Forms.Init();
            FormsMaps.Init();
            MapExtendRenderer.Init();

            ToastNotificatorImplementation.Init();

            App app = new App();

            LoadApplication(app);

            uiApplication.RegisterUserNotificationSettings(UIUserNotificationSettings.GetSettingsForTypes(UIUserNotificationType.Badge | UIUserNotificationType.Sound | UIUserNotificationType.Alert, new NSSet()));

            _serviceHelper = SensusServiceHelper.Get() as iOSSensusServiceHelper;

            UiBoundSensusServiceHelper.Set(_serviceHelper);
            app.SensusMainPage.DisplayServiceHelper(UiBoundSensusServiceHelper.Get(true));

            return(base.FinishedLaunching(uiApplication, launchOptions));
        }
Ejemplo n.º 2
0
        public override bool FinishedLaunching(UIApplication uiApplication, NSDictionary launchOptions)
        {
            #region configure context
            SensusContext.Current = new iOSSensusContext
            {
                Platform = Sensus.Context.Platform.iOS,
                MainThreadSynchronizer = new MainConcurrent(),
                SymmetricEncryption    = new SymmetricEncryption(SensusServiceHelper.ENCRYPTION_KEY)
            };

            // iOS introduced a new notification center in 10.0 based on UNUserNotifications
            if (UIDevice.CurrentDevice.CheckSystemVersion(10, 0))
            {
                UNUserNotificationCenter.Current.RequestAuthorizationAsync(UNAuthorizationOptions.Badge | UNAuthorizationOptions.Sound | UNAuthorizationOptions.Alert);
                UNUserNotificationCenter.Current.RemoveAllDeliveredNotifications();
                UNUserNotificationCenter.Current.RemoveAllPendingNotificationRequests();
                UNUserNotificationCenter.Current.Delegate = new UNUserNotificationDelegate();
                SensusContext.Current.CallbackScheduler   = new UNUserNotificationCallbackScheduler();
                SensusContext.Current.Notifier            = new UNUserNotificationNotifier();
            }
            // use the pre-10.0 approach based on UILocalNotifications
            else
            {
                UIApplication.SharedApplication.RegisterUserNotificationSettings(UIUserNotificationSettings.GetSettingsForTypes(UIUserNotificationType.Badge | UIUserNotificationType.Sound | UIUserNotificationType.Alert, new NSSet()));
                SensusContext.Current.CallbackScheduler = new UILocalNotificationCallbackScheduler();
                SensusContext.Current.Notifier          = new UILocalNotificationNotifier();
            }
            #endregion

            SensusServiceHelper.Initialize(() => new iOSSensusServiceHelper());

            // facebook settings
            Settings.AppID       = "873948892650954";
            Settings.DisplayName = "Sensus";

            Forms.Init();
            FormsMaps.Init();
            MapExtendRenderer.Init();
            new SfChartRenderer();
            ZXing.Net.Mobile.Forms.iOS.Platform.Init();

            LoadApplication(new App());

#if UI_TESTING
            Forms.ViewInitialized += (sender, e) =>
            {
                if (!string.IsNullOrWhiteSpace(e.View.StyleId))
                {
                    e.NativeView.AccessibilityIdentifier = e.View.StyleId;
                }
            };

            Calabash.Start();
#endif

            return(base.FinishedLaunching(uiApplication, launchOptions));
        }
Ejemplo n.º 3
0
        //
        // 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();
            LoadApplication(new App());

            MapExtendRenderer.Init();

            return(base.FinishedLaunching(app, options));
        }
Ejemplo n.º 4
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            global::Xamarin.Forms.Forms.Init(this, bundle);

            MapExtendRenderer.Init(this, bundle);

            LoadApplication(new App());
        }
Ejemplo n.º 5
0
        public MainPage()
        {
            InitializeComponent();
            SupportedOrientations = SupportedPageOrientation.PortraitOrLandscape;

            global::Xamarin.Forms.Forms.Init();
            string applicationId = "APP_ID_FROM_PORTAL", authToken = "AUTH_TOKEN_FROM_PORTAL";

            MapExtendRenderer.Init(applicationId, authToken);
            LoadApplication(new ProbandoMapas.App());
        }
Ejemplo n.º 6
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            SensusServiceHelper.Initialize(() => new AndroidSensusServiceHelper());

            _uiReadyWait             = new ManualResetEvent(false);
            _activityResultWait      = new ManualResetEvent(false);
            _facebookCallbackManager = CallbackManagerFactory.Create();
            _isForegrounded          = false;

            Window.AddFlags(global::Android.Views.WindowManagerFlags.DismissKeyguard);
            Window.AddFlags(global::Android.Views.WindowManagerFlags.ShowWhenLocked);
            Window.AddFlags(global::Android.Views.WindowManagerFlags.TurnScreenOn);

            Forms.Init(this, savedInstanceState);
            FormsMaps.Init(this, savedInstanceState);
            MapExtendRenderer.Init(this, savedInstanceState);

            _app = new App();
            LoadApplication(_app);

            _serviceConnection = new AndroidSensusServiceConnection();

            _serviceConnection.ServiceConnected += (o, e) =>
            {
                // it's happened that the service is created / started after the service helper is disposed:  https://insights.xamarin.com/app/Sensus-Production/issues/46
                // binding to the service in such a situation can result in a null service helper within the binder.
                if (e.Binder.SensusServiceHelper == null)
                {
                    Finish();
                    return;
                }

                // get reference to service helper for use within the UI
                UiBoundSensusServiceHelper.Set(e.Binder.SensusServiceHelper);

                // give service helper a reference to this activity
                e.Binder.SensusServiceHelper.MainActivityWillBeSet = false;
                e.Binder.SensusServiceHelper.SetMainActivity(this);

                // display service helper properties on the main page
                _app.SensusMainPage.DisplayServiceHelper(e.Binder.SensusServiceHelper);
            };

            _serviceConnection.ServiceDisconnected += (o, e) =>
            {
                DisconnectFromService();
            };

            OpenIntentAsync(Intent);
        }
Ejemplo n.º 7
0
        public MainPage()
        {
            InitializeComponent();
            SupportedOrientations = SupportedPageOrientation.PortraitOrLandscape;

            global::Xamarin.Forms.Forms.Init();

            string applicationId = "c8c9b802-012d-486d-a7a0-a991d78b4d04";
            string authToken     = "BJwZ5VMpoCBJID0f-Hb7AQ";

            MapExtendRenderer.Init(applicationId, authToken);

            LoadApplication(new HowUseMapExtend.App());
        }
Ejemplo n.º 8
0
        public override bool FinishedLaunching(UIApplication uiApplication, NSDictionary launchOptions)
        {
            InsightsInitialization.Initialize(new iOSInsightsInitializer(UIDevice.CurrentDevice.IdentifierForVendor.AsString()), SensusServiceHelper.XAMARIN_INSIGHTS_APP_KEY);

            SensusContext.Current = new iOSSensusContext(SensusServiceHelper.ENCRYPTION_KEY);
            SensusServiceHelper.Initialize(() => new iOSSensusServiceHelper());

            // facebook settings
            Settings.AppID       = "873948892650954";
            Settings.DisplayName = "Sensus";

            Forms.Init();
            FormsMaps.Init();
            MapExtendRenderer.Init();
            new SfChartRenderer();

            // toasts for iOS
            DependencyService.Register <ToastNotificatorImplementation>();
            ToastNotificatorImplementation.Init();

            LoadApplication(new App());

            uiApplication.RegisterUserNotificationSettings(UIUserNotificationSettings.GetSettingsForTypes(UIUserNotificationType.Badge | UIUserNotificationType.Sound | UIUserNotificationType.Alert, new NSSet()));

#if UNIT_TESTING
            Forms.ViewInitialized += (sender, e) =>
            {
                if (!string.IsNullOrWhiteSpace(e.View.StyleId))
                {
                    e.NativeView.AccessibilityIdentifier = e.View.StyleId;
                }
            };

            Calabash.Start();
#endif

            return(base.FinishedLaunching(uiApplication, launchOptions));
        }
        public override bool FinishedLaunching(UIApplication app, NSDictionary options)
        {
            global::Xamarin.Forms.Forms.Init();
            MapExtendRenderer.Init();
            Xamarin.FormsMaps.Init();               //so we can get the map to load
            ImageCircleRenderer.Init();             //so we can get the image circle properties
            SQLitePCL.CurrentPlatform.Init();

            //doing this call here so as to speed up the load when someone goes to the
            //List of Beer Page

            window = new UIWindow(UIScreen.MainScreen.Bounds);
            window.RootViewController = App.GetMainPage().CreateViewController();
            window.MakeKeyAndVisible();


            App.UIContext = window.RootViewController;
            return(true);


//			LoadApplication (new App ());
//
//			return base.FinishedLaunching (app, options);
        }
Ejemplo n.º 10
0
        public override bool FinishedLaunching(UIApplication uiApplication, NSDictionary launchOptions)
        {
            // insights should be initialized first to maximize coverage of exception reporting
            InsightsInitialization.Initialize(new iOSInsightsInitializer(UIDevice.CurrentDevice.IdentifierForVendor.AsString()), SensusServiceHelper.XAMARIN_INSIGHTS_APP_KEY);

            #region configure context
            SensusContext.Current = new iOSSensusContext
            {
                Platform = Sensus.Context.Platform.iOS,
                MainThreadSynchronizer = new MainConcurrent(),
                SymmetricEncryption    = new SymmetricEncryption(SensusServiceHelper.ENCRYPTION_KEY)
            };

            // iOS introduced a new notification center in 10.0 based on UNUserNotifications
            if (UIDevice.CurrentDevice.CheckSystemVersion(10, 0))
            {
                UNUserNotificationCenter.Current.RequestAuthorizationAsync(UNAuthorizationOptions.Badge | UNAuthorizationOptions.Sound | UNAuthorizationOptions.Alert);
                UNUserNotificationCenter.Current.RemoveAllDeliveredNotifications();
                UNUserNotificationCenter.Current.RemoveAllPendingNotificationRequests();
                UNUserNotificationCenter.Current.Delegate = new UNUserNotificationDelegate();
                SensusContext.Current.CallbackScheduler   = new UNUserNotificationCallbackScheduler();
                SensusContext.Current.Notifier            = new UNUserNotificationNotifier();
            }
            // use the pre-10.0 approach based on UILocalNotifications
            else
            {
                UIApplication.SharedApplication.RegisterUserNotificationSettings(UIUserNotificationSettings.GetSettingsForTypes(UIUserNotificationType.Badge | UIUserNotificationType.Sound | UIUserNotificationType.Alert, new NSSet()));
                SensusContext.Current.CallbackScheduler = new UILocalNotificationCallbackScheduler();
                SensusContext.Current.Notifier          = new UILocalNotificationNotifier();
            }
            #endregion

            SensusServiceHelper.Initialize(() => new iOSSensusServiceHelper());

            // facebook settings
            Settings.AppID       = "873948892650954";
            Settings.DisplayName = "Sensus";

            Forms.Init();
            FormsMaps.Init();
            MapExtendRenderer.Init();
            new SfChartRenderer();
            ZXing.Net.Mobile.Forms.iOS.Platform.Init();

            LoadApplication(new App());

#if UI_TESTING
            Forms.ViewInitialized += (sender, e) =>
            {
                if (!string.IsNullOrWhiteSpace(e.View.StyleId))
                {
                    e.NativeView.AccessibilityIdentifier = e.View.StyleId;
                }
            };

            Calabash.Start();
#endif

            // background authorization will be done implicitly when the location manager is used in probes, but the authorization is
            // done asynchronously so it's likely that the probes will believe that GPS is not enabled/authorized even though the user
            // is about to grant access (if they choose). now, the health test should fix this up by checking for GPS and restarting
            // the probes, but the whole thing will seem strange to the user. instead, prompt the user for background authorization
            // immediately. this is only done one time after the app is installed and started.
            _locationManager.RequestAlwaysAuthorization();

            return(base.FinishedLaunching(uiApplication, launchOptions));
        }
Ejemplo n.º 11
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            Console.Error.WriteLine("--------------------------- Creating activity ---------------------------");

            base.OnCreate(savedInstanceState);

            _activityResultWait      = new ManualResetEvent(false);
            _facebookCallbackManager = CallbackManagerFactory.Create();
            _serviceBindWait         = new ManualResetEvent(false);

            Window.AddFlags(global::Android.Views.WindowManagerFlags.DismissKeyguard);
            Window.AddFlags(global::Android.Views.WindowManagerFlags.ShowWhenLocked);
            Window.AddFlags(global::Android.Views.WindowManagerFlags.TurnScreenOn);

            Forms.Init(this, savedInstanceState);
            FormsMaps.Init(this, savedInstanceState);
            MapExtendRenderer.Init(this, savedInstanceState);
            CrossCurrentActivity.Current.Activity = this;

#if UNIT_TESTING
            Forms.ViewInitialized += (sender, e) =>
            {
                if (!string.IsNullOrWhiteSpace(e.View.StyleId))
                {
                    e.NativeView.ContentDescription = e.View.StyleId;
                }
            };
#endif

            _app = new App();
            LoadApplication(_app);

            MobileBarcodeScanner.Initialize(Application);

            _serviceConnection = new AndroidSensusServiceConnection();

            _serviceConnection.ServiceConnected += (o, e) =>
            {
                // it's happened that the service is created / started after the service helper is disposed:  https://insights.xamarin.com/app/Sensus-Production/issues/46
                // binding to the service in such a situation can result in a null service helper within the binder. if the service helper was disposed, then the goal is
                // to close down sensus. so finish the activity.
                if (e.Binder.SensusServiceHelper == null)
                {
                    Finish();
                    return;
                }

                if (e.Binder.SensusServiceHelper.BarcodeScanner == null)
                {
                    try
                    {
                        e.Binder.SensusServiceHelper.BarcodeScanner = new MobileBarcodeScanner();
                    }
                    catch (Exception ex)
                    {
                        e.Binder.SensusServiceHelper.Logger.Log("Failed to create barcode scanner:  " + ex.Message, LoggingLevel.Normal, GetType());
                    }
                }

                // tell the service to finish this activity when it is stopped
                e.Binder.ServiceStopAction = Finish;

                // signal the activity that the service has been bound
                _serviceBindWait.Set();

                // if we're unit testing, try to load and run the unit testing protocol from the embedded assets
#if UNIT_TESTING
                using (Stream protocolFile = Assets.Open("UnitTestingProtocol.json"))
                {
                    Protocol.RunUnitTestingProtocol(protocolFile);
                }
#endif
            };

            // the following is fired if the process hosting the service crashes or is killed.
            _serviceConnection.ServiceDisconnected += (o, e) =>
            {
                Toast.MakeText(this, "The Sensus service has crashed.", ToastLength.Long);
                DisconnectFromService();
                Finish();
            };

            OpenIntentAsync(Intent);
        }