Permalink
Browse files

Facebook iOS SDK 3.2 (see https://developers.facebook.com/ios/change-…

…log-3.x/)

Summary:

Modified
    FBSession properties accessToken, expirationDate and loginType have been deprecated. Instead use the new accessTokenData property to access this info.
    FBSession methods reauthorize* have been deprecated, instead use the requestNew* methods.
    Improved error handling logic, including handling various iOS 6 cases.
    The Scrumptious sample now uses FBLoginViewfor authentication. The sample has also been modified to show best practices in handling errors during authorization and calling Facebook APIs.
    Samples migrated from the deprecated APIs. The -ObjC linker flag added to all samples.
    Implicit logging added to provide Facebook Insights to events such as launching/dismissing the native share sheet, launching/dismissing the native Login dialog, friend picker usage, and place picker usage. A new advanced setting in the App Dashboard named Mobile SDK Insights, allows you to turn off the implicit logging which is on by default.
    PlacePickerSample sample displays an alert when a place is selected.
    JustRequestSample sample renamed to GraphApiSample.

Added
    FBWebDialog class to provide webview dialogs to replace Facebook dialog API.
    NSError(FBError) category extension to NSError to simplify Facebook error handling.
    FBSession methods requestNewPublishPermissions:defaultAudience:completionHandler: requestNewReadPermissions:completionHandler: for requesting new or additional permissions for the session.
    FBSession method openFromAccessTokenData to support opening from an FBAccessTokenData instance.
    FBSession class method renewSystemCredentials to allow easy refresh of iOS 6 account store.
    FBSession class methods to get and set default URL scheme suffix used in sessions:
        setDefaultUrlSchemeSuffix:
        defaultUrlSchemeSuffix
    FBAccessTokenData class to simplify access token data operations.
    FBSession property accessTokenData used to get the FBAccessTokenData used in the session.
    FBSessionTokenCachingStrategy methods to operate with FBAccessTokenData:
        nullCacheInstance - class method that returns an FBSessionTokenCachingStrategy instance that does not perform any caching. One scenario where this is useful is importing an access token using the openFromAccessTokenData method on an FBSession instance that is not initialized from cache. The nullCacheInstance can be used to create the required FBSession instance.
        cacheFBAccessTokenData: - method used to cache a token represented by FBAccessTokenData.
        fetchFBAccessTokenData - method used to fetch a cached token.
    FBPlacePickerViewController method updateView to allow a place picker refresh without a network roundtrip.
    FBLoginViewDelegate method loginView:handleError: to notify the delegate of communication or authorization errors.
    FBSettings method publishInstall:withHandler: enables defining a handler to process server response when publishing an attributed install for Mobile App Install Ads analytics.
    FBInsights class to provide client-side logging of specialized app analytics that are then available on Facebook Insights. Also provides analytics for Conversion Pixel tracking for ads optimization.
    FBSettings class methods setClientToken and clientToken to enable anonymous Facebook API calls in support of FBInsights logging.

Fixed
    Memory leaks in FBUserSettingsViewController, FBLoginView, and FBSession.
    Incorrect use of publish permissions when read permissions should be used, in FBUserSettingsViewController and FBLoginView.
    FBViewController to initialize ''done'' and''cancel'' buttons properly for non-programmatic init paths.
    FBViewController and FBLoginView documentation.
    A bug in the FBSession handleOpenURL method that no longer passed through errors.
    A bug in the FBSession handleDidBecomeActive method that incorrectly coupled to the active session.
    A bug in FBSession that prevented KVO of the state property.
    How friend picker and place picker selection changed events are triggered when items are deselected. The event was being triggered multiple times in certain scenarios.
    The friend picker to properly handle profiles with no name data.
    A bug in WebView Login dialog reauthorization flow that did not invoke reauthorization handlers.
    Rotation bugs in ProfilePictureSample, FriendPickerSample and FBUserSettingsViewController.
    FriendPickerViewController and PlacePickerViewController can now fetch Retina-sized images.

Reviewers: clang

Reviewed By: clang

Test Plan: Release Testing.
  • Loading branch information...
1 parent 2a030e7 commit 76b75a4fe076da2df8974cb7651e66e8a9d46d2c @chrisp-fb chrisp-fb committed Feb 25, 2013
Showing with 6,819 additions and 2,105 deletions.
  1. +0 −5 .arcconfig
  2. +3 −0 .gitignore
  3. +8 −2 samples/BooleanOGSample/BooleanOGSample.xcodeproj/project.pbxproj
  4. +19 −35 samples/BooleanOGSample/BooleanOGSample/BOGFirstViewController.m
  5. +4 −0 samples/BooleanOGSample/BooleanOGSample/BOGSecondViewController.h
  6. +12 −0 samples/BooleanOGSample/BooleanOGSample/BOGSecondViewController.m
  7. +0 −2 samples/BooleanOGSample/BooleanOGSample/BooleanOGSample-Info.plist
  8. +160 −11 samples/BooleanOGSample/BooleanOGSample/en.lproj/BOGSecondViewController_iPad.xib
  9. +161 −14 samples/BooleanOGSample/BooleanOGSample/en.lproj/BOGSecondViewController_iPhone.xib
  10. +8 −2 samples/FriendPickerSample/FriendPickerSample.xcodeproj/project.pbxproj
  11. +7 −4 samples/FriendPickerSample/FriendPickerSample/FPAppDelegate.m
  12. +5 −0 samples/FriendPickerSample/FriendPickerSample/FPViewController.m
  13. +12 −48 samples/FriendPickerSample/FriendPickerSample/en.lproj/FPViewController_iPhone.xib
  14. +56 −50 ...uestSample/JustRequestSample.xcodeproj → GraphApiSample/GraphApiSample.xcodeproj}/project.pbxproj
  15. BIN samples/{JustRequestSample/JustRequestSample → GraphApiSample/GraphApiSample}/Default-568h@2x.png
  16. BIN samples/{JustRequestSample/JustRequestSample → GraphApiSample/GraphApiSample}/Default.png
  17. BIN samples/{JustRequestSample/JustRequestSample → GraphApiSample/GraphApiSample}/Default@2x.png
  18. +3 −3 ...stSample/JustRequestSample/JRAppDelegate.h → GraphApiSample/GraphApiSample/GraphApiAppDelegate.h}
  19. +5 −5 ...stSample/JustRequestSample/JRAppDelegate.m → GraphApiSample/GraphApiSample/GraphApiAppDelegate.m}
  20. +3 −3 ...estSample/JustRequestSample-Info.plist → GraphApiSample/GraphApiSample/GraphApiSample-Info.plist}
  21. +1 −1 ...estSample/JustRequestSample-Prefix.pch → GraphApiSample/GraphApiSample/GraphApiSample-Prefix.pch}
  22. +1 −1 ...le/JustRequestSample/JRViewController.h → GraphApiSample/GraphApiSample/GraphApiViewController.h}
  23. +15 −5 ...le/JustRequestSample/JRViewController.m → GraphApiSample/GraphApiSample/GraphApiViewController.m}
  24. BIN samples/{JustRequestSample/JustRequestSample → GraphApiSample/GraphApiSample}/Icon-72.png
  25. BIN samples/{JustRequestSample/JustRequestSample → GraphApiSample/GraphApiSample}/Icon-72@2x.png
  26. BIN samples/{JustRequestSample/JustRequestSample → GraphApiSample/GraphApiSample}/Icon.png
  27. BIN samples/{JustRequestSample/JustRequestSample → GraphApiSample/GraphApiSample}/Icon@2x.png
  28. +13 −60 ...ViewController_iPad.xib → GraphApiSample/GraphApiSample/en.lproj/GraphApiViewController_iPad.xib}
  29. +13 −59 ...Controller_iPhone.xib → GraphApiSample/GraphApiSample/en.lproj/GraphApiViewController_iPhone.xib}
  30. 0 .../{JustRequestSample/JustRequestSample → GraphApiSample/GraphApiSample}/en.lproj/InfoPlist.strings
  31. +2 −2 samples/{JustRequestSample/JustRequestSample → GraphApiSample/GraphApiSample}/main.m
  32. +2 −2 samples/{JustRequestSample → GraphApiSample}/ReadMe.txt
  33. +8 −2 samples/Hackbook/Hackbook.xcodeproj/project.pbxproj
  34. +8 −2 samples/HelloFacebookSample/HelloFacebookSample.xcodeproj/project.pbxproj
  35. +3 −4 samples/HelloFacebookSample/HelloFacebookSample/HFAppDelegate.m
  36. +21 −7 samples/HelloFacebookSample/HelloFacebookSample/HFViewController.m
  37. +10 −4 samples/PlacePickerSample/PlacePickerSample.xcodeproj/project.pbxproj
  38. +31 −7 samples/PlacePickerSample/PlacePickerSample/PPViewController.m
  39. +8 −2 samples/ProfilePictureSample/ProfilePictureSample.xcodeproj/project.pbxproj
  40. +3 −4 samples/ProfilePictureSample/ProfilePictureSample/PPAppDelegate.m
  41. +14 −110 samples/ProfilePictureSample/ProfilePictureSample/en.lproj/PPViewController_iPad.xib
  42. +12 −7 samples/Scrumptious/ReadMe.txt
  43. +12 −2 samples/Scrumptious/Scrumptious.xcodeproj/project.pbxproj
  44. +9 −9 samples/Scrumptious/scrumptious/SCAppDelegate.h
  45. +77 −161 samples/Scrumptious/scrumptious/SCAppDelegate.m
  46. +6 −10 samples/Scrumptious/scrumptious/SCLoginViewController.h
  47. +77 −33 samples/Scrumptious/scrumptious/SCLoginViewController.m
  48. +27 −139 samples/Scrumptious/scrumptious/SCLoginViewController.xib
  49. +0 −2 samples/Scrumptious/scrumptious/SCProtocols.h
  50. +5 −7 samples/Scrumptious/scrumptious/SCViewController.h
  51. +212 −194 samples/Scrumptious/scrumptious/SCViewController.m
  52. +8 −2 samples/SessionLoginSample/SessionLoginSample.xcodeproj/project.pbxproj
  53. +1 −1 samples/SessionLoginSample/SessionLoginSample/SLViewController.m
  54. +2 −0 samples/SwitchUserSample/SwitchUserSample.xcodeproj/project.pbxproj
  55. +1 −1 samples/SwitchUserSample/SwitchUserSample/SUUserManager.m
  56. +7 −3 scripts/build_distribution.sh
  57. +1 −1 scripts/build_documentation.sh
  58. +2 −1 scripts/build_framework.sh
  59. +1 −1 scripts/build_samples.sh
  60. +0 −127 scripts/build_scrumptious_distribution.sh
  61. +1 −1 scripts/common.sh
  62. +7 −32 scripts/configure_simulator_for_unit_tests.sh
  63. +32 −0 src/FBAccessTokenData+Internal.h
  64. +115 −0 src/FBAccessTokenData.h
  65. +209 −0 src/FBAccessTokenData.m
  66. +2 −1 src/FBDataDiskCache.m
  67. +169 −18 src/FBError.h
  68. +11 −0 src/FBError.m
  69. +46 −0 src/FBErrorUtility.h
  70. +267 −0 src/FBErrorUtility.m
  71. +26 −0 src/FBFetchedAppSettings.h
  72. +25 −0 src/FBFetchedAppSettings.m
  73. +16 −1 src/FBFriendPickerViewController.m
  74. +5 −2 src/FBGraphObjectPagingLoader.m
  75. +2 −0 src/FBGraphObjectTableCell.m
  76. +1 −1 src/FBGraphObjectTableDataSource.m
  77. +19 −9 src/FBGraphObjectTableSelection.m
  78. +56 −0 src/FBInsights+Internal.h
  79. +271 −0 src/FBInsights.h
  80. +1,137 −0 src/FBInsights.m
  81. +4 −2 src/FBLogger.m
  82. +20 −2 src/FBLoginView.h
  83. +95 −28 src/FBLoginView.m
  84. +33 −8 src/FBNativeDialogs.m
  85. +10 −0 src/FBPlacePickerViewController.h
  86. +25 −10 src/FBPlacePickerViewController.m
  87. +2 −1 src/FBRequest.m
  88. +177 −91 src/FBRequestConnection.m
  89. +2 −2 src/FBSDKVersion.h
  90. +12 −2 src/FBSession+Internal.h
  91. +8 −4 src/FBSession+Protected.h
  92. +152 −19 src/FBSession.h
  93. +503 −499 src/FBSession.m
  94. +38 −0 src/FBSessionInsightsState.h
  95. +114 −0 src/FBSessionInsightsState.m
  96. +33 −2 src/FBSessionTokenCachingStrategy.h
  97. +49 −1 src/FBSessionTokenCachingStrategy.m
  98. +59 −7 src/FBSettings.h
  99. +141 −58 src/FBSettings.m
  100. +85 −0 src/FBSystemAccountStoreAdapter.h
  101. +286 −0 src/FBSystemAccountStoreAdapter.m
  102. +47 −41 src/FBTestSession.m
  103. +16 −30 src/FBURLConnection.m
  104. +2 −0 src/FBUserSettingsViewController.h
  105. +59 −17 src/FBUserSettingsViewController.m
  106. BIN src/FBUserSettingsViewResources.bundle/images/loginBackgroundIPadLandscape.jpg
  107. BIN src/FBUserSettingsViewResources.bundle/images/loginBackgroundIPadLandscape@2x.jpg
  108. BIN src/FBUserSettingsViewResources.bundle/images/loginBackgroundIPadPortrait.jpg
  109. BIN src/FBUserSettingsViewResources.bundle/images/loginBackgroundIPadPortrait@2x.jpg
  110. BIN src/FBUserSettingsViewResources.bundle/images/loginBackgroundIPhonePortrait.jpg
  111. BIN src/FBUserSettingsViewResources.bundle/images/loginBackgroundIPhonePortrait@2x.jpg
  112. +23 −4 src/FBUtility.h
  113. +153 −0 src/FBUtility.m
  114. +2 −0 src/FBViewController+Internal.h
  115. +1 −6 src/FBViewController.h
  116. +37 −10 src/FBViewController.m
  117. +110 −0 src/FBWebDialogs.h
  118. +212 −0 src/FBWebDialogs.m
  119. +5 −7 src/Facebook.m
  120. +5 −8 src/FacebookSDK.h
  121. BIN src/FacebookSDKResources.bundle/Contents/Resources/en.lproj/Localizable.strings
  122. BIN src/FacebookSDKResources.bundle/Contents/Resources/he.lproj/Localizable.strings
  123. BIN src/FacebookSDKResources.bundle/FBProfilePictureView/images/fb_blank_profile_portrait.png
  124. BIN src/FacebookSDKResources.bundle/FBProfilePictureView/images/fb_blank_profile_square.png
  125. +59 −0 src/NSError+FBError.h
  126. +71 −0 src/NSError+FBError.m
  127. +104 −8 src/facebook-ios-sdk.xcodeproj/project.pbxproj
  128. +32 −5 src/facebook-ios-sdk.xcodeproj/xcshareddata/xcschemes/facebook-ios-sdk-tests.xcscheme
  129. +33 −5 src/facebook-ios-sdk.xcodeproj/xcshareddata/xcschemes/facebook-ios-sdk.xcscheme
  130. +22 −0 src/tests/FBAccessTokenDataTests.h
  131. +358 −0 src/tests/FBAccessTokenDataTests.m
  132. +3 −3 src/tests/FBCommonRequestTests.m
  133. +3 −2 src/tests/FBGraphObjectTests.m
  134. +20 −0 src/tests/FBRequestConnectionTests.m
  135. +1 −0 src/tests/FBSessionTests.h
  136. +76 −0 src/tests/FBSessionTests.m
  137. +2 −1 src/tests/FBTestSessionTests.m
  138. +1 −0 src/tests/FBTests.h
  139. +18 −0 src/tests/FacebookSDKTests.xcconfig
View
@@ -1,5 +0,0 @@
-{
- "project_id" : "facebook-ios-sdk",
- "conduit_uri" : "https://phabricator.fb.com/api/",
- "copyright_holder" : "Facebook"
-}
View
@@ -17,3 +17,6 @@ test/UnitTest/build/
project.xcworkspace
xcuserdata
.arc
+.arcconfig
+.internal/
+TestAppIdAndSecret.xcconfig
@@ -359,7 +359,10 @@
GCC_PREFIX_HEADER = "BooleanOGSample/BooleanOGSample-Prefix.pch";
INFOPLIST_FILE = "BooleanOGSample/BooleanOGSample-Info.plist";
IPHONEOS_DEPLOYMENT_TARGET = 4.3;
- OTHER_LDFLAGS = "-lsqlite3.0";
+ OTHER_LDFLAGS = (
+ "-lsqlite3.0",
+ "-ObjC",
+ );
PRODUCT_NAME = "$(TARGET_NAME)";
WRAPPER_EXTENSION = app;
};
@@ -376,7 +379,10 @@
GCC_PREFIX_HEADER = "BooleanOGSample/BooleanOGSample-Prefix.pch";
INFOPLIST_FILE = "BooleanOGSample/BooleanOGSample-Info.plist";
IPHONEOS_DEPLOYMENT_TARGET = 4.3;
- OTHER_LDFLAGS = "-lsqlite3.0";
+ OTHER_LDFLAGS = (
+ "-lsqlite3.0",
+ "-ObjC",
+ );
PRODUCT_NAME = "$(TARGET_NAME)";
WRAPPER_EXTENSION = app;
};
@@ -151,9 +151,9 @@ - (void)postAction:(NSString *)actionPath
// if we don't have permission to post, let's first address that
if ([FBSession.activeSession.permissions indexOfObject:@"publish_actions"] == NSNotFound) {
- [FBSession.activeSession reauthorizeWithPublishPermissions:[NSArray arrayWithObject:@"publish_actions"]
- defaultAudience:FBSessionDefaultAudienceFriends
- completionHandler:^(FBSession *session, NSError *error) {
+ [FBSession.activeSession requestNewPublishPermissions:@[@"publish_actions"]
+ defaultAudience:FBSessionDefaultAudienceFriends
+ completionHandler:^(FBSession *session, NSError *error) {
if (!error) {
// re-call assuming we now have the permission
[self postAction:actionPath
@@ -186,43 +186,27 @@ - (void)postAction:(NSString *)actionPath
// a more complex application may want to store or perform addtional actions
// with the id that represents the just-posted action
} else {
- // get the basic error message
- NSString *message = error.localizedDescription;
-
- // see if we can improve on it with an error message from the server
- id json = [error.userInfo objectForKey:FBErrorParsedJSONResponseKey];
- id facebookError = nil;
- NSDecimalNumber *code = nil;
- if ([json isKindOfClass:[NSDictionary class]] &&
- (json = [json objectForKey:@"body"]) &&
- [json isKindOfClass:[NSDictionary class]] &&
- (facebookError = [json objectForKey:@"error"]) &&
- [facebookError isKindOfClass:[NSDictionary class]] &&
- (json = [facebookError objectForKey:@"message"])) {
- message = [json description];
- code = [facebookError objectForKey:@"code"];
- }
-
- if ([code intValue] == 200 && tryReauthIfNeeded) {
+ // See the Scrumptious sample for further error handling tips.
+ // In this sample, we will simply retry permission errors.
+ if (error.fberrorCategory == FBErrorCategoryPermissions && tryReauthIfNeeded) {
// We got an error indicating a permission is missing. This could happen if the user has gone into
// their Facebook settings and explictly removed a permission they had previously granted. Try reauthorizing
// again to get the permission back.
- [FBSession.activeSession reauthorizeWithPermissions:[NSArray arrayWithObject:@"publish_actions"]
- behavior:FBSessionLoginBehaviorWithFallbackToWebView
- completionHandler:^(FBSession *session, NSError *error) {
- if (!error) {
- // re-call assuming we now have the permission
- [self postAction:actionPath
- leftOperand:left
- rightOperand:right
- result:result
- tryReauthIfNeeded:NO];
- }
- }];
+ [FBSession.activeSession requestNewPublishPermissions:@[@"publish_actions"]
+ defaultAudience:FBSessionDefaultAudienceFriends
+ completionHandler:^(FBSession *session, NSError *error) {
+ if (!error) {
+ // re-call assuming we now have the permission
+ [self postAction:actionPath
+ leftOperand:left
+ rightOperand:right
+ result:result
+ tryReauthIfNeeded:NO];
+ }
+ }];
} else {
- // display the message that we have
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"OG Post Failed"
- message:message
+ message:error.fberrorUserMessage ?: @"Unknown error"
delegate:nil
cancelButtonTitle:@"OK"
otherButtonTitles:nil];
@@ -21,4 +21,8 @@
@property (strong, nonatomic) IBOutlet UITextView *activityTextView;
+@property (unsafe_unretained, nonatomic) IBOutlet UIButton *inviteButton;
+
+- (IBAction)clickInviteFriends:(id)sender;
+
@end
@@ -47,7 +47,10 @@ - (void)viewDidAppear:(BOOL)animated {
if (FBSession.activeSession.isOpen) {
[self loadData];
+ self.inviteButton.enabled = YES;
} else {
+ self.inviteButton.enabled = NO;
+
// display the message that we have
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Social Features Disabled"
message:@"There is no open session with Facebook. Use the Facebook Settings "
@@ -62,6 +65,7 @@ - (void)viewDidAppear:(BOOL)animated {
- (void)viewDidUnload {
self.activityTextView = nil;
+ [self setInviteButton:nil];
[super viewDidUnload];
}
@@ -178,4 +182,12 @@ - (void)updateActivityForID:(NSString *)fbid {
[connection start];
}
+- (IBAction)clickInviteFriends:(id)sender {
+ [FBWebDialogs presentRequestsDialogModallyWithSession:nil
+ message:@"Please come rock the logic with me!"
+ title:@"Invite a Friend"
+ parameters:nil
+ handler:nil];
+}
+
@end
@@ -62,8 +62,6 @@
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
- <string>UIInterfaceOrientationLandscapeLeft</string>
- <string>UIInterfaceOrientationLandscapeRight</string>
</array>
<key>UISupportedInterfaceOrientations~ipad</key>
<array>
Oops, something went wrong.

0 comments on commit 76b75a4

Please sign in to comment.