I want to share photos upon my custom button click, am able to share links and messages but when it comes to the sharing of photos am not able to do.
I am using latest Facebook SDK framework (4.15.1).
This is my code in inside the button click.
- (IBAction)btnsharecustom:(id)sender {
//Get aws s3 Image.
NSString* strS3ImageURL = @"https://TEST_IMAGE_URL/1473497380077.jpg";
//Convert to URL.
NSURL* url1 = [NSURL URLWithString:strS3ImageURL];
//Convert it into data.
NSData* data = [NSData dataWithContentsOfURL:url1];
//Convert it to image.
UIImage* image = [UIImage imageWithData:data];
FBSDKSharePhoto *photo = [[FBSDKSharePhoto alloc]init];
photo.image = image;
photo.caption = @"Test Caption";
photo.userGenerated = YES;
FBSDKSharePhotoContent *content = [[FBSDKSharePhotoContent alloc] init];
content.photos = @[photo];
}
I included this code in app delegate.
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization after application launch.
[[FBSDKApplicationDelegate sharedInstance] application:application
didFinishLaunchingWithOptions:launchOptions];
return YES;
}
//FaceBook URLs.
- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url
sourceApplication:(NSString *)sourceApplication annotation:(id)annotation {
BOOL handled = [[FBSDKApplicationDelegate sharedInstance] application:application
openURL:url
sourceApplication:sourceApplication
annotation:annotation
];
// Add any custom logic here.
return handled;
}
Also included this code in info.plist
<dict>
<key>CFBundleURLSchemes</key>
<array>
<string>fb15771408xxx409xx</string>
</array>
</dict>
<key>FacebookAppID</key>
<string>15771408xxx409xx</string>
<key>FacebookDisplayName</key>
<string>Cedar iOS</string>
<key>LSApplicationQueriesSchemes</key>
<array>
<string>fbapi</string>
<string>fb-messenger-api</string>
<string>fbauth2</string>
<string>fbshareextension</string>
<string>fbapi20130214</string>
<string>fbapi20130410</string>
<string>fbapi20130702</string>
<string>fbapi20131010</string>
<string>fbapi20131219</string>
<string>fbapi20140410</string>
<string>fbapi20140116</string>
<string>fbapi20150313</string>
<string>fbapi20150629</string>
<string>fbapi20160328</string>
<string>fbauth</string>
<string>fb-messenger-api20140430</string>
</array>
When I click upon my custom button Facebook App or safari browser is not launching, so can anyone tell me what I am missing here?