示例#1
0
        public override void OnActivated(UIApplication uiApplication)
        {
            // since all notifications are about to be rescheduled, clear any scheduled / delivered notifications.
            UIApplication.SharedApplication.CancelAllLocalNotifications();
            UIApplication.SharedApplication.ApplicationIconBadgeNumber = 0;

            _serviceHelper.ActivationId = Guid.NewGuid().ToString();

            iOSSensusServiceHelper sensusServiceHelper = UiBoundSensusServiceHelper.Get(true) as iOSSensusServiceHelper;

            sensusServiceHelper.StartAsync(() =>
            {
                sensusServiceHelper.UpdateCallbackNotificationActivationIdsAsync();
            });

            base.OnActivated(uiApplication);
        }
示例#2
0
        public override void OnActivated(UIApplication uiApplication)
        {
            // since all notifications are about to be rescheduled/serviced, clear all current notifications.
            UIApplication.SharedApplication.CancelAllLocalNotifications();
            UIApplication.SharedApplication.ApplicationIconBadgeNumber = 0;

            iOSSensusServiceHelper serviceHelper = SensusServiceHelper.Get() as iOSSensusServiceHelper;

            serviceHelper.ActivationId = Guid.NewGuid().ToString();

            try
            {
                serviceHelper.BarcodeScanner = new ZXing.Mobile.MobileBarcodeScanner(UIApplication.SharedApplication.KeyWindow.RootViewController);
            }
            catch (Exception ex)
            {
                serviceHelper.Logger.Log("Failed to create barcode scanner:  " + ex.Message, LoggingLevel.Normal, GetType());
            }

            serviceHelper.StartAsync(() =>
            {
                serviceHelper.UpdateCallbackNotificationActivationIdsAsync();

#if UNIT_TESTING
                // load and run the unit testing protocol
                string filePath = NSBundle.MainBundle.PathForResource("UnitTestingProtocol", "json");
                using (Stream file = new FileStream(filePath, FileMode.Open, FileAccess.Read))
                {
                    Protocol.RunUnitTestingProtocol(file);
                }
#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.
            new CLLocationManager().RequestAlwaysAuthorization();

            base.OnActivated(uiApplication);
        }