コード例 #1
0
        /// <summary>
        /// Provisions the app for People app integration if it is supported
        /// by the current platform.
        /// </summary>
        /// <returns>An awaitable Task for social provisioning</returns>
        private async Task _SocialInfoProvisionAsync()
        {
            // Use the SocialInfoProviderManager to provision this app
            if (PlatformUtilities.IsSocialInfoApiAvailable())
            {
                bool isProvisionSuccessful = await SocialInfoProviderManager.ProvisionAsync();

                // Throw an exception if the app could not be provisioned
                if (!isProvisionSuccessful)
                {
                    throw new Exception("Could not provision the app with the SocialInfoProviderManager.");
                }
            }
        }
コード例 #2
0
        /// <summary>
        /// Downloads the feed asynchronously
        /// </summary>
        /// <returns>An awaitable Task</returns>
        public override async Task DownloadFeedAsync()
        {
            // Query the "database" for the home feeds
            IEnumerable <FeedItem> homeFeedItems =
                InMemorySocialCache.Instance.GetHomeFeeds(OwnerRemoteId, ItemCount);

            // Check if the platform supports the SocialInfo APIs
            if (!PlatformUtilities.IsSocialInfoApiAvailable())
            {
                return;
            }

            // Create the social feed updater
            SocialFeedUpdater feedUpdater = await SocialInfoProviderManager.CreateSocialFeedUpdaterAsync(
                SocialFeedKind.HomeFeed,
                SocialFeedUpdateMode.Replace,
                OwnerRemoteId);

            // Generate each of the feed items
            foreach (FeedItem fi in homeFeedItems)
            {
                SocialFeedItem item = new SocialFeedItem();

                item.Timestamp              = fi.Timestamp;
                item.RemoteId               = fi.Id;
                item.TargetUri              = fi.TargetUri;
                item.Author.DisplayName     = fi.AuthorDisplayName;
                item.Author.RemoteId        = fi.AuthorId;
                item.PrimaryContent.Title   = fi.Title;
                item.PrimaryContent.Message = fi.Message;

                if (fi.ImageUri != null)
                {
                    item.Thumbnails.Add(new SocialItemThumbnail()
                    {
                        TargetUri = fi.TargetUri,
                        ImageUri  = fi.ImageUri
                    });
                }

                feedUpdater.Items.Add(item);
            }

            await feedUpdater.CommitAsync();
        }
コード例 #3
0
        /// <summary>
        /// Handler for the user clicking the LogOut button
        /// </summary>
        public async void LogOut_Button_Click(object sender, RoutedEventArgs e)
        {
            // Get the ContactList and ContactAnnotationList
            ContactList contactList = await _GetContactListAsync();

            // Delete the contact list to remove all of the information that was
            // inserted by this app
            await contactList.DeleteAsync();

            // Use the SocialInfoProviderManager to deprovision this app.
            // In build 10240, this API is only present in the Mobile SDK extension.
            if (PlatformUtilities.IsSocialInfoApiAvailable())
            {
                await SocialInfoProviderManager.DeprovisionAsync();
            }

            // Mark the user as no longer logged in
            ApplicationSettings.SaveIsUserLoggedIn(false);

            // Update the state of the buttons
            LogInButton.IsEnabled  = true;
            LogOutButton.IsEnabled = !LogInButton.IsEnabled;
        }
コード例 #4
0
        /// <summary>
        /// Downloads the feed asynchronously
        /// </summary>
        /// <returns>An awaitable Task</returns>
        public override async Task DownloadFeedAsync()
        {
            // Get the dashboard feed item from the database
            FeedItem dashboardFeedItem = InMemorySocialCache.Instance.GetDashboardFeed(OwnerRemoteId);

            if (dashboardFeedItem != null)
            {
                // Check if the platform supports the SocialInfo APIs
                if (!PlatformUtilities.IsSocialInfoApiAvailable())
                {
                    return;
                }

                SocialDashboardItemUpdater dashboard =
                    await SocialInfoProviderManager.CreateDashboardItemUpdaterAsync(OwnerRemoteId);

                dashboard.Content.Message = dashboardFeedItem.Message;
                dashboard.Content.Title   = dashboardFeedItem.Title;
                dashboard.Timestamp       = dashboardFeedItem.Timestamp;

                // The TargetUri of the dashboard always has to be set
                dashboard.TargetUri = dashboardFeedItem.TargetUri;

                // For a thumbnail, there must always be a TargetUri.
                if ((dashboardFeedItem.ImageUri != null) && (dashboardFeedItem.TargetUri != null))
                {
                    dashboard.Thumbnail = new SocialItemThumbnail()
                    {
                        ImageUri  = dashboardFeedItem.ImageUri,
                        TargetUri = dashboardFeedItem.TargetUri
                    };
                }

                await dashboard.CommitAsync();
            }
        }