public override void ViewWillAppear(bool animated)
        {
            base.ViewWillAppear(animated);

            WillEnterForgroundToken = NSNotificationCenter.DefaultCenter.AddObserver(UIApplication.WillEnterForegroundNotification, (obj) =>
            {
                StartFlyingObjectsView();
            });

            DidEnterBackgroundToken = NSNotificationCenter.DefaultCenter.AddObserver(UIApplication.DidEnterBackgroundNotification, (obj) =>
            {
                FlyingObjects.EndAnimation(FlyingObjectsView.AnimationEnding.collapse, 0.1f);
            });

            DesignChangedToken = NSNotificationCenter.DefaultCenter.AddObserver(new NSString(Strings.InternalNotifications.notification_design_changed), async (obj) =>
            {
                FlyingObjects.EndAnimation(FlyingObjectsView.AnimationEnding.collapse, .01f);
                await System.Threading.Tasks.Task.Delay(TimeSpan.FromSeconds(0.5));
                StartFlyingObjectsView();
            });

            AdViewSuperViewHeightConstaint.Constant = 0;
            if (ShowsAds)
            {
                var iPersistant = ServiceLocator.Instance.Resolve<IPersistantStorage>();
                var facebookToken = iPersistant.GetFacebookToken();
                    
                var graphRequest = new GraphRequest("/me?fields=gender,birthday", null, facebookToken, null, "GET");
                var requestConnection = new GraphRequestConnection();
                requestConnection.AddRequest(graphRequest, (connection, result, error) =>
                {
                    var data = result as NSDictionary;
                    if (data == null) return;

                    var dict = new Dictionary<string, string>();

                    if(data.ContainsKey(new NSString(AdKeyGender)))
                        dict.Add(AdKeyGender, data[AdKeyGender].ToString());

                    if(data.ContainsKey(new NSString(AdKeyBirthday)))
                        dict.Add(AdKeyBirthday, data[AdKeyBirthday].ToString());
                    
                    ShowBanner(dict);
                });
                requestConnection.Start();
            }
        }

        public override void ViewDidAppear(bool animated)
Пример #2
0
        public override void ViewWillAppear(bool animated)
        {
            base.ViewWillAppear(animated);

            WillEnterForgroundToken = NSNotificationCenter.DefaultCenter.AddObserver(UIApplication.WillEnterForegroundNotification, (obj) =>
            {
                var service    = ServiceLocator.Instance.Resolve <IPersistantStorage>();
                var designType = service.GetDesignType();
                FlyingObjects.StartAnimationLoop(FlyingObjectsView.AnimationDirection.left, designType, 20, 100, 1);
            });

            DidEnterBackgroundToken = NSNotificationCenter.DefaultCenter.AddObserver(UIApplication.DidEnterBackgroundNotification, (obj) =>
            {
                FlyingObjects.EndAnimation(FlyingObjectsView.AnimationEnding.collapse, 10);
            });
        }