Skip to content

Commit

Permalink
Merge upstream
Browse files Browse the repository at this point in the history
  • Loading branch information
alexchugunov committed Mar 14, 2013
2 parents 15cf8d3 + 76b75a4 commit bb4ab97
Show file tree
Hide file tree
Showing 139 changed files with 6,811 additions and 2,104 deletions.
5 changes: 0 additions & 5 deletions .arcconfig

This file was deleted.

3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,6 @@ test/UnitTest/build/
project.xcworkspace
xcuserdata
.arc
.arcconfig
.internal/
TestAppIdAndSecret.xcconfig
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};
Expand All @@ -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;
};
Expand Down
54 changes: 19 additions & 35 deletions samples/BooleanOGSample/BooleanOGSample/BOGFirstViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,8 @@

@property (strong, nonatomic) IBOutlet UITextView *activityTextView;

@property (unsafe_unretained, nonatomic) IBOutlet UIButton *inviteButton;

- (IBAction)clickInviteFriends:(id)sender;

@end
12 changes: 12 additions & 0 deletions samples/BooleanOGSample/BooleanOGSample/BOGSecondViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -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 "
Expand All @@ -62,6 +65,7 @@ - (void)viewDidAppear:(BOOL)animated {
- (void)viewDidUnload {
self.activityTextView = nil;

[self setInviteButton:nil];
[super viewDidUnload];
}

Expand Down Expand Up @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,6 @@
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
<key>UISupportedInterfaceOrientations~ipad</key>
<array>
Expand Down
Loading

0 comments on commit bb4ab97

Please sign in to comment.