示例#1
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)
        {
            var settingsService = new SettingsService();

            settingsService.Init(this);

            _notificationHubsService = new NotificationHubsService();
            _notificationHubsService.Init(this);

            global::Xamarin.Forms.Forms.Init();
            LoadApplication(new App(settingsService, _notificationHubsService));

            if (UIDevice.CurrentDevice.CheckSystemVersion(8, 0))
            {
                UIApplication.SharedApplication.RegisterUserNotificationSettings(
                    UIUserNotificationSettings.GetSettingsForTypes(
                        UIUserNotificationType.Alert
                        | UIUserNotificationType.Badge
                        | UIUserNotificationType.Sound, null));
                UIApplication.SharedApplication.RegisterForRemoteNotifications();
            }
            else
            {
                UIApplication.SharedApplication.RegisterForRemoteNotificationTypes(UIRemoteNotificationType.Alert
                                                                                   | UIRemoteNotificationType.Badge
                                                                                   | UIRemoteNotificationType.Sound);
            }
            return(base.FinishedLaunching(app, options));
        }
示例#2
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            var settingsService = new SettingsService();

            settingsService.Init(this);

            var notificationHubsService = new NotificationHubsService();

            notificationHubsService.Init(this);

            global::Xamarin.Forms.Forms.Init(this, bundle);
            LoadApplication(new App(settingsService, notificationHubsService));
            notificationHubsService.RegisterOrUpdate();
        }