コード例 #1
0
 public void InitializerCalledTest()
 {
     Assert.Throws <SuccessException>(() => InsightsInitialization.Initialize(new ActionInitializer(s => { throw new SuccessException("You passed the test"); }), "Fake-Key", false));
 }
コード例 #2
0
 public void InitializerGivenCorrectKeyAsParameterTest()
 {
     InsightsInitialization.Initialize(new ActionInitializer(s => { Assert.AreEqual("Fake-Key", s); }), "Fake-Key", false);
 }
コード例 #3
0
 public void PlatformInitializerDoesNotExplodeWithoutKeyTest()
 {
     Assert.DoesNotThrow(() => InsightsInitialization.Initialize(_platformInitializer, "", false));
 }
コード例 #4
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(),
                Encryption             = new SimpleEncryption(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();

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

            LoadApplication(new App());

#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));
        }
コード例 #5
0
 public void InitializerExceptionsSuprressedTest()
 {
     Assert.DoesNotThrow(() => InsightsInitialization.Initialize(new ActionInitializer(s => { throw new Exception(); }), "Fake-Key"));
 }
コード例 #6
0
 public void InitializerNotCalledWhenKeyIsEmptyTest()
 {
     InsightsInitialization.Initialize(new ActionInitializer(s => { Assert.Fail(); }), "", false);
 }
コード例 #7
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));
        }