How to share NSData or phasset video using Facebook iOS SDK 4.0 FBSDKShareDialog -


i noticed can share nsdata video facebook messenger simply:

nsdata *videodata = [nsdata datawithcontentsofurl:localvideourl]; [fbsdkmessengersharer sharevideo:videodata withoptions:options]; 

but i’m having difficulties doing same when sharing facebook feed using local video file or phasset.

fbsdksharevideo *video = [fbsdksharevideo videowithvideourl:localvideourl]; fbsdksharevideocontent *content = [[fbsdksharevideocontent alloc] init]; [content setvideo: video]; [fbsdksharedialog showfromviewcontroller:nil withcontent:content delegate:self]; 

com.facebook.sdk:fbsdkerrordevelopermessagekey=only asset file urls allowed native dialog

how go having similar nice app-switching behavior using phasset video?

thanks!

with new facebook sdk 4.0, videos must passed assets url. have copy local video path assets library , use generated url share on facebook.

step 1:

nsurl *videourl=[nsurl fileurlwithpath:[[nsbundle mainbundle] pathforresource:@"img_1007" oftype:@"mp4"]]; [self savetocameraroll:videourl]; 

step 2:

- (void)savetocameraroll:(nsurl *)srcurl {     nslog(@"srcurl: %@", srcurl);      alassetslibrary *library = [[alassetslibrary alloc] init];     alassetslibrarywritevideocompletionblock videowritecompletionblock =     ^(nsurl *newurl, nserror *error) {         if (error) {             nslog( @"error writing image metadata photo library: %@", error );         } else {             nslog( @"wrote image metadata photo library %@", newurl.absolutestring);             url_new  = newurl;         }     };      if ([library videoatpathiscompatiblewithsavedphotosalbum:srcurl])     {         [library writevideoatpathtosavedphotosalbum:srcurl                                     completionblock:videowritecompletionblock];     } } 

step 3:

fbsdksharedialog *sharedialog = [[fbsdksharedialog alloc] init];     nsurl *videourl = url_new; fbsdksharevideo *video = [[fbsdksharevideo alloc] init]; video.videourl = videourl; fbsdksharevideocontent *content = [[fbsdksharevideocontent alloc] init];    content.video = video; sharedialog.sharecontent = content; sharedialog.delegate = self; [sharedialog show]; 

if have other query please let me know.

thanks!


Comments

Popular posts from this blog

Payment information shows nothing in one page checkout page magento -

tcpdump - How to check if server received packet (acknowledged) -