예제 #1
0
        public static async Task GetInfo(Action <JObject> onCompleted)
        {
            IsLoginCall = false;

            var accessToken = await RefreshAccessToken();

            var param   = NSDictionary.FromObjectAndKey(CurrentParameters.ToString(",").ToNs(), "fields".ToNs());
            var request = new SDK.CoreKit.GraphRequest("me", param, accessToken.TokenString, null, "GET");

            request.Start(new SDK.CoreKit.GraphRequestBlockHandler(GraphCallback));

            UserInfoFetched.ClearHandlers();
            UserInfoFetched.Handle(onCompleted);
        }
        public static async Task SetFromApi <TViewModel, TApiResult>(
            this Bindable <TViewModel> @this,
            Expression <Func <TViewModel, TApiResult> > viewModelProperty,
            string apiUrl,
            AsyncEvent <RevisitingEventArgs> pageRevisiting = null)
        {
            var binding = new Bindable <TViewModel> .ViewModelMemberBinding <TApiResult>(@this, viewModelProperty);

            var cacheAvailable = false;

            async Task refresh()
            {
                var fresh = await BaseApi.Get <TApiResult>(apiUrl, cacheChoice : ApiResponseCache.PreferThenUpdate, refresher : binding.Update);

                if (!cacheAvailable && fresh != null)
                {
                    binding.Update(fresh);
                }
            }

            // If there is a cached result already available, set it immediately
            var result = await BaseApi.Get <TApiResult>(apiUrl, cacheChoice : ApiResponseCache.CacheOrNull);

            if (result != null)
            {
                cacheAvailable = true;
                await binding.Update(result);
            }

            // Otherwise send a fresh request and apply the value.
            refresh().RunInParallel();

            // When gone back to the page, also refresh.
            if (pageRevisiting != null)
            {
                pageRevisiting.Handle(x => refresh());
            }
        }
 static PushNotification()
 {
     ReceivedError.Handle(error => Log.For(typeof(PushNotification)).Error("Push Notification Error: " + error));
     Init();
 }