public override bool FinishedLaunching(UIApplication application, NSDictionary launchOptions)
		{
			// create a new window instance based on the screen size
			Window = new UIWindow(UIScreen.MainScreen.Bounds);
			// If you have defined a root view controller, set it here:
			// Window.RootViewController = myViewController;
			// make the window visible
			Window.MakeKeyAndVisible();


/////////////////////////////////////////////////////////////

			UIApplication.SharedApplication.SetMinimumBackgroundFetchInterval(UIApplication.BackgroundFetchIntervalMinimum);

			if (UIDevice.CurrentDevice.CheckSystemVersion(8, 0))
			{
				var notificationSettings = UIUserNotificationSettings.GetSettingsForTypes(
					UIUserNotificationType.Badge, null
				);

				application.RegisterUserNotificationSettings(notificationSettings);
			}

/////////////////////////////////////////////////////////////

			return true;
		}
Example #2
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();

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

            LoadApplication(new App());

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

            _serviceHelper = SensusServiceHelper.Get() as iOSSensusServiceHelper;

            #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 application, NSDictionary launchOptions)
        {
            if (UIDevice.CurrentDevice.CheckSystemVersion(8, 0))
            {
                var notificationSettings = UIUserNotificationSettings.GetSettingsForTypes(
                    UIUserNotificationType.Alert | UIUserNotificationType.Badge | UIUserNotificationType.Sound, null
                );

                application.RegisterUserNotificationSettings(notificationSettings);
            }

            // check for a notification
            if (launchOptions != null)
            {
                // check for a local notification
                if (launchOptions.ContainsKey(UIApplication.LaunchOptionsLocalNotificationKey))
                {
                    var localNotification = launchOptions[UIApplication.LaunchOptionsLocalNotificationKey] as UILocalNotification;
                    if (localNotification != null)
                    {
                        UIAlertController okayAlertController = UIAlertController.Create(localNotification.AlertAction, localNotification.AlertBody, UIAlertControllerStyle.Alert);
                        okayAlertController.AddAction(UIAlertAction.Create("OK", UIAlertActionStyle.Default, null));

                        Window.RootViewController.PresentViewController(okayAlertController, true, null);

                        // reset our badge
                        UIApplication.SharedApplication.ApplicationIconBadgeNumber = 0;
                    }
                }
            }
            return true;
        }
Example #4
0
		public override bool FinishedLaunching (UIApplication application, NSDictionary launchOptions)
		{
			var notificationSettings = UIUserNotificationSettings.GetSettingsForTypes (UIUserNotificationType.Alert, null);
			application.RegisterUserNotificationSettings (notificationSettings);
			application.RegisterForRemoteNotifications ();

			return true;
		}
		public override bool FinishedLaunching (UIApplication app, NSDictionary options)
		{
			#if DEBUG
			Xamarin.Calabash.Start();
			#endif


			// create our window
			window = new UIWindow (UIScreen.MainScreen.Bounds);
			window.MakeKeyAndVisible ();

			home = new Screens.iPhone.Home.Home_iPhone();
			home.View.Frame = new CoreGraphics.CGRect (0, UIApplication.SharedApplication.StatusBarFrame.Height, UIScreen.MainScreen.ApplicationFrame.Width, UIScreen.MainScreen.ApplicationFrame.Height);
			window.RootViewController = home;

			// check for a notification
			if(options != null) {

				// check for a local notification
				if(options.ContainsKey(UIApplication.LaunchOptionsLocalNotificationKey)) {

					UILocalNotification localNotification = options[UIApplication.LaunchOptionsLocalNotificationKey] as UILocalNotification;
					if(localNotification != null) {

						new UIAlertView(localNotification.AlertAction, localNotification.AlertBody, null, "OK", null).Show();
						// reset our badge
						UIApplication.SharedApplication.ApplicationIconBadgeNumber = 0;
					}
				}

				// check for a remote notification
				if(options.ContainsKey(UIApplication.LaunchOptionsRemoteNotificationKey)) {

					NSDictionary remoteNotification = options[UIApplication.LaunchOptionsRemoteNotificationKey] as NSDictionary;
					if(remoteNotification != null) {
						//new UIAlertView(remoteNotification.AlertAction, remoteNotification.AlertBody, null, "OK", null).Show();
					}
				}
			}

			if (UIDevice.CurrentDevice.CheckSystemVersion (8, 0)) {
				var notificationSettings = UIUserNotificationSettings.GetSettingsForTypes (
					                           UIUserNotificationType.Alert | UIUserNotificationType.Badge | UIUserNotificationType.Sound, null
				                           );

				app.RegisterUserNotificationSettings (notificationSettings);
				app.RegisterForRemoteNotifications ();
			} else {
				//==== register for remote notifications and get the device token
				// set what kind of notification types we want
				UIRemoteNotificationType notificationTypes = UIRemoteNotificationType.Alert | UIRemoteNotificationType.Badge;
				// register for remote notifications
				UIApplication.SharedApplication.RegisterForRemoteNotificationTypes(notificationTypes);
			}

			return true;
		}
Example #6
0
		public override bool FinishedLaunching (UIApplication app, NSDictionary options)
		{
			// Override point for customization after application launch.
			UIUserNotificationSettings notificationSettings = UIUserNotificationSettings.GetSettingsForTypes (UIUserNotificationType.Alert, null);
			app.RegisterUserNotificationSettings (notificationSettings);;
			app.RegisterForRemoteNotifications ();

			return true;
		}
		public override bool FinishedLaunching (UIApplication app, NSDictionary options)
		{

			if (UIDevice.CurrentDevice.CheckSystemVersion (8, 0)) {
				var notificationSettings = UIUserNotificationSettings.GetSettingsForTypes (
					UIUserNotificationType.Alert | UIUserNotificationType.Badge | UIUserNotificationType.Sound, null
				);

				app.RegisterUserNotificationSettings (notificationSettings);
			} 

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

			// Code for starting up the Xamarin Test Cloud Agent
			#if ENABLE_TEST_CLOUD
			Xamarin.Calabash.Start();
			#endif

			LoadApplication (new App ());

			return base.FinishedLaunching (app, options);
		}
Example #8
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));

            if (launchOptions != null)
            {
                NSObject launchOptionValue;
                if (launchOptions.TryGetValue(UIApplication.LaunchOptionsLocalNotificationKey, out launchOptionValue))
                    ServiceNotificationAsync(launchOptionValue as UILocalNotification);
                else if (launchOptions.TryGetValue(UIApplication.LaunchOptionsUrlKey, out launchOptionValue))
                    Protocol.DisplayFromBytesAsync(File.ReadAllBytes((launchOptionValue as NSUrl).Path));
            }

            // service all other notifications whose fire time has passed
            foreach (UILocalNotification notification in uiApplication.ScheduledLocalNotifications)
                if (notification.FireDate.ToDateTime() <= DateTime.UtcNow)
                    ServiceNotificationAsync(notification);

            return base.FinishedLaunching(uiApplication, launchOptions);
        }
Example #9
0
		protected void RegisterNotifications (UIApplication application)
		{
			var lightsSwitchAction = new UIMutableUserNotificationAction {
				Identifier = LightsSwitchIdentifier,
				Title = "Zet lampen uit en aan",
				ActivationMode = UIUserNotificationActivationMode.Background,
				AuthenticationRequired = false,
				Destructive = true
			};
			var lightsOnAction = new UIMutableUserNotificationAction {
				Identifier = LightsOnIdentifier,
				Title = "Zet lampen aan",
				ActivationMode = UIUserNotificationActivationMode.Background,
				AuthenticationRequired = false
			};
			var lightsOffAction = new UIMutableUserNotificationAction {
				Identifier = LightsOffIdentifier,
				Title = "Zet lampen uit",
				ActivationMode = UIUserNotificationActivationMode.Background,
				AuthenticationRequired = false,
				Destructive = true
			};
					
			var switchRoomCategory = new UIMutableUserNotificationCategory {
				Identifier = SwitchRoomCategory
			};
			switchRoomCategory.SetActions (new UIUserNotificationAction[] {
				lightsSwitchAction, lightsOnAction, lightsOffAction
			}, UIUserNotificationActionContext.Default);
			switchRoomCategory.SetActions (new UIUserNotificationAction[] {
				lightsSwitchAction, lightsOnAction, lightsOffAction
			}, UIUserNotificationActionContext.Minimal);

			var enterRoomCategory = new UIMutableUserNotificationCategory {
				Identifier = EnterRoomCategory
			};
			enterRoomCategory.SetActions (new UIUserNotificationAction[] { lightsOnAction }, UIUserNotificationActionContext.Default);
			enterRoomCategory.SetActions (new UIUserNotificationAction[] { lightsOnAction }, UIUserNotificationActionContext.Minimal);

			var leftRoomCategory = new UIMutableUserNotificationCategory {
				Identifier = LeftRoomCategory
			};
			leftRoomCategory.SetActions (new UIUserNotificationAction[] { lightsOffAction }, UIUserNotificationActionContext.Default);
			leftRoomCategory.SetActions (new UIUserNotificationAction[] { lightsOffAction }, UIUserNotificationActionContext.Minimal);

			var categories = new NSSet (switchRoomCategory, enterRoomCategory, leftRoomCategory);
			var settings = UIUserNotificationSettings.GetSettingsForTypes (UIUserNotificationType.Alert | UIUserNotificationType.Badge | UIUserNotificationType.Sound, categories);
			application.RegisterUserNotificationSettings (settings);
		}
Example #10
0
        public static void ConnectRCIM(UIApplication application, string appkey, string token)
        {
            if (_isIniting || _isInited)
                return;

            _isIniting = true;
            RCIM.SharedRCIM.InitWithAppKey(appkey);
            RCIM.SharedRCIM.ReceiveMessageDelegate = new IMRMDelegate();
            RCIM.SharedRCIM.UserInfoDataSource = new ChatUserDataSource();
            if (application.IsRegisteredForRemoteNotifications)
            {
                var setting = UIUserNotificationSettings.GetSettingsForTypes(UIUserNotificationType.Alert | UIUserNotificationType.Badge | UIUserNotificationType.Sound, null);
                application.RegisterUserNotificationSettings(setting);
            }
            else
            {
                var myTypes = UIRemoteNotificationType.Alert | UIRemoteNotificationType.Badge | UIRemoteNotificationType.Sound;
                application.RegisterForRemoteNotificationTypes(myTypes);
            }

            RCIM.SharedRCIM.ConnectWithToken(token,
                success =>
                {

                    System.Console.WriteLine("Connect RCIM Success");
                    _isInited = true;
                    _isIniting = false;
                },
                err =>
                {
                    _isIniting = false;

                    System.Console.WriteLine("Connect RCIM Error : " + err.ToString());
                },
                () =>
                {
                    _isIniting = false; 
                    System.Console.WriteLine("Connect RCIM Error : Auth Token Fail");
                });
        }
Example #11
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);
        }