예제 #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 launchOptions)
        {
            global::Xamarin.Forms.Forms.Init();

            // define useragent android like
            string userAgent = "Mozilla/5.0 (Linux; Android 5.1.1; Nexus 5 Build/LMY48B; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/43.0.2357.65 Mobile Safari/537.36";

            // set default useragent
            NSDictionary dictionary = NSDictionary.FromObjectAndKey(NSObject.FromObject(userAgent), NSObject.FromObject("UserAgent"));

            NSUserDefaults.StandardUserDefaults.RegisterDefaults(dictionary);

            // On IOS:

            /* var account = AccountStore.Create().FindAccountsForService("Facebook").FirstOrDefault();
             * if (account != null)
             *   App.IsLoggedIn = true;*/

            // Get Shared User Defaults
            var plist = NSUserDefaults.StandardUserDefaults;
            // Get value
            var useHeader = plist.StringForKey("PrefName");

            if (!String.IsNullOrEmpty(useHeader))
            {
                App.IsLoggedIn = true;
            }


            // Register for push notifications.
            var settings = UIUserNotificationSettings.GetSettingsForTypes
                               (UIUserNotificationType.Alert | UIUserNotificationType.Badge | UIUserNotificationType.Sound, new NSSet());

            UIApplication.SharedApplication.RegisterUserNotificationSettings(settings);
            UIApplication.SharedApplication.RegisterForRemoteNotifications();

            //

            App.Init((IAuthenticate)this);


            App.ScreenWidth  = (int)UIScreen.MainScreen.Bounds.Width * 4;
            App.ScreenHeight = (int)UIScreen.MainScreen.Bounds.Height * 2;
            App.ScreenDPI    = 600;

            // 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));

                        var window = UIApplication.SharedApplication.KeyWindow;
                        window.RootViewController.PresentViewController(okayAlertController, true, null);

                        // reset our badge
                        UIApplication.SharedApplication.ApplicationIconBadgeNumber = 0;
                    }
                }
            }

            if (UIDevice.CurrentDevice.CheckSystemVersion(10, 0))
            {
                // Ask the user for permission to get notifications on iOS 10.0+
                UNUserNotificationCenter.Current.RequestAuthorization(
                    UNAuthorizationOptions.Alert | UNAuthorizationOptions.Badge | UNAuthorizationOptions.Sound,
                    (approved, error) => { });

                // Watch for notifications while app is active
                UNUserNotificationCenter.Current.Delegate = new UserNotificationCenterDelegate();
            }
            else if (UIDevice.CurrentDevice.CheckSystemVersion(8, 0))
            {
                // Ask the user for permission to get notifications on iOS 8.0+
                var settingss = UIUserNotificationSettings.GetSettingsForTypes(
                    UIUserNotificationType.Alert | UIUserNotificationType.Badge | UIUserNotificationType.Sound,
                    new NSSet());

                UIApplication.SharedApplication.RegisterUserNotificationSettings(settingss);
            }

            LoadApplication(new App());

            WireUpLongRunningTask();



            return(base.FinishedLaunching(app, launchOptions));
        }
		public virtual void DidRegisterUserNotificationSettings (UIApplication application, UIUserNotificationSettings notificationSettings)
		{
			SystemLogger.Log ("DidRegisterUserNotificationSettings event received. Override this method if you need to handle this event in the Appverse module");
		}
예제 #3
0
        public void RegisterUserForNotifications()
        {
            var notificationTypes = UIUserNotificationSettings.GetSettingsForTypes(UIUserNotificationType.Alert | UIUserNotificationType.Sound, null);

            UIApplication.SharedApplication.RegisterUserNotificationSettings(notificationTypes);
        }
        /// <summary>
        /// Finisheds the launching.
        /// </summary>
        /// <returns><c>true</c>, if launching was finisheded, <c>false</c> otherwise.</returns>
        /// <param name="application">Application.</param>
        /// <param name="launchOptions">Launch options.</param>
        public override bool FinishedLaunching(UIApplication application, NSDictionary launchOptions)
        {
            // Monitor token generation
            InstanceId.Notifications.ObserveTokenRefresh(TokenRefreshNotification);

            // Register your app for remote notifications.
            if (UIDevice.CurrentDevice.CheckSystemVersion(10, 0))
            {
                // iOS 10 or later
                var authOptions = UNAuthorizationOptions.Alert | UNAuthorizationOptions.Badge | UNAuthorizationOptions.Sound;
                UNUserNotificationCenter.Current.RequestAuthorization(authOptions, (granted, error) =>
                {
                    Console.WriteLine(granted);
                });

                // For iOS 10 display notification (sent via APNS)
                UNUserNotificationCenter.Current.Delegate = this;

                // For iOS 10 data message (sent via FCM)
                Messaging.SharedInstance.RemoteMessageDelegate = this;
            }
            else
            {
                // iOS 9 or before
                var allNotificationTypes = UIUserNotificationType.Alert | UIUserNotificationType.Badge | UIUserNotificationType.Sound;
                var settings             = UIUserNotificationSettings.GetSettingsForTypes(allNotificationTypes, null);
                UIApplication.SharedApplication.RegisterUserNotificationSettings(settings);
            }

            UIApplication.SharedApplication.RegisterForRemoteNotifications();

            App.Configure();

            // database initialisation
            Database.DefaultInstance.PersistenceEnabled = true;
            RootNode = Database.DefaultInstance.GetRootReference();

            //#if ENABLE_TEST_CLOUD
            //Xamarin.Calabash.Start();
            //#endif

            //MobileCenter.Start("34d7d8ca-c1f9-4099-b41c-da723fb37bf6",
            //typeof(Analytics), typeof(Crashes));

            // hockey app
            //var manager = BITHockeyManager.SharedHockeyManager;
            //manager.Configure("com.flusharcade.ReactiveUIAroundMe");
            //manager.StartManager();
            //manager.Authenticator.AuthenticateInstallation(); // This line is obsolete in crash only builds

            RxApp.SuspensionHost.SetupDefaultSuspendResume();

            _suspendHelper = new AutoSuspendHelper(this);
            _suspendHelper.FinishedLaunching(application, launchOptions);

            UIApplication.SharedApplication.SetStatusBarStyle(UIStatusBarStyle.LightContent, false);

            var bootstrapper = RxApp.SuspensionHost.GetAppState <AppBootstrapper>();

            _window = new UIWindow(UIScreen.MainScreen.Bounds);
            //_window.RootViewController = new SplitViewController(bootstrapper.CreateFlyoutMenu(),
            //                                                     bootstrapper.CreateRouteHost());

            _window.RootViewController = bootstrapper.CreateRouteHost();
            _window.MakeKeyAndVisible();

            return(true);
        }
예제 #5
0
        public override bool FinishedLaunching(UIApplication app, NSDictionary options)
        {
            if (UIDevice.CurrentDevice.CheckSystemVersion(10, 0))
            {
                // Ask the user for permission to get notifications on iOS 10.0+
                UNUserNotificationCenter.Current.RequestAuthorization(
                    UNAuthorizationOptions.Alert | UNAuthorizationOptions.Badge | UNAuthorizationOptions.Sound,
                    (approved, error) => { });

                // Watch for notifications while app is active
                UNUserNotificationCenter.Current.Delegate = new UserNotificationCenterDelegate();
            }
            else if (UIDevice.CurrentDevice.CheckSystemVersion(8, 0))
            {
                // Ask the user for permission to get notifications on iOS 8.0+
                var settings = UIUserNotificationSettings.GetSettingsForTypes(
                    UIUserNotificationType.Alert | UIUserNotificationType.Badge | UIUserNotificationType.Sound,
                    new NSSet());

                UIApplication.SharedApplication.RegisterUserNotificationSettings(settings);
            }

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

            LoadApplication(new App());

            return base.FinishedLaunching(app, options);
        }
        public static async Task Initialize(NSDictionary options, bool autoRegistration = true)
        {
            CrossFirebasePushNotification.Current.NotificationHandler = CrossFirebasePushNotification.Current.NotificationHandler ?? new DefaultPushNotificationHandler();

            TaskCompletionSource <bool> permisionTask = new TaskCompletionSource <bool>();

            // Register your app for remote notifications.
            if (UIDevice.CurrentDevice.CheckSystemVersion(10, 0))
            {
                // iOS 10 or later
                var authOptions = UNAuthorizationOptions.Alert | UNAuthorizationOptions.Badge | UNAuthorizationOptions.Sound;
                UNUserNotificationCenter.Current.RequestAuthorization(authOptions, (granted, error) =>
                {
                    if (error != null)
                    {
                        _onNotificationError?.Invoke(CrossFirebasePushNotification.Current, new FirebasePushNotificationErrorEventArgs(error.Description));
                    }
                    else
                    {
                        System.Diagnostics.Debug.WriteLine(granted);
                    }

                    permisionTask.SetResult(granted);
                });

                // For iOS 10 display notification (sent via APNS)
                UNUserNotificationCenter.Current.Delegate = CrossFirebasePushNotification.Current as IUNUserNotificationCenterDelegate;

                // For iOS 10 data message (sent via FCM)
                Messaging.SharedInstance.Delegate = CrossFirebasePushNotification.Current as IMessagingDelegate;
            }
            else
            {
                // iOS 9 or before
                var allNotificationTypes = UIUserNotificationType.Alert | UIUserNotificationType.Badge | UIUserNotificationType.Sound;
                var settings             = UIUserNotificationSettings.GetSettingsForTypes(allNotificationTypes, null);
                UIApplication.SharedApplication.RegisterUserNotificationSettings(settings);
                permisionTask.SetResult(true);
            }



            /*if (options != null && options.Keys != null && options.Keys.Count() != 0 && options.ContainsKey(new NSString("UIApplicationLaunchOptionsRemoteNotificationKey")))
             * {
             *  NSDictionary data = options.ObjectForKey(new NSString("UIApplicationLaunchOptionsRemoteNotificationKey")) as NSDictionary;
             *
             *  // CrossFirebasePushNotification.Current.OnNotificationOpened(GetParameters(data));
             *
             * }*/
            var permissonGranted = await permisionTask.Task;

            if (!permissonGranted)
            {
                _onNotificationError?.Invoke(CrossFirebasePushNotification.Current, new FirebasePushNotificationErrorEventArgs("Push notification permission not granted"));
            }


            App.Configure();

            if (autoRegistration)
            {
                UIApplication.SharedApplication.RegisterForRemoteNotifications();
            }
        }
예제 #7
0
        public override bool FinishedLaunching(UIApplication application, NSDictionary launchOptions)
        {
            // Override point for customization after application launch.
            // If not required for your application you can safely delete this method

            // Code to start the Xamarin Test Cloud Agent
                        #if ENABLE_TEST_CLOUD
            Xamarin.Calabash.Start();
                        #endif

            // 需要使用者授權,才能發出 Notification
            if (UIDevice.CurrentDevice.CheckSystemVersion(8, 0))
            {
                var notificationSettings =
                    UIUserNotificationSettings.GetSettingsForTypes(
                        UIUserNotificationType.Alert |
                        UIUserNotificationType.Badge |
                        UIUserNotificationType.Sound, null);

                application.RegisterUserNotificationSettings(notificationSettings);

                UIApplication.SharedApplication.RegisterForRemoteNotifications();
            }



            if (launchOptions != null)
            {
                // 如果是因為 Local Notification 啟動 App
                if (launchOptions.ContainsKey(UIApplication.LaunchOptionsLocalNotificationKey))
                {
                    var localNotification = launchOptions[UIApplication.LaunchOptionsLocalNotificationKey] as UILocalNotification;
                    if (localNotification != null)
                    {
                        //
                        Debug.WriteLine("Start with Local Notification");

                        UIApplication.SharedApplication.ApplicationIconBadgeNumber = 0;
                    }
                }

                if (launchOptions.ContainsKey(UIApplication.LaunchOptionsRemoteNotificationKey))
                {
                    NSDictionary remoteNotification = launchOptions[UIApplication.LaunchOptionsRemoteNotificationKey] as NSDictionary;
                    if (remoteNotification != null)
                    {
                    }

                    UIApplication.SharedApplication.ApplicationIconBadgeNumber = 0;
                }
            }

            //
            NSError configureError;
            Context.SharedInstance.Configure(out configureError);
            if (configureError != null)
            {
                Console.WriteLine("Error configuring the Google context: {0}", configureError);
                SignIn.SharedInstance.ClientID = clientId;
            }

            return(true);
        }
예제 #8
0
		public override void DidRegisterUserNotificationSettings (UIApplication application, UIUserNotificationSettings notificationSettings)
		{
			// Use notificationSettings.Types to test for allowed types

		}
        async partial void LoginClick(UIButton sender)
        {
            if (LoginButton.Title(UIControlState.Normal) == "Logout")
            {
                NSUserDefaults.StandardUserDefaults.RemoveObject("CrmUserId");
                LoginButton.SetTitle("Login To CRM", UIControlState.Normal);
                Output("Cleared CRM user id");
                return;
            }

            if (string.IsNullOrEmpty(CrmUrl.Text) || string.IsNullOrEmpty(CrmUsername.Text) ||
                string.IsNullOrEmpty(CrmPassword.Text))
            {
                return;
            }

            string url = CrmUrl.Text;

            if (!url.EndsWith("/"))
            {
                url += "/";
            }

            CrmAuthenticationHeader authHeader = null;
            CrmAuth auth = new CrmAuth();

            authHeader = url.Contains("dynamics.com") ?
                         auth.GetHeaderOnline(CrmUsername.Text, CrmPassword.Text, url) :
                         auth.GetHeaderOnPremise(CrmUsername.Text, CrmPassword.Text, url);

            if (authHeader == null)
            {
                Output("Unable to connect to CRM");
                return;
            }

            string userid = CrmWhoAmI(authHeader, url);

            if (string.IsNullOrEmpty(userid))
            {
                Output("Unable to retrieve user info from CRM");
                return;
            }

            //Save the userid
            NSUserDefaults.StandardUserDefaults.SetString(userid, "CrmUserId");

            //Register for notifications
            //Moved from AppDelegate.cs - FinishedLaunching
            var settings = UIUserNotificationSettings.GetSettingsForTypes(
                UIUserNotificationType.Alert
                | UIUserNotificationType.Badge
                | UIUserNotificationType.Sound,
                new NSSet());

            UIApplication.SharedApplication.RegisterUserNotificationSettings(settings);
            UIApplication.SharedApplication.RegisterForRemoteNotifications();

            LoginButton.SetTitle("Logout", UIControlState.Normal);
            Output("Retrieved CRM user id");
        }
예제 #10
0
        // class-level declarations

        private static void RegisterNotifications()
        {
            var settings = UIUserNotificationSettings.GetSettingsForTypes(UIUserNotificationType.Alert | UIUserNotificationType.Sound, new NSSet());

            UIApplication.SharedApplication.RegisterUserNotificationSettings(settings);
        }
예제 #11
0
        public override bool FinishedLaunching(UIApplication app, NSDictionary options)
        {
            XfxControls.Init();
            ButtonCircle.FormsPlugin.iOS.ButtonCircleRenderer.Init();

            UINavigationBar.Appearance.TintColor = Color.White.ToUIColor();

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

            Firebase.Core.App.Configure();

            KeyboardOverlapRenderer.Init();

            DependencyService.Register <ToastNotification>(); // Register your dependency
            ToastNotification.Init();

            FFImageLoading.Forms.Touch.CachedImageRenderer.Init();

            var ignore = new CircleTransformation();

            //CarouselViewRenderer.Init();

            DependencyService.Register <IGoogleManager, GoogleManager>();
            DependencyService.Register <IFacebookManager, FacebookManager>();

            var googleServiceDictionary = NSDictionary.FromFile("GoogleService-Info.plist");

            SignIn.SharedInstance.ClientID = googleServiceDictionary["CLIENT_ID"].ToString();

            FormsMaps.Init();
            Rg.Plugins.Popup.Popup.Init();

            LoadApplication(new App());

            //var statusBar = UIApplication.SharedApplication.ValueForKey(new NSString("statusBar")) as UIView;
            //if (statusBar.RespondsToSelector(new ObjCRuntime.Selector("setBackgroundColor:")))
            //{
            //    statusBar.BackgroundColor = UIColor.White;
            //    statusBar.TintColor = UIColor.White;
            //}

            ImageCircle.Forms.Plugin.iOS.ImageCircleRenderer.Init();

            //FirebasePushNotificationManager.Initialize(options, new NotificationUserCategory[]
            //{
            //    new NotificationUserCategory("message",new List<NotificationUserAction> {
            //        new NotificationUserAction("Reply","Reply",NotificationActionType.Foreground)
            //    }),
            //    new NotificationUserCategory("request",new List<NotificationUserAction> {
            //        new NotificationUserAction("Accept","Accept"),
            //        new NotificationUserAction("Reject","Reject",NotificationActionType.Destructive)
            //    })

            //});

            // Register your app for remote notifications.
            if (UIDevice.CurrentDevice.CheckSystemVersion(10, 0))
            {
                // iOS 10 or later
                var authOptions = UNAuthorizationOptions.Alert | UNAuthorizationOptions.Badge | UNAuthorizationOptions.Sound;
                UNUserNotificationCenter.Current.RequestAuthorization(authOptions, (granted, error) => {
                    Console.WriteLine(granted);
                });

                // For iOS 10 display notification (sent via APNS)
                UNUserNotificationCenter.Current.Delegate = this;

                // For iOS 10 data message (sent via FCM)

                Messaging.SharedInstance.RemoteMessageDelegate = this;
            }
            else
            {
                // iOS 9 or before
                var allNotificationTypes = UIUserNotificationType.Alert | UIUserNotificationType.Badge | UIUserNotificationType.Sound;
                var settings             = UIUserNotificationSettings.GetSettingsForTypes(allNotificationTypes, null);
                UIApplication.SharedApplication.RegisterUserNotificationSettings(settings);
            }

            UIApplication.SharedApplication.RegisterForRemoteNotifications();

            return(base.FinishedLaunching(app, options));
        }
예제 #12
0
 public void DidRegisterUserNotificationSettings(UIApplication application, UIUserNotificationSettings notificationSettings)
 {
     //application.RegisteredForRemoteNotifications (application);
     application.RegisterForRemoteNotifications();
 }
예제 #13
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

#if !ENABLE_TEST_CLOUD
            var notificationSettings = UIUserNotificationSettings.GetSettingsForTypes(UIUserNotificationType.Alert | UIUserNotificationType.Badge | UIUserNotificationType.Sound, null);
            UIApplication.SharedApplication.RegisterUserNotificationSettings(notificationSettings);
            UIApplication.SharedApplication.RegisterForRemoteNotifications();
#endif

            ShowHelpIfNecessary(TutorialHelper.Welcome, () =>
            {
                ShowHelpIfNecessary(TutorialHelper.FindFavorites);
            });

            SlideOutMenuController               = Storyboard.InstantiateViewController <MenuViewController> ();
            SlideOutMenuController.View.Frame    = new CGRect(-UIScreen.MainScreen.Bounds.Width, 0, UIScreen.MainScreen.Bounds.Width - 60, UIScreen.MainScreen.Bounds.Height);
            SlideOutMenuController.MenuItemClick = MenuItemClicked;
            View.Add(SlideOutMenuController.View);
            AddChildViewController(SlideOutMenuController);

            homeController = Storyboard.InstantiateViewController <HomeViewController> ();
            AddChildViewController(homeController);
            vwContent.Add(homeController.View);
            homeController.View.AddMatchParentSizeConstraints();
            //MenuItemClicked (5);
            bool touchStartAccepted    = false;
            UIPanGestureRecognizer pan = new UIPanGestureRecognizer((gesture) =>
            {
                if (gesture.State == UIGestureRecognizerState.Began)
                {
                    View.EndEditing(true);
                    var location = gesture.LocationInView(View);
                    if ((location.X < 35 && !IsMenuOpen) || IsMenuOpen)
                    {
                        touchStartAccepted = true;
                    }
                    else
                    {
                        touchStartAccepted = false;
                    }
                }
                else if (gesture.State == UIGestureRecognizerState.Changed)
                {
                    if (touchStartAccepted)
                    {
                        UIView.Animate(.1f, () =>
                        {
                            var f = SlideOutMenuController.View.Frame;
                            f.X   = (nfloat)Math.Min(gesture.LocationInView(View).X - f.Width, 0);
                            SlideOutMenuController.View.Frame = f;
                            vwDarkenView.Alpha = (nfloat)Math.Min(Math.Abs(gesture.LocationInView(View).X) / UIScreen.MainScreen.Bounds.Width, 0.75);
                        });
                    }
                }
                else if (gesture.State == UIGestureRecognizerState.Ended)
                {
                    if (touchStartAccepted)
                    {
                        var velocity = gesture.VelocityInView(View);
                        if (velocity.X < 0)
                        {
                            AnimateMenuClosed();
                        }
                        else
                        {
                            AnimateMenuOpen();
                        }
                    }
                }
            })
            {
                CancelsTouchesInView = false
            };
            pan.ShouldRecognizeSimultaneously = new UIGesturesProbe((gestureRecognizer, otherGestureRecognizer) =>
            {
                if (otherGestureRecognizer is UITapGestureRecognizer)
                {
                    return(false);
                }

                if (otherGestureRecognizer is UIPanGestureRecognizer)
                {
                    var other = otherGestureRecognizer as UIPanGestureRecognizer;
                    if (other.View == SlideOutMenuController.GetMenu())
                    {
                        return(false);
                    }
                }

                return(true);
            });

            View.AddGestureRecognizer(pan);

            vwDarkenView.AddGestureRecognizer(new UITapGestureRecognizer((gesture) =>
            {
                AnimateMenuClosed();
            }));

            var user = CrossSettings.Current.GetValueOrDefaultJson <User>("User");
            InvokeOnMainThread(() =>
            {
                CrossPushNotifications.Current.Register(new string[] { user.Id });
            });

            if (AppDelegate.ClickedNotification != null)
            {
                Navigator.HandleNotificationTap(NavigationController, AppDelegate.ClickedNotification.MetaData, AppDelegate.ClickedNotification.Title, AppDelegate.ClickedNotification.Message);
                AppDelegate.ClickedNotification = null;
            }
        }
		public override void DidRegisterUserNotificationSettings (UIApplication application, UIUserNotificationSettings notificationSettings)
		{ 
			//application.RegisteredForRemoteNotifications (application);
			SystemLogger.Log (SystemLogger.Module.PLATFORM, "DidRegisterUserNotificationSettings from AppDelegate..."); 
			application.RegisterForRemoteNotifications (); 
		}
예제 #15
0
 public override void DidRegisterUserNotificationSettings(UIApplication application,
     UIUserNotificationSettings notificationSettings)
 {
     // without this RegisteredForRemoteNotifications doesn't fire on iOS 8!
     //application.RegisterForRemoteNotifications();
 }
예제 #16
0
        public override bool FinishedLaunching(UIApplication application, NSDictionary launchOptions)
        {
            // Registration of the navigation
            var navigation = new SeekiosApp.Services.NavigationService();

            navigation.Initialize((UINavigationController)Window.RootViewController);
            navigation.Configure(App.LOGIN_PAGE, "LoginView");
            navigation.Configure(App.NEED_UPDATE_PAGE, "NeedUpdateView");
            navigation.Configure(App.LIST_SEEKIOS_PAGE, "ListSeekiosView");
            navigation.Configure(App.DETAIL_SEEKIOS_PAGE, "DetailSeekiosView");
            navigation.Configure(App.MAP_PAGE, "MapView");
            navigation.Configure(App.MAP_HISTORIC_PAGE, "MapHistoricView");
            navigation.Configure(App.MODE_ZONE_PAGE, "ModeZoneFirstView");
            navigation.Configure(App.MODE_ZONE_2_PAGE, "ModeZoneThirdView");
            navigation.Configure(App.MODE_ZONE_3_PAGE, "ModeZoneSecondView");
            navigation.Configure(App.MODE_DONT_MOVE_PAGE, "ModeDontMoveFirstView");
            navigation.Configure(App.MODE_DONT_MOVE_2_PAGE, "ModeDontMoveSecondView");
            navigation.Configure(App.MODE_TRACKING_PAGE, "ModeTrackingView");
            navigation.Configure(App.ALERT_PAGE, "AlertView");
            navigation.Configure(App.ALERT_SOS_PAGE, "AlertSOSView");
            navigation.Configure(App.PARAMETER_PAGE, "ParameterUserView");
            navigation.Configure(App.ABOUT_PAGE, "AboutView");
            navigation.Configure(App.ADD_SEEKIOS_PAGE, "AddSeekiosView");
            navigation.Configure(App.MAP_ALL_SEEKIOS_PAGE, "MapAllSeekiosView");
            navigation.Configure(App.RELOAD_CREDIT_PAGE, "RechargeCreditsView");
            navigation.Configure(App.TRANSACTION_HISTORIC_PAGE, "TransactionHistoricView");
            navigation.Configure(App.LIST_TUTORIAL_PAGE, "ListTutorialView");
            navigation.Configure(App.TUTORIAL_BACKGROUND_FIRST_LAUNCH_PAGE, "TutorialBackgroundView");
            navigation.Configure(App.TUTORIAL_POWERSAVING_PAGE, "TutorialPowerSavingView");
            navigation.Configure(App.TUTORIAL_CREDITCOST_PAGE, "TutorialCreditCostView");
            navigation.Configure(App.TUTORIAL_SEEKIOS_LED_PAGE, "TutorialSeekiosLedView");

            // Registration of the others services
            SimpleIoc.Default.Reset();
            //ServiceLocator.SetLocatorProvider(new ServiceLocatorProvider());
            ServiceLocator.SetLocatorProvider(() => SimpleIoc.Default);
            SimpleIoc.Default.Register <INavigationService>(() => navigation);
            SimpleIoc.Default.Register <ISaveDataService, SaveDataService>();
            SimpleIoc.Default.Register <Interfaces.IDialogService, Seekios.iOS.Services.DialogService>();
            SimpleIoc.Default.Register <IDispatchOnUIThread, DispatchService>();
            SimpleIoc.Default.Register <IMapControlManager, ControlManager.MapControlManager>();
            SimpleIoc.Default.Register <ITimer, Services.Timer>();
            SimpleIoc.Default.Register <ILocalNotificationService, LocalNotificationService>();
            ViewModel.ViewModelLocator.Initialize();

            // MVVM Light's DispatcherHelper for cross-thread handling.
            DispatcherHelper.Initialize(application);

            // Setup the application version
            App.Locator.Login.VersionApplication = NSBundle.MainBundle.InfoDictionary["CFBundleVersion"].ToString();

            // Initialize HockeyApp
            var hockeyApp = BITHockeyManager.SharedHockeyManager;

            hockeyApp.Configure("ba744679c8894526b78271606dbae95e", new HockeyAppCrashDelegate());
            hockeyApp.DisableMetricsManager           = true;
            hockeyApp.CrashManager.CrashManagerStatus = BITCrashManagerStatus.AutoSend;
            hockeyApp.StartManager();

            // Set up the style of all the navigation bars in your application
            UINavigationBar.Appearance.BarTintColor = UIColor.FromRGB(98, 218, 115);
            UINavigationBar.Appearance.TintColor    = UIColor.White;
            UIApplication.SharedApplication.SetStatusBarStyle(UIStatusBarStyle.LightContent, false);

            // Subscribe to notification
            if (UIDevice.CurrentDevice.CheckSystemVersion(8, 0))
            {
                var pushSettings = UIUserNotificationSettings.GetSettingsForTypes(UIUserNotificationType.Alert | UIUserNotificationType.Badge | UIUserNotificationType.Sound, new NSSet());
                UIApplication.SharedApplication.RegisterUserNotificationSettings(pushSettings);
                UIApplication.SharedApplication.RegisterForRemoteNotifications();
            }
            else
            {
                UIApplication.SharedApplication.RegisterForRemoteNotificationTypes(UIRemoteNotificationType.Alert | UIRemoteNotificationType.Badge | UIRemoteNotificationType.Sound);
            }

            // Set up in app purchases
            InitializeInAppPurchases();
            var controller = new PackView();

            controller.AttachToPurchaseManager(null, PurchaseManager);

            return(true);
        }
예제 #17
0
        public override bool FinishedLaunching(UIApplication application, NSDictionary launchOptions)
        {
            // Override point for customization after application launch.
            // If not required for your application you can safely delete this method
            Window = new UIWindow(UIScreen.MainScreen.Bounds);

            // set our root view controller with the sidebar menu as the apps root view controller
            Window.RootViewController = new RootViewController();

            Window.MakeKeyAndVisible();

            #region Check for a Notification

            // check for a notification
            if (launchOptions != null)
            {
                // check for a local notification
                if (launchOptions.ContainsKey(UIApplication.LaunchOptionsLocalNotificationKey))
                {
                    UILocalNotification localNotification = launchOptions[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 (launchOptions.ContainsKey(UIApplication.LaunchOptionsRemoteNotificationKey))
                {
                    NSDictionary remoteNotification = launchOptions[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
                    );

                application.RegisterUserNotificationSettings(notificationSettings);
                application.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);
            }

            var googleServiceDictionary = NSDictionary.FromFile("GoogleService-Info.plist");
            SignIn.SharedInstance.ClientID = googleServiceDictionary["CLIENT_ID"].ToString();
            #endregion

            //Profile.EnableUpdatesOnAccessTokenChange(true);
            //Settings.AppID = appId;
            //Settings.DisplayName = appName;
            //return ApplicationDelegate.SharedInstance.FinishedLaunching(application, launchOptions);
            return(true);
        }
        public static async Task Initialize(NSDictionary options, bool autoRegistration = true)
        {
            CrossFirebasePushNotification.Current.NotificationHandler = CrossFirebasePushNotification.Current.NotificationHandler ?? new DefaultPushNotificationHandler();

            TaskCompletionSource <bool> permisionTask = new TaskCompletionSource <bool>();

            // Register your app for remote notifications.
            if (UIDevice.CurrentDevice.CheckSystemVersion(10, 0))
            {
                // iOS 10 or later
                var authOptions = UNAuthorizationOptions.Alert | UNAuthorizationOptions.Badge | UNAuthorizationOptions.Sound;
                UNUserNotificationCenter.Current.RequestAuthorization(authOptions, (granted, error) =>
                {
                    if (error != null)
                    {
                        _onNotificationError?.Invoke(CrossFirebasePushNotification.Current, new FirebasePushNotificationErrorEventArgs(error.Description));
                    }
                    else
                    {
                        System.Diagnostics.Debug.WriteLine(granted);
                    }

                    permisionTask.SetResult(granted);
                });

                // For iOS 10 display notification (sent via APNS)
                UNUserNotificationCenter.Current.Delegate = CrossFirebasePushNotification.Current as IUNUserNotificationCenterDelegate;

                // For iOS 10 data message (sent via FCM)
                Messaging.SharedInstance.RemoteMessageDelegate = CrossFirebasePushNotification.Current as IMessagingDelegate;
            }
            else
            {
                // iOS 9 or before
                var allNotificationTypes = UIUserNotificationType.Alert | UIUserNotificationType.Badge | UIUserNotificationType.Sound;
                var settings             = UIUserNotificationSettings.GetSettingsForTypes(allNotificationTypes, null);
                UIApplication.SharedApplication.RegisterUserNotificationSettings(settings);
                permisionTask.SetResult(true);
            }



            /*if (options != null && options.Keys != null && options.Keys.Count() != 0 && options.ContainsKey(new NSString("UIApplicationLaunchOptionsRemoteNotificationKey")))
             * {
             *  NSDictionary data = options.ObjectForKey(new NSString("UIApplicationLaunchOptionsRemoteNotificationKey")) as NSDictionary;
             *
             *  // CrossFirebasePushNotification.Current.OnNotificationOpened(GetParameters(data));
             *
             * }*/
            var permissonGranted = await permisionTask.Task;

            if (!permissonGranted)
            {
                _onNotificationError?.Invoke(CrossFirebasePushNotification.Current, new FirebasePushNotificationErrorEventArgs("Push notification permission not granted"));
            }


            App.Configure();

            // Monitor token generation
            InstanceId.Notifications.ObserveTokenRefresh((sender, e) =>
            {
                // Note that this callback will be fired everytime a new token is generated, including the first
                // time. So if you need to retrieve the token as soon as it is available this is where that
                // should be done.
                var refreshedToken = InstanceId.SharedInstance.Token;
                if (!string.IsNullOrEmpty(refreshedToken))
                {
                    _onTokenRefresh?.Invoke(CrossFirebasePushNotification.Current, new FirebasePushNotificationTokenEventArgs(refreshedToken));
                    Connect();
                }
            });

            if (autoRegistration)
            {
                UIApplication.SharedApplication.RegisterForRemoteNotifications();
            }
        }
		/// <summary>
		/// Dids the register user notification settings.
		/// </summary>
		/// <param name="application">Application.</param>
		/// <param name="notificationSettings">Notification settings.</param>
		public void DidRegisterUserNotificationSettings (UIApplication application, UIUserNotificationSettings notificationSettings)
		{ 	
			#if DEBUG
			log("DidRegisterUserNotificationSettings");
			#endif

			// send event to registered weak delegates
			var wDelegatesEnumerator = weakDelegates.GetEnumerator ();
			while (wDelegatesEnumerator.MoveNext())
			{
				IWeakDelegateManager weakDelegate = wDelegatesEnumerator.Current.Value;
				weakDelegate.DidRegisterUserNotificationSettings (application, notificationSettings);
			}
		}
예제 #20
0
        public override bool FinishedLaunching(UIApplication application, NSDictionary launchOptions)
        {
            // Override point for customization after application launch.
            // If not required for your application you can safely delete this method
            Window = new UIWindow(UIScreen.MainScreen.Bounds);
            Window.BackgroundColor = UIColor.GroupTableViewBackgroundColor;

            #region 极光推送注册
            MsgBoxHelper.Initialize(this);
            if (float.Parse(UIDevice.CurrentDevice.SystemVersion.Split('.')[0]) >= 10.0)
            {
                UNUserNotificationCenter center = UNUserNotificationCenter.Current;
                center.RequestAuthorization((UNAuthorizationOptions.CarPlay | UNAuthorizationOptions.Alert | UNAuthorizationOptions.Sound | UNAuthorizationOptions.Badge), (bool arg1, NSError arg2) =>
                {
                    if (arg1)
                    {
                        Console.WriteLine("ios 10 request notification success");
                    }
                    else
                    {
                        Console.WriteLine("IOS 10 request notification failed");
                    }
                });
            }
            else if (float.Parse(UIDevice.CurrentDevice.SystemVersion.Split('.')[0]) >= 8.0)
            {
                UIUserNotificationSettings notiSettings = UIUserNotificationSettings.GetSettingsForTypes(UIUserNotificationType.Badge | UIUserNotificationType.Sound | UIUserNotificationType.Alert, null);
                UIApplication.SharedApplication.RegisterUserNotificationSettings(notiSettings);
            }
            else
            {
                UIRemoteNotificationType myTypes = UIRemoteNotificationType.Alert | UIRemoteNotificationType.Sound | UIRemoteNotificationType.Badge;
                UIApplication.SharedApplication.RegisterForRemoteNotificationTypes(myTypes);
            }

            /*
             * JPUSHService.SetupWithOption(launchOptions, "466439cd8279089311ead639", "Publish channel", false);
             * 将上面代码中的应用程序码换成你在极光服务器上注册的应用码,通过极光服务器发送推送消息,在真机上测试即可收到。
             */
            JPUSHService.SetupWithOption(launchOptions, "466439cd8279089311ead639", "Publish channel", false);
            JPUSHService.SetDebugMode();
            UIApplication.SharedApplication.RegisterForRemoteNotifications();
            //JPUSHService.RegistrationIDCompletionHandler((int arg1, NSString arg2) =>
            //{
            //	if (arg1 == 0)
            //		Console.WriteLine(arg2);
            //});
            if (launchOptions != null)
            {
                NSDictionary remoteNotification = (NSDictionary)(launchOptions.ObjectForKey(UIApplication.LaunchOptionsRemoteNotificationKey));
                if (remoteNotification != null)
                {
                    Console.WriteLine(remoteNotification);
                    this.goToMessageViewControllerWith(remoteNotification);
                }
            }
            #endregion
            Window.RootViewController = new UINavigationController(new ViewController());
            // make the window visible
            Window.MakeKeyAndVisible();

            return(true);
        }
        async public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            try
            {
                if (string.IsNullOrEmpty(sUserAccountNumber))
                {
                    sUserAccountNumber = "0000";
                }

                ImagePersonalQRCode.Image = IosHelper.GetQrCode(sUserAccountNumber, 240, 240, 0);
                lblCustomerId.Text        = sUserAccountNumber;

                lblQRCodeBackground.Layer.CornerRadius  = 10f;
                lblQRCodeBackground.Layer.MasksToBounds = true;

                qrCodePlaceHolderBorder.Layer.CornerRadius  = 10f;
                qrCodePlaceHolderBorder.Layer.MasksToBounds = true;
                qrCodePlaceHolderBorder.Layer.BorderColor   = UIColor.White.CGColor;
                qrCodePlaceHolderBorder.Layer.BorderWidth   = 1f;

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

                    UIApplication.SharedApplication.RegisterUserNotificationSettings(pushSettings);
                    UIApplication.SharedApplication.RegisterForRemoteNotifications();
                }
                else
                {
                    UIRemoteNotificationType notificationTypes = UIRemoteNotificationType.Alert | UIRemoteNotificationType.Badge | UIRemoteNotificationType.Sound;
                    UIApplication.SharedApplication.RegisterForRemoteNotificationTypes(notificationTypes);
                }

                //string sAccessToken = Helpers.Settings.AccessToken;
                //string sUserEmail = Helpers.Settings.UserEmail;

                //if (!string.IsNullOrEmpty(sAccessToken) && !string.IsNullOrEmpty(sUserEmail))
                //{
                //    Joyces.Platform.AppContext.Instance.Platform.CustomerId = sUserEmail;

                //    var getCustomer = await RestAPI.GetCustomer(sUserEmail, sAccessToken);

                //    if (getCustomer != null && getCustomer is Customer)
                //    {
                //        Joyces.Platform.AppContext.Instance.Platform.CustomerList = (Customer)getCustomer;

                //        var resp = await RestAPI.GetOffer(sUserEmail, sAccessToken);

                //        if (resp != null && resp is List<Offer>)
                //            Joyces.Platform.AppContext.Instance.Platform.OfferList = (List<Offer>)resp;
                //        else
                //            Joyces.Platform.AppContext.Instance.Platform.OfferList = null;

                //        resp = await RestAPI.GetNews(sUserEmail, sAccessToken);

                //        if (resp != null && resp is List<Joyces.News>)
                //            Joyces.Platform.AppContext.Instance.Platform.NewsList = (List<Joyces.News>)resp;
                //        else
                //            Joyces.Platform.AppContext.Instance.Platform.NewsList = null;

                //        Joyces.Platform.AppContext.Instance.Platform.MoreList = await RestAPI.GetMore(sAccessToken);
                //    }
                //    else
                //    {
                //        Helpers.Settings.AccessToken = string.Empty;
                //        Helpers.Settings.UserEmail = string.Empty;

                //        var mainController = Storyboard.InstantiateViewController("loginNavigationController");
                //        UIApplication.SharedApplication.KeyWindow.RootViewController = mainController;
                //    }
                //}
                //else
                //{
                //    //Något är JÄÄÄVLIGT FEL, hit ska den absolut aldrig kunna komma!!!

                //    Helpers.Settings.AccessToken = string.Empty;
                //    Helpers.Settings.UserEmail = string.Empty;

                //    var mainController = Storyboard.InstantiateViewController("loginNavigationController");
                //    UIApplication.SharedApplication.KeyWindow.RootViewController = mainController;

                //    return;
                //}

                if (!string.IsNullOrEmpty(Joyces.Helpers.Settings.AccessToken))
                {
                    sendDeviceToken(Joyces.Helpers.Settings.AccessToken);
                }
            }
            catch (Exception ex)
            {
            }
        }
예제 #22
0
        public override void FinishedLaunching(UIApplication application)
        {
            application.RegisterForRemoteNotifications();


            if (UIDevice.CurrentDevice.UserInterfaceIdiom == UIUserInterfaceIdiom.Phone)
            {
                if (UIDevice.CurrentDevice.CheckSystemVersion(8, 0))
                {
                    //OS is up to date
                    var settings = UIUserNotificationSettings.GetSettingsForTypes(UIUserNotificationType.Alert & UIUserNotificationType.Sound, null);
                    UIApplication.SharedApplication.RegisterUserNotificationSettings(settings);

                    UILocalNotification batteryNotification = new UILocalNotification();

                    NSDate.FromObject(UIDevice.BatteryLevelDidChangeNotification);

                    batteryNotification.SoundName = UILocalNotification.DefaultSoundName;

                    UIApplication.SharedApplication.ScheduleLocalNotification(batteryNotification);
                    UIApplication.SharedApplication.StatusBarStyle = UIStatusBarStyle.BlackOpaque;

                    var memoryCache      = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
                    var filePathPassword = System.IO.Path.Combine(memoryCache, "password.txt");

                    try
                    {
                        if (filePathPassword == null)
                        {
                            throw new FileNotFoundException();
                        }
                        else
                        {
                            if (String.IsNullOrEmpty(File.ReadAllText(filePathPassword)) == true)
                            {
                                if (this.navMaster.VisibleViewController == this.passwordFirstControl)
                                {
                                    this.Window.RootViewController = this.passwordFirstControl;
                                    this.navMaster.PushViewController(this.passwordFirstControl, true);
                                }
                                else
                                {
                                    this.navMaster.PushViewController(this.passwordFirstControl, true);
                                }
                            }
                            else
                            {
                                if (this.navMaster.ViewControllers.Contains(this.password) == true)
                                {
                                    if (this.navMaster.VisibleViewController != this.password)
                                    {
                                        this.passwordLog.Text = "";
                                        this.passwordLog.ResignFirstResponder();
                                        this.navMaster.PopToViewController(this.password, true);
                                    }
                                    else
                                    {
                                        Console.WriteLine("Controller already exists");
                                    }
                                }
                                else
                                {
                                    this.navMaster.PushViewController(this.password, true);
                                }
                            }
                        }
                    }
                    catch (FileNotFoundException)
                    {
                        if (this.navMaster.VisibleViewController == this.passwordFirstControl)
                        {
                            this.Window.RootViewController = this.password;
                            this.navMaster.PushViewController(this.passwordFirstControl, true);
                        }
                        else
                        {
                            this.navMaster.PushViewController(this.passwordFirstControl, true);
                        }
                    }
                    //welcome the user when they launch the app for the first time on the device
                    //add a key to the OS
                    Console.WriteLine("Presented view controller" + this.navMaster.VisibleViewController);
                }
                else
                {
                    //OS is out of date
                }
            }

            else if (UIDevice.CurrentDevice.UserInterfaceIdiom == UIUserInterfaceIdiom.Pad)
            {
                if (UIDevice.CurrentDevice.CheckSystemVersion(8, 0))
                {
                    var settings = UIUserNotificationSettings.GetSettingsForTypes(UIUserNotificationType.Alert & UIUserNotificationType.Sound, null);
                    UIApplication.SharedApplication.RegisterUserNotificationSettings(settings);

                    //local notifications
                    UILocalNotification batteryNotification = new UILocalNotification();

                    NSDate.FromObject(UIDevice.BatteryLevelDidChangeNotification);

                    batteryNotification.SoundName = UILocalNotification.DefaultSoundName;

                    UIApplication.SharedApplication.ScheduleLocalNotification(batteryNotification);
                    UIApplication.SharedApplication.StatusBarStyle = UIStatusBarStyle.BlackOpaque;

                    var memoryCache      = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
                    var filePathPassword = System.IO.Path.Combine(memoryCache, "password.txt");

                    try
                    {
                        if (filePathPassword == null)
                        {
                            throw new FileNotFoundException();
                        }
                        else
                        {
                            if (String.IsNullOrEmpty(File.ReadAllText(filePathPassword)) == true)
                            {
                                if (this.navMaster.VisibleViewController == this.passwordFirstControl)
                                {
                                    this.Window.RootViewController = this.passwordFirstControl;
                                    this.navMaster.PushViewController(this.passwordFirstControl, true);
                                }
                                else
                                {
                                    this.navMaster.PushViewController(this.passwordFirstControl, true);
                                }
                            }
                            else
                            {
                                if (this.navMaster.ViewControllers.Contains(this.password) == true)
                                {
                                    if (this.navMaster.VisibleViewController != this.password)
                                    {
                                        this.passwordLog.Text = "";
                                        this.passwordLog.ResignFirstResponder();
                                        this.navMaster.PopToViewController(this.password, true);
                                    }
                                    else
                                    {
                                        Console.WriteLine("Controller already exists");
                                    }
                                }
                                else
                                {
                                    this.navMaster.PushViewController(this.password, true);
                                }
                            }
                        }
                    }
                    catch (FileNotFoundException)
                    {
                        if (this.navMaster.VisibleViewController == this.passwordFirstControl)
                        {
                            this.Window.RootViewController = this.password;
                            this.navMaster.PushViewController(this.passwordFirstControl, true);
                        }
                        else
                        {
                            this.navMaster.PushViewController(this.passwordFirstControl, true);
                        }
                    }
                    Console.WriteLine("Presented view controller" + this.navMaster.VisibleViewController);
                }
            }
        }
예제 #23
0
 public override void DidRegisterUserNotificationSettings(UIApplication application, UIUserNotificationSettings notificationSettings)
 {
     Console.WriteLine("didRegisterUserNotificationSettings");
 }
 public void DidRegisterUserNotificationSettings(UIApplication application, UIUserNotificationSettings notificationSettings)
 {
     //application.RegisteredForRemoteNotifications (application);
     application.RegisterForRemoteNotifications ();
 }
예제 #25
0
        public override bool FinishedLaunching(UIApplication app, NSDictionary options)
        {
            Xamarin.Forms.Forms.SetFlags(new string[] { "CarouselView_Experimental", "SwipeView_Experimental", "IndicatorView_Experimental", "MediaElement_Experimental" });
            UINavigationBar.Appearance.TintColor = UIColor.Red;

            UINavigationBar.Appearance.SetTitleTextAttributes(new UITextAttributes()
            {
                TextColor = UIColor.Red
            });


            //Actualizar el token de las notificaciones
            MessagingCenter.Subscribe <JobMe.ViewModels.MainEmployeeViewModel>(this, "DeleteToken", sender =>
            {
                if (UIDevice.CurrentDevice.CheckSystemVersion(10, 0))
                {
                    UNUserNotificationCenter.Current.RequestAuthorization(UNAuthorizationOptions.Alert | UNAuthorizationOptions.Badge | UNAuthorizationOptions.Sound,
                                                                          (granted, error) =>
                    {
                        if (granted)
                        {
                            InvokeOnMainThread(UIApplication.SharedApplication.RegisterForRemoteNotifications);
                        }
                    });
                }
                else if (UIDevice.CurrentDevice.CheckSystemVersion(8, 0))
                {
                    var pushSettings = UIUserNotificationSettings.GetSettingsForTypes(
                        UIUserNotificationType.Alert | UIUserNotificationType.Badge | UIUserNotificationType.Sound,
                        new NSSet());

                    UIApplication.SharedApplication.RegisterUserNotificationSettings(pushSettings);
                    UIApplication.SharedApplication.RegisterForRemoteNotifications();
                }
                else
                {
                    UIRemoteNotificationType notificationTypes = UIRemoteNotificationType.Alert | UIRemoteNotificationType.Badge | UIRemoteNotificationType.Sound;
                    UIApplication.SharedApplication.RegisterForRemoteNotificationTypes(notificationTypes);
                }
            });

            MessagingCenter.Subscribe <JobMe.ViewModels.LoginViewModel>(this, "DeleteToken", sender =>
            {
                if (UIDevice.CurrentDevice.CheckSystemVersion(10, 0))
                {
                    InvokeOnMainThread(UIApplication.SharedApplication.RegisterForRemoteNotifications);
                }
                else if (UIDevice.CurrentDevice.CheckSystemVersion(8, 0))
                {
                    var pushSettings = UIUserNotificationSettings.GetSettingsForTypes(
                        UIUserNotificationType.Alert | UIUserNotificationType.Badge | UIUserNotificationType.Sound,
                        new NSSet());

                    UIApplication.SharedApplication.RegisterUserNotificationSettings(pushSettings);
                    UIApplication.SharedApplication.RegisterForRemoteNotifications();
                }
                else
                {
                    UIRemoteNotificationType notificationTypes = UIRemoteNotificationType.Alert | UIRemoteNotificationType.Badge | UIRemoteNotificationType.Sound;
                    UIApplication.SharedApplication.RegisterForRemoteNotificationTypes(notificationTypes);
                }
            });


            if (UIDevice.CurrentDevice.CheckSystemVersion(10, 0))
            {
                UNUserNotificationCenter.Current.RequestAuthorization(UNAuthorizationOptions.Alert | UNAuthorizationOptions.Badge | UNAuthorizationOptions.Sound,
                                                                      (granted, error) =>
                {
                    if (granted)
                    {
                        InvokeOnMainThread(UIApplication.SharedApplication.RegisterForRemoteNotifications);
                    }
                });
            }
            else if (UIDevice.CurrentDevice.CheckSystemVersion(8, 0))
            {
                var pushSettings = UIUserNotificationSettings.GetSettingsForTypes(
                    UIUserNotificationType.Alert | UIUserNotificationType.Badge | UIUserNotificationType.Sound,
                    new NSSet());

                UIApplication.SharedApplication.RegisterUserNotificationSettings(pushSettings);
                UIApplication.SharedApplication.RegisterForRemoteNotifications();
            }
            else
            {
                UIRemoteNotificationType notificationTypes = UIRemoteNotificationType.Alert | UIRemoteNotificationType.Badge | UIRemoteNotificationType.Sound;
                UIApplication.SharedApplication.RegisterForRemoteNotificationTypes(notificationTypes);
            }

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

            SfPullToRefreshRenderer.Init();
            SfCardLayoutRenderer.Init();
            CarouselViewRenderer.Init();
            SfTabViewRenderer.Init();
            SfRotatorRenderer.Init();
            SfBadgeViewRenderer.Init();
            Syncfusion.XForms.iOS.Chat.SfChatRenderer.Init();
            SfBorderRenderer.Init();
            new SfComboBoxRenderer();
            SfTextInputLayoutRenderer.Init();
            SfMaskedEditRenderer.Init();
            SfPdfDocumentViewRenderer.Init();
            SfRangeSliderRenderer.Init();
            SfPickerRenderer.Init();
            SfListViewRenderer.Init();
            SfEffectsViewRenderer.Init();
            SfAvatarViewRenderer.Init();
            SfMaskedEditRenderer.Init();
            Syncfusion.XForms.iOS.PopupLayout.SfPopupLayoutRenderer.Init();
            //SfRotatorRenderer.Init();
            Syncfusion.XForms.iOS.Buttons.SfSegmentedControlRenderer.Init();

            FFImageLoading.Forms.Platform.CachedImageRenderer.Init();

            FormsVideoPlayer.Init();

            CardsViewRenderer.Preserve();

            App.ScreenWidth  = UIScreen.MainScreen.Bounds.Width;
            App.ScreenHeight = UIScreen.MainScreen.Bounds.Height;

            LoadApplication(new App(false));
            //  LoadApplication(new App(false));

            // Watch for notifications while the app is active
            UNUserNotificationCenter.Current.Delegate = new UserNotificationCenterDelegate();

            return(base.FinishedLaunching(app, options));
        }
예제 #26
0
        public override bool FinishedLaunching(UIApplication app, NSDictionary options)
        {
            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());


            // Handling Push notification when app is closed if App was opened by Push Notification...
            if (options != null && options.Keys != null && options.Keys.Count() != 0 && options.ContainsKey(new NSString("UIApplicationLaunchOptionsRemoteNotificationKey")))
            {
                NSDictionary UIApplicationLaunchOptionsRemoteNotificationKey = options.ObjectForKey(new NSString("UIApplicationLaunchOptionsRemoteNotificationKey")) as NSDictionary;

                ProcessNotification(UIApplicationLaunchOptionsRemoteNotificationKey, true);
            }

            //added on 1/7/17 by aditmer to see if the device token from APNS has changed (like after an app update)
            if (ApplicationSettings.InstallationID != "")
            {
                //Push notifications registration
                if (UIDevice.CurrentDevice.CheckSystemVersion(8, 0))
                {
                    var pushSettings = UIUserNotificationSettings.GetSettingsForTypes(
                        UIUserNotificationType.Alert | UIUserNotificationType.Badge | UIUserNotificationType.Sound,
                        new NSSet());

                    UIApplication.SharedApplication.RegisterUserNotificationSettings(pushSettings);
                    UIApplication.SharedApplication.RegisterForRemoteNotifications();
                }
                else
                {
                    UIRemoteNotificationType notificationTypes = UIRemoteNotificationType.Alert | UIRemoteNotificationType.Badge | UIRemoteNotificationType.Sound;
                    UIApplication.SharedApplication.RegisterForRemoteNotificationTypes(notificationTypes);
                }
            }
            //added on 1/4/17 by aditmer to add 4 (1/6/17) customizable snooze options
            int snoozeTime1 = 1;
            int snoozeTime2 = 2;
            int snoozeTime3 = 3;
            int snoozeTime4 = 4;

            if (ApplicationSettings.AlarmUrgentLowMins1 != 0)
            {
                snoozeTime1 = ApplicationSettings.AlarmUrgentLowMins1;
            }

            if (ApplicationSettings.AlarmUrgentLowMins2 != 0)
            {
                snoozeTime2 = ApplicationSettings.AlarmUrgentLowMins2;
            }

            if (ApplicationSettings.AlarmUrgentMins1 != 0)
            {
                snoozeTime3 = ApplicationSettings.AlarmUrgentMins1;
            }

            if (ApplicationSettings.AlarmUrgentMins2 != 0)
            {
                snoozeTime4 = ApplicationSettings.AlarmUrgentMins2;
            }


            //added on 12/03/16 by aditmer to add custom actions to the notifications (I think this code goes here)
            // Create action
            var actionID = "snooze1";
            var title    = $"Snooze {snoozeTime1} minutes";
            var action   = UNNotificationAction.FromIdentifier(actionID, title, UNNotificationActionOptions.None);

            var actionID2 = "snooze2";
            var title2    = $"Snooze {snoozeTime2} minutes";
            var action2   = UNNotificationAction.FromIdentifier(actionID2, title2, UNNotificationActionOptions.None);

            var actionID3 = "snooze3";
            var title3    = $"Snooze {snoozeTime3} minutes";
            var action3   = UNNotificationAction.FromIdentifier(actionID3, title3, UNNotificationActionOptions.None);

            var actionID4 = "snooze4";
            var title4    = $"Snooze {snoozeTime4} minutes";
            var action4   = UNNotificationAction.FromIdentifier(actionID4, title4, UNNotificationActionOptions.None);

            // Create category
            var categoryID = "event";
            var actions    = new List <UNNotificationAction> {
                action, action2, action3, action4
            };
            var intentIDs       = new string[] { };
            var categoryOptions = new UNNotificationCategoryOptions[] { };

            //added on 1/19/17 by aditmer to remove duplicate snooze options (they can be custom set by each user in their Nightscout settings)
            actions = actions.DistinctBy((arg) => arg.Title).ToList();


            var category = UNNotificationCategory.FromIdentifier(categoryID, actions.ToArray(), intentIDs, UNNotificationCategoryOptions.AllowInCarPlay);

            // Register category
            var categories = new UNNotificationCategory[] { category };
            UNUserNotificationCenter.Current.SetNotificationCategories(new NSSet <UNNotificationCategory>(categories));

            return(base.FinishedLaunching(app, options));
        }
예제 #27
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            this.NavigationController.NavigationBar.Translucent = true;
            //Estilos para la barra de navegacion
            this.NavigationController.NavigationBar.TintColor = UIColor.Gray;
            //this.NavigationController.NavigationBar.BarTintColor =  UIColor.Blue;
            this.NavigationController.NavigationBar.Translucent = true;
            //Fin estilos barra navegacion

            GetData();
            DataSource data = new DataSource(jsonObj, this);

            tvDatos.Source = data;
            tvDatos.ReloadData();
            tvDatos.ReloadInputViews();

            //Nuevos beacons

            var settings = UIUserNotificationSettings.GetSettingsForTypes(
                UIUserNotificationType.Alert
                | UIUserNotificationType.Badge
                | UIUserNotificationType.Sound,
                new NSSet());

            UIApplication.SharedApplication.RegisterUserNotificationSettings(settings);

            locationMgr = new CLLocationManager();

            if (locationMgr.RespondsToSelector(new Selector("requestWhenInUseAuthorization")))
            {
                locationMgr.RequestAlwaysAuthorization();
            }

            //primer beacon
            var shopUUID     = new NSUuid(uuid);
            var beaconRegion = new CLBeaconRegion(shopUUID, firstShopId);

            beaconRegion.NotifyEntryStateOnDisplay = true;
            beaconRegion.NotifyOnEntry             = true;
            beaconRegion.NotifyOnExit = true;

            locationMgr.StartMonitoring(beaconRegion);
            locationMgr.StartRangingBeacons(beaconRegion);

            //segundo beacon
            var shop2UUID     = new NSUuid(uuid2);
            var beaconRegion2 = new CLBeaconRegion(shop2UUID, secondShopId);

            beaconRegion2.NotifyEntryStateOnDisplay = true;
            beaconRegion2.NotifyOnEntry             = true;
            beaconRegion2.NotifyOnExit = true;

            locationMgr.StartMonitoring(beaconRegion2);
            locationMgr.StartRangingBeacons(beaconRegion2);



            locationMgr.RegionEntered += (object sender, CLRegionEventArgs e) => {
                Console.WriteLine("RegionEntered");

                switch (e.Region.Identifier)
                {
                case "shop2":
                    UILocalNotification notification = new UILocalNotification()
                    {
                        AlertBody = "Existe una promoción A!!!"
                    };
                    UIApplication.SharedApplication.PresentLocationNotificationNow(notification);
                    break;

                case "shop1":
                    UILocalNotification notification2 = new UILocalNotification()
                    {
                        AlertBody = "Existe una promoción B!!!"
                    };
                    UIApplication.SharedApplication.PresentLocationNotificationNow(notification2);
                    break;
                }

                /*
                 * if (e.Region.Identifier == secondShopId) {
                 *      UILocalNotification notification = new UILocalNotification () { AlertBody = "Existe una promoción A!!!" };
                 *      UIApplication.SharedApplication.PresentLocationNotificationNow (notification);
                 * }
                 * if (e.Region.Identifier == firstShopId) {
                 *      UILocalNotification notification = new UILocalNotification () { AlertBody = "Existe una promoción B!!!" };
                 *      UIApplication.SharedApplication.PresentLocationNotificationNow (notification);
                 * }
                 */
            };

            locationMgr.DidRangeBeacons += (object sender, CLRegionBeaconsRangedEventArgs e) => {
                System.Diagnostics.Debug.WriteLine("Entramos");
                if (e.Beacons.Length > 0)
                {
                    if (e.Region.Identifier == firstShopId)
                    {
                        CLBeacon beacon = e.Beacons [0];
                        switch (beacon.Proximity)
                        {
                        case CLProximity.Immediate:
                            Console.WriteLine("Beacon 1");
                            var CategoryVC = new iBeaconVC();
                            this.NavigationController.PresentViewController(CategoryVC, true, null);
                            break;
                        }
                    }
                    if (e.Region.Identifier == secondShopId)
                    {
                        CLBeacon beacon = e.Beacons [0];
                        switch (beacon.Proximity)
                        {
                        case CLProximity.Immediate:
                            Console.WriteLine("Beacon 2");
                            var Category2VC = new Catego2ViewController();
                            this.NavigationController.PresentViewController(Category2VC, true, null);
                            break;
                        }
                    }
                }
            };



            //locationMgr.StartMonitoring (beaconRegion2);
            //locationMgr.StartRangingBeacons (beaconRegion2);


            //this.NavigationController.PushViewController(CategoryVC, true);
        }
예제 #28
0
        public override bool FinishedLaunching(UIApplication app, NSDictionary options)

        {
            // Override point for customization after application launch.

            // If not required for your application you can safely delete this method



            //(Window.RootViewController as UINavigationController).PushViewController(new UserInfoViewController(this), true);

            //UIApplication.SharedApplication.StatusBarStyle = UIStatusBarStyle.LightContent;



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

            Firebase.Core.App.Configure();
            LoadApplication(new App());



            // Register your app for remote notifications.

            if (UIDevice.CurrentDevice.CheckSystemVersion(10, 0))
            {
                // For iOS 10 display notification (sent via APNS)

                UNUserNotificationCenter.Current.Delegate = this;



                var authOptions = UNAuthorizationOptions.Alert | UNAuthorizationOptions.Badge | UNAuthorizationOptions.Sound;

                UNUserNotificationCenter.Current.RequestAuthorization(authOptions, (granted, error) => {
                    Console.WriteLine(granted);
                });
            }
            else
            {
                // iOS 9 or before

                var allNotificationTypes = UIUserNotificationType.Alert | UIUserNotificationType.Badge | UIUserNotificationType.Sound;

                var settings = UIUserNotificationSettings.GetSettingsForTypes(allNotificationTypes, null);

                UIApplication.SharedApplication.RegisterUserNotificationSettings(settings);
            }



            UIApplication.SharedApplication.RegisterForRemoteNotifications();



            Messaging.SharedInstance.Delegate = this;



            // To connect with FCM. FCM manages the connection, closing it

            // when your app goes into the background and reopening it

            // whenever the app is foregrounded.

            Messaging.SharedInstance.ShouldEstablishDirectChannel = true;



            return(base.FinishedLaunching(app, options));
        }
예제 #29
0
 public void DidRegisterUserNotificationSettings(UIApplication application, UIUserNotificationSettings notificationSettings)
 {
     SMManager.SharedInstance().DidRegisterUserNotificationSettings(notificationSettings);
 }
예제 #30
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));
        }
예제 #31
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)
        {
            UINavigationBar.Appearance.BarTintColor = UIColor.FromRGB(33, 150, 243);
            UINavigationBar.Appearance.TintColor    = UIColor.White;

            UINavigationBar.Appearance.SetTitleTextAttributes(new UITextAttributes {
                TextColor = UIColor.White
            });
            ImageCircle.Forms.Plugin.iOS.ImageCircleRenderer.Init();

            //UINavigationBar.Appearance.TitleTextAttributes.ForegroundColor = UIColor.White;

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

            //CrossBadge.Current.SetBadge(10);


            if (UIDevice.CurrentDevice.CheckSystemVersion(10, 0))
            {
                var authOptions = UNAuthorizationOptions.Alert | UNAuthorizationOptions.Badge | UNAuthorizationOptions.Sound;
                UNUserNotificationCenter.Current.RequestAuthorization(authOptions, (granted, error) =>
                {
                    Console.WriteLine("granted--------------------------------------------------------" + granted);
                });

                // For iOS 10 display notification (sent via APNS)
                UNUserNotificationCenter.Current.Delegate = this;

                // For iOS 10 data message (sent via FCM)
                //Messaging.SharedInstance.RemoteMessageDelegate = this;
            }
            else
            {
                var allNotificationTypes = UIUserNotificationType.Alert | UIUserNotificationType.Badge | UIUserNotificationType.Sound;
                var settings             = UIUserNotificationSettings.GetSettingsForTypes(allNotificationTypes, null);


                UIApplication.SharedApplication.RegisterUserNotificationSettings(settings);
            }

            UIApplication.SharedApplication.RegisterForRemoteNotifications();

            // Firebase component initialize
            Firebase.Core.App.Configure();
            //Firebase.Analytics.App.Configure();

            Firebase.InstanceID.InstanceId.Notifications.ObserveTokenRefresh((sender, e) =>
            {
                var newToken = Firebase.InstanceID.InstanceId.SharedInstance.Token;
                // if you want to send notification per user, use this token
                System.Diagnostics.Debug.WriteLine("newToken-------------------------------------------------------------" + newToken);
                Aliswork.ContentGlobal.registrationId = newToken;

                connectFCM();
            });



            //return base.FinishedLaunching(uiApplication, launchOptions);

            return(base.FinishedLaunching(app, options));
        }
예제 #32
0
 public override void DidRegisterUserNotificationSettings(UIApplication application, UIUserNotificationSettings notificationSettings)
 {
     NotificationsRegistered(notificationSettings);
 }
예제 #33
0
        public override bool FinishedLaunching(UIApplication app, NSDictionary options)
        {
            ServicePointManager.ServerCertificateValidationCallback +=
                (sender, cert, chain, sslPolicyErrors) =>
            {
                System.Diagnostics.Debug.WriteLine(cert.GetSerialNumberString());
                System.Diagnostics.Debug.WriteLine(cert.Issuer);
                System.Diagnostics.Debug.WriteLine(cert.Subject);
                return(true);
            };

            UIApplication.SharedApplication.SetStatusBarStyle(UIStatusBarStyle.LightContent, false);
            UIApplication.SharedApplication.SetStatusBarHidden(false, false);

            UINavigationBar.Appearance.SetTitleTextAttributes(new UITextAttributes()
            {
                Font      = UIFont.FromName("HelveticaNeue-Light", (nfloat)20f),
                TextColor = UIColor.White
            });

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

            iRate.SharedInstance.DaysUntilPrompt = 10;
            iRate.SharedInstance.UsesUntilPrompt = 20;
            ZXing.Net.Mobile.Forms.iOS.Platform.Init();

            CachedImageRenderer.Init();
            SlideOverKit.iOS.SlideOverKit.Init();
            OxyPlot.Xamarin.Forms.Platform.iOS.PlotViewRenderer.Init();

            LoadApplication(new App(SaveToken));
            CrossPushNotification.Initialize <CrossPushNotificationListener>();

            // Register your app for remote notifications.
            if (UIDevice.CurrentDevice.CheckSystemVersion(10, 0))
            {
                var authOptions = UNAuthorizationOptions.Alert | UNAuthorizationOptions.Badge | UNAuthorizationOptions.Sound;
                UNUserNotificationCenter.Current.RequestAuthorization(authOptions, (granted, error) =>
                {
                    App.AddLog("GC Authorization granted");
                });

                // For iOS 10 display notification (sent via APNS)
                UNUserNotificationCenter.Current.Delegate = this;

                // For iOS 10 data message (sent via FCM)
                Messaging.SharedInstance.RemoteMessageDelegate = this;
            }
            else
            {
                // iOS 9 or before
                var allNotificationTypes = UIUserNotificationType.Alert | UIUserNotificationType.Badge | UIUserNotificationType.Sound;
                var settings             = UIUserNotificationSettings.GetSettingsForTypes(allNotificationTypes, null);
                UIApplication.SharedApplication.RegisterUserNotificationSettings(settings);
            }

            UIApplication.SharedApplication.RegisterForRemoteNotifications();


            App.AddLog("GCM: Setup Firebase");
            Firebase.Core.App.Configure();
            Firebase.InstanceID.InstanceId.Notifications.ObserveTokenRefresh((sender, e) =>
            {
                var refreshedToken = Firebase.InstanceID.InstanceId.SharedInstance.Token;
                tokenUploaded      = false;
                SaveToken();
            });

            return(base.FinishedLaunching(app, options));
        }
예제 #34
0
        public override void DidRegisterUserNotificationSettings(UIApplication application, UIUserNotificationSettings notificationSettings)
        {
            Helpers.Settings.Notifications = true;

            if (postItController == null)
            {
                return;
            }

            postItController.CreateAllNotifcations();
        }
예제 #35
0
		public override void DidRegisterUserNotificationSettings (UIApplication application, UIUserNotificationSettings notificationSettings)
		{
			application.RegisterForRemoteNotifications();
		}
예제 #36
0
        public override bool FinishedLaunching(UIApplication application, NSDictionary launchOptions)
        {
            try
            {
                //downloading all wine images
                BlobWrapper.DownloadAllImages();
                // Override point for customization after application launch.
                // If not required for your application you can safely delete this method
                UITabBarController RootTab = (UITabBarController)Window.RootViewController;
                //CurrentUser.Clear();
                CurrentUser.Store("48732", "user Simulator");
                //for direct log in
                //CurrentUser.PutCa	rdNumber("7207589007");
                //Console.WriteLine(DateTime.Now + " App opened");
                UIImage profile = UIImage.FromFile("profile.png");
                profile = ResizeImage(profile, 25, 25);
                _window = Window;
                UIImage info = UIImage.FromFile("Info.png");
                info = ResizeImage(info, 25, 25);
                //Checking the user already logged in or not
                if (CurrentUser.RetreiveUserId() != 0)
                {
                    ManageTabBar(RootTab);
                    LoggingClass.LogInfo("App opened " + CurrentUser.RetreiveUserId(), screen);
                    nav = new UINavigationController(RootTab);
                    //Window.RootViewController = RootTab;
                    AddNavigationButtons(nav);
                    UIBarButtonItem.Appearance.TintColor = UIColor.FromRGB(128, 0, 128);
                    Window.RootViewController            = nav;
                }
                //Checking Guest logged in or not
                else if (CurrentUser.GetGuestId() != "0" && CurrentUser.GetGuestId() != null)
                {
                    CurrentUser.Store("0", "Guest");
                    ManageTabBar(RootTab);
                    //Console.WriteLine(DateTime.Now + " App opened");
                    nav = new UINavigationController(RootTab);
                    //Window.RootViewController = RootTab;
                    AddNavigationButtons(nav);
                    UIBarButtonItem.Appearance.TintColor = UIColor.FromRGB(128, 0, 128);
                    Window.RootViewController            = nav;
                }
                else
                {
                    ManageTabBar(RootTab);
                    var login = new LoginViewController();
                    login.RootTabs = Window.RootViewController;
                    login._window  = Window;
                    nav            = new UINavigationController(login);
                    //nav.NavigationBar.BackgroundColor = UIColor.FromRGB(97, 100, 142);
                    UIBarButtonItem.Appearance.TintColor = UIColor.FromRGB(128, 0, 128);
                    Window.RootViewController            = nav;
                }
            }
            catch (Exception exe)
            {
                LoggingClass.LogError(exe.Message, screen, exe.StackTrace);
            }
            //Notification Settings
            if (UIDevice.CurrentDevice.CheckSystemVersion(8, 0))
            {
                var pushSettings = UIUserNotificationSettings.GetSettingsForTypes(
                    UIUserNotificationType.Alert | UIUserNotificationType.Badge | UIUserNotificationType.Sound,
                    new NSSet());

                UIApplication.SharedApplication.RegisterUserNotificationSettings(pushSettings);
                UIApplication.SharedApplication.RegisterForRemoteNotifications();
            }
            else
            {
                UIRemoteNotificationType notificationTypes = UIRemoteNotificationType.Alert | UIRemoteNotificationType.Badge | UIRemoteNotificationType.Sound;
                UIApplication.SharedApplication.RegisterForRemoteNotificationTypes(notificationTypes);
            }
            return(true);
        }
예제 #37
0
 public override void DidRegisterUserNotificationSettings(UIApplication application,
                                                          UIUserNotificationSettings notificationSettings)
 {
     application.RegisterForRemoteNotifications();
 }
예제 #38
0
		public override void DidRegisterUserNotificationSettings (UIApplication application, UIUserNotificationSettings notificationSettings)
		{
			var handler = NotificationsRegistered;
			if(handler != null)
				handler (notificationSettings);
		}