コード例 #1
0
        partial void OnShare(UIButton sender)
        {
            var shareDialog = new VKShareDialogController();

            shareDialog.Text                 = "This post was created and posted using the VKontakte Xamarin.iOS SDK. #vksdk #xamarin #ios";
            shareDialog.UploadImages         = new [] { VKUploadImage.Create(UIImage.FromBundle("apple.png"), VKImageParameters.JpegImage(0.8f)) };
            shareDialog.DismissAutomatically = true;

            PresentViewController(shareDialog, true, null);
        }
コード例 #2
0
        public override void RowSelected(UITableView tableView, NSIndexPath indexPath)
        {
            tableView.DeselectRow(indexPath, true);

            switch (indexPath.Row)
            {
            case 0:
                // users.get
                CallMethod(VKApi.Users.Get(new NSMutableDictionary <NSString, NSObject> {
                    { VKApiConst.Fields, (NSString)"first_name, last_name, uid, photo_100" },
                    { VKApiConst.UserId, (NSNumber)OwnerId }
                }));
                break;

            case 1:
                // friends.get
                CallMethod(VKApi.Friends.Get());
                break;

            case 2:
                // friends.get with fields
                var friendsRequest = VKApi.Friends.Get(new NSMutableDictionary <NSString, NSObject> {
                    { VKApiConst.Fields, (NSString)AllUserFields }
                });
                CallMethod(friendsRequest);
                break;

            case 3:
                // subscribers
                CallMethod(VKRequest.Create <VKUsersArray> ("users.getFollowers", new NSMutableDictionary <NSString, NSObject> {
                    { VKApiConst.UserId, (NSNumber)FollowersId },
                    { VKApiConst.Count, (NSNumber)100 },
                    { VKApiConst.Fields, (NSString)AllUserFields }
                }));
                break;

            case 4:
                // Upload photo to wall
                UploadWallPhoto();
                break;

            case 5:
                // Upload photo to album
                UploadAlbumPhoto();
                break;

            case 6:
                // Upload several photos to wall
                UploadSeveralWallPhotos();
                break;

            case 7:
                // Test captcha
                var request = new VKApiCaptcha().Force();
                request.Execute(
                    resp => Console.WriteLine("Result: " + resp),
                    error => Console.WriteLine("Error: " + error));
                break;

            case 8:
                // Call unknown method
                CallMethod(VKRequest.Create("I.am.Lord.Voldemort", null));
                break;

            case 9:
                // Test validation
                CallMethod(VKRequest.Create("account.testValidation", null));
                break;

            case 10:
                // Test share dialog
                var shareDialog = new VKShareDialogController();
                shareDialog.Text                 = "This post made with #vksdk #xamarin #ios";
                shareDialog.Images               = new [] { PhotoId, PhotoId2, PhotoId3 };
                shareDialog.ShareLink            = new VKShareLink("Super puper link, but nobody knows", new NSUrl("https://vk.com/dev/ios_sdk"));
                shareDialog.DismissAutomatically = true;
                PresentViewController(shareDialog, true, null);
                break;

            case 11:
                // Test VKActivity
                var items = new NSObject [] {
                    UIImage.FromBundle("apple"),
                    (NSString)"This post made with #vksdk activity #xamarin #ios",
                    new NSUrl("https://vk.com/dev/ios_sdk")
                };
                var activityViewController = new UIActivityViewController(items, new [] { new VKActivity() });
                activityViewController.SetValueForKey((NSString)"VK SDK", (NSString)"subject");
                activityViewController.CompletionHandler = null;
                if (UIDevice.CurrentDevice.CheckSystemVersion(8, 0))
                {
                    var popover = activityViewController.PopoverPresentationController;
                    if (popover != null)
                    {
                        popover.SourceView = View;
                        popover.SourceRect = tableView.RectForRowAtIndexPath(indexPath);
                    }
                }
                PresentViewController(activityViewController, false, null);
                break;

            case 12:
                // Test app request
                CallMethod(VKRequest.Create("apps.sendRequest", new NSMutableDictionary <NSString, NSObject> {
                    { (NSString)"user_id", (NSNumber)FriendId },
                    { (NSString)"text", (NSString)"Yo ho ho" },
                    { (NSString)"type", (NSString)"request" },
                    { (NSString)"name", (NSString)"I need more gold" },
                    { (NSString)"key", (NSString)"more_gold" }
                }));
                break;
            }
        }