3

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 ?

Larme
  • 24,190
  • 6
  • 51
  • 81
Vishal Wagh
  • 111
  • 1
  • 10
  • Read the doc: https://developers.facebook.com/docs/reference/ios/current/class/FBSDKHashtag/: `Represents a single hashtag that can be used with the share dialog.`, `You are responsible for making sure that stringRepresentation is a valid hashtag (a single '#' followed by one or more word characters). Invalid hashtags are ignored when sharing content. You can check validity with the valid property.` Your's isn't valid. – Larme Jan 04 '17 at 13:41
  • I'm Fresher can u give me n example, how to do it.? i'm stuck here last 6 hour.. – Vishal Wagh Jan 04 '17 at 14:19
  • The doc says, that's you can only have ONE hashtag, and it has to be a word, you can't put a sentence with one or various hashtag => "Hello" (it will prefix the # itself) works, but not "Hello there!". And your string is clearly not valid, so it's bypassed. – Larme Jan 04 '17 at 14:23
  • Yes I can Understand and I try that But it is not working. Is there any another way to share the Hash Tag string with the video. I was show this type of sharing in 1 app (Ripl ), but didn't know which is way they use. Please give me solution on this.? – Vishal Wagh Jan 04 '17 at 14:50
  • Hello, Please Help me out from these.. Give me the solution on these? If Any other way then let me know ? – Vishal Wagh Jan 05 '17 at 07:31

1 Answers1

2

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
     }
 }];

}

Vishal Wagh
  • 111
  • 1
  • 10