Advertisement
Guest User

Untitled

a guest
Feb 11th, 2016
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.96 KB | None | 0 0
  1. // Create an object
  2. NSDictionary *properties = @{
  3. @"og:type": @"books.book",
  4. @"og:title": @"A Game of Thrones",
  5. @"og:description": @"In the frozen wastes to the north of Winterfell, sinister and supernatural forces are mustering.",
  6. @"books:isbn": @"0-553-57340-3",
  7. };
  8. FBSDKShareOpenGraphObject *object = [FBSDKShareOpenGraphObject objectWithProperties:properties];
  9.  
  10. // Create an action
  11. FBSDKShareOpenGraphAction *action = [[FBSDKShareOpenGraphAction alloc] init];
  12. action.actionType = @"books.reads";
  13. [action setObject:object forKey:@"books:book"];
  14.  
  15. // Create the content
  16. FBSDKShareOpenGraphContent *content = [[FBSDKShareOpenGraphContent alloc] init];
  17. content.action = action;
  18. content.previewPropertyName = @"books:book";
  19.  
  20. FBSDKShareDialog *dialog = [[FBSDKShareDialog alloc] init];
  21.  
  22. if ([[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:@"fbauth2://"]]){
  23. dialog.mode = FBSDKShareDialogModeNative;
  24. }
  25. else {
  26. dialog.mode = FBSDKShareDialogModeBrowser; //or FBSDKShareDialogModeAutomatic
  27. }
  28. dialog.shareContent = content;
  29. dialog.delegate = self;
  30. dialog.fromViewController = self;
  31. [dialog show];
  32.  
  33. FBSDKShareLinkContent *content = [[FBSDKShareLinkContent alloc] init];
  34.  
  35. content.contentURL = [NSURL URLWithString:@"https://developers.facebook.com"];
  36. content.contentTitle=@"TestSHare";
  37.  
  38. FBSDKShareDialog *dialog = [[FBSDKShareDialog alloc] init];
  39.  
  40. if ([[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:@"fbauth2://"]]){
  41. dialog.mode = FBSDKShareDialogModeNative;
  42. }
  43. else {
  44. dialog.mode = FBSDKShareDialogModeBrowser; //or FBSDKShareDialogModeAutomatic
  45. }
  46. dialog.shareContent = content;
  47. dialog.delegate = self;
  48. dialog.fromViewController = self;
  49. [dialog show];
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement