Example #1
0
        public void TermsDismissed(bool isAccepted)
        {
            this.DismissViewController(true, async() => {
                if (!isAccepted)
                {
                    NavigationController.PopViewControllerAnimated(true);
                }
                else
                {
                    AccountManager acm = new AccountManager();

                    iOSLoginManager loginManager = iOSLoginManager.Instance;

                    TravelerModel traveler       = await acm.GetTravelerByEmail(loginManager.GetUsername());
                    traveler.InformedConsent     = true;
                    traveler.InformedConsentDate = DateTime.UtcNow;

                    traveler = await acm.UpdateTraveler(traveler);

                    NavigationController.PopViewControllerAnimated(true);

                    if (LoginEvent != null)
                    {
                        LoginEvent();
                    }
                }
            });
        }
Example #2
0
        async public override void ViewWillAppear(bool animated)
        {
            showLoading();
            mACM = new AccountManager();
            iOSLoginManager loginManager = iOSLoginManager.Instance;

            mUsername = loginManager.GetUsername();

            mTraveler = await mACM.GetTravelerByEmail(mUsername);

            if (!String.IsNullOrEmpty(mTraveler.PromoCode))
            {
                txtPromoCode.Text      = mTraveler.PromoCode;
                btnSetPromoCode.Hidden = true;
            }
            else
            {
                btnSetPromoCode.Hidden = false;
            }

            lblUsername.Text = mUsername;

                        #if DEBUG
            string versionTag = " debug";
                        #else
            string versionTag = "";
                        #endif
            lblVersion.Text = NSBundle.MainBundle.InfoDictionary [new NSString("CFBundleVersion")].ToString() + versionTag;
            dismissLoading();
        }
Example #3
0
        public override void RegisteredForRemoteNotifications(UIApplication application, NSData deviceToken)
        {
            // NOTE: Don't call the base implementation on a Model class
            // see http://docs.xamarin.com/guides/ios/application_fundamentals/delegates,_protocols,_and_events

            Hub = new SBNotificationHub(Constants.ConnectionString, Constants.NotificationHubPath);
            this.DeviceToken = deviceToken;

            try{
                Hub.UnregisterAllAsync(deviceToken, (error) => {
                    if (error != null)
                    {
                        Console.WriteLine("Error calling Unregister: {0}", error.ToString());
                        return;
                    }


                    iOSLoginManager loginManager = iOSLoginManager.Instance;

                    string username   = loginManager.GetUsername();
                    string travelerId = loginManager.GetTravelerId().ToString();

                    string[] tagsArray = new string[2];
                    tagsArray[0]       = username;
                    tagsArray[1]       = travelerId;

                    NSSet tags = new NSSet(tagsArray);

                    Hub.RegisterNativeAsync(deviceToken, tags, (errorCallback) => {
                        if (errorCallback != null)
                        {
                            GAI.SharedInstance.DefaultTracker.Send(GAIDictionaryBuilder.CreateEvent("app_action", "notifications", "notifications registration error", null).Build());
                            Console.WriteLine("RegisterNativeAsync error: " + errorCallback.ToString());
                        }
                        else
                        {
                            GAI.SharedInstance.DefaultTracker.Send(GAIDictionaryBuilder.CreateEvent("app_action", "notifications launched", "notifications registration complete", null).Build());
                        }
                    });
                });
            }catch (Exception ex) {
                Console.WriteLine("Error" + ex.ToString());
            }
        }
Example #4
0
        private async Task checkLogin()
        {
            iOSLoginManager loginManager = iOSLoginManager.Instance;
            bool            shouldLogout = NSUserDefaults.StandardUserDefaults.BoolForKey("logout_preference");

            if (shouldLogout)
            {
                loginManager.Logout();
                NSUserDefaults.StandardUserDefaults.SetBool(false, "logout_preference");
            }

            AccountManager acm      = new AccountManager();
            TravelerModel  traveler = await acm.GetTravelerByEmail(loginManager.GetUsername());

            if (traveler != null && !traveler.InformedConsent)
            {
                loginManager.Logout();
            }


            if (!await loginManager.IsLoggedIn())
            {
                PerformSegue("LoginSegue", this);
            }
            else
            {
                UIRemoteNotificationType notificationTypes = UIRemoteNotificationType.Alert |
                                                             UIRemoteNotificationType.Badge | UIRemoteNotificationType.Sound;
                UIApplication.SharedApplication.RegisterForRemoteNotificationTypes(notificationTypes);

                if (CLLocationManager.LocationServicesEnabled)
                {
                    mLocationManager.StartUpdatingLocation();
                }

                await UpdateTripDisplays();
            }
        }