Search code examples
objective-cfacebook-graph-apiios10facebook-sdk-4.x

How to share HashTag Text with Video On Facebook in IOS?


I'm sharing the video on Facebook (Without the SLComposer) from my IOS App. it will send successfully but I want To add the HashTag Text With it. Im Trying it But It will not get add shared with the video (only video get shared ).

FBSDKShareVideo *ShareVideo = [FBSDKShareVideo videoWithVideoURL:appDelegateObj.finalVideoUrl];
ShareVideo.videoURL = appDelegateObj.finalVideoUrl;
FBSDKShareVideoContent *ShareContnt = [[FBSDKShareVideoContent alloc] init];
ShareContnt.video = ShareVideo;
ShareContnt.hashtag =  [FBSDKHashtag hashtagWithString:[NSString stringWithFormat:@"%@",@"We are #sharing this #video for the #testing of #video and the #HashTag Text"]];
[FBSDKShareAPI shareWithContent:ShareContnt delegate:self];

Please Help me for this issues ?


Solution

  • 100% Working I got the ANS Of these...

    //Using these code we only share can't send the text / Title or name of video...

    -(void)facbookSharng {

    NSLog(@"Permission for sharing..%@",[FBSDKAccessToken currentAccessToken].permissions);
    if ([[FBSDKAccessToken currentAccessToken] hasGranted:@"contact_email"])
    {
        FBSDKShareVideo *ShareVideo = [FBSDKShareVideo videoWithVideoURL:appDelegateObj.finalVideoUrl];
        ShareVideo.videoURL = appDelegateObj.finalVideoUrl;
        FBSDKShareVideoContent *ShareContnt = [[FBSDKShareVideoContent alloc] init];
        ShareContnt.video = ShareVideo;
        [FBSDKShareAPI shareWithContent:ShareContnt delegate:self] 
    
          // write the deleate methdo for post ID..
    }
    

    }

    //But for these Facebook gives another way,

    NSLog(@"Permission for sharing..%@",[FBSDKAccessToken currentAccessToken].permissions); if ([[FBSDKAccessToken currentAccessToken] hasGranted:@"contact_email"]) {

    NSData *videoData = [NSData dataWithContentsOfURL:appDelegateObj.finalVideoUrl];
    NSMutableDictionary *params = [NSMutableDictionary dictionaryWithCapacity:3L];
    
    [params setObject:videoData forKey:@"video_filename.MOV"];
    [params setObject:@"Title for this post." forKey:@"title"];
    [params setObject:@"#Description for this post." forKey:@"description"];
    
    [[[FBSDKGraphRequest alloc] initWithGraphPath:@"/me/videos" parameters:params HTTPMethod:@"POST"]
     startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection, id result, NSError *error) {
         if (!error) {
             //video posted
             NSLog(@"Facebook sharing completed %@:",result);
             strFbSocialPostId = [result valueForKey:@"id"];//post ID
         }
     }];
    

    }