Skip to content

Commit

Permalink
Addresses a few issues for hotfix
Browse files Browse the repository at this point in the history
Summary:
Issues addressed here are -
* Fix to FBGraphUser
* Removal of date handling on post, and relevant fix to unit tests
* Sample fix to use modern permission
* Nil of delegate in Facebook.m

Test Plan: Ran related unit tests and samples

Reviewers: clang, karthiks, ayden, gregschechte

Reviewed By: clang

CC: msdkexp@, platform-diffs@lists

Differential Revision: https://phabricator.fb.com/D551794

Task ID: 1382325
  • Loading branch information
Jason Clark committed Aug 21, 2012
1 parent a54ef24 commit 01e476b
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 27 deletions.
Expand Up @@ -57,7 +57,7 @@ - (void)viewDidLoad {

// Create Login View so that the app will be granted "status_update" permission.
FBLoginView *loginview =
[[FBLoginView alloc] initWithPermissions:[NSArray arrayWithObject:@"status_update"]];
[[FBLoginView alloc] initWithPermissions:[NSArray arrayWithObject:@"publish_actions"]];

loginview.frame = CGRectOffset(loginview.frame, 5, 5);
loginview.delegate = self;
Expand Down
4 changes: 2 additions & 2 deletions src/FBGraphUser.h
Expand Up @@ -15,7 +15,7 @@
*/

#import <Foundation/Foundation.h>
#import "FBGraphLocation.h"
#import "FBGraphPlace.h"
#import "FBGraphObject.h"

/*!
Expand Down Expand Up @@ -85,6 +85,6 @@
@property
@abstract Typed access to the user's current city.
*/
@property (retain, nonatomic) id<FBGraphLocation> location;
@property (retain, nonatomic) id<FBGraphPlace> location;

@end
11 changes: 0 additions & 11 deletions src/FBRequestConnection.m
Expand Up @@ -864,17 +864,6 @@ + (void)processGraphObjectPropertyKey:(NSString*)key
[value isKindOfClass:[NSNumber class]]) {
// Just serialize these.
action(key, value);
} else if ([value isKindOfClass:[NSDate class]]) {
// The "Events Timezone" platform migration affects what date/time formats Facebook accepts and returns.
// Apps created after 8/1/12 (or apps that have explicitly enabled the migration) should send/receive
// dates in ISO-8601 format. Pre-migration apps can send as Unix timestamps. Since the future is ISO-8601,
// that is what we support here. Apps that need pre-migration behavior can explicitly send these as
// integer timestamps rather than NSDates.
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateFormat:@"yyyy-MM-dd'T'HH:mm:ssZ"];

value = [dateFormatter stringFromDate:value];
action(key, value);
} else if ([value isKindOfClass:[NSArray class]]) {
// Arrays are serialized as multiple elements with keys of the
// form key[0], key[1], etc.
Expand Down
14 changes: 3 additions & 11 deletions src/FBSettings.m
Expand Up @@ -36,14 +36,6 @@

NSTimeInterval const FBPublishDelay = 0.1;

@protocol FBActivity<FBGraphObject>

@property (retain, nonatomic) NSString *event;
@property (retain, nonatomic) NSString *attribution;

@end


@implementation FBSettings

static NSSet *g_loggingBehavior;
Expand Down Expand Up @@ -120,9 +112,9 @@ + (void)publishInstall:(NSString *)appID {
[[result objectForKey:FBSupportsAttribution] boolValue]) {
// set up the HTTP POST to publish the attribution ID.
NSString *publishPath = [NSString stringWithFormat:FBPublishActivityPath, appID, nil];
id<FBActivity> installActivity = (id<FBActivity>)[FBGraphObject graphObject];
installActivity.event = FBMobileInstallEvent;
installActivity.attribution = attributionID;
NSMutableDictionary<FBGraphObject> *installActivity = [FBGraphObject graphObject];
[installActivity setObject:FBMobileInstallEvent forKey:@"event"];
[installActivity setObject:attributionID forKey:@"attribution"];

FBRequest *publishRequest = [[[FBRequest alloc] initForPostWithSession:nil graphPath:publishPath graphObject:installActivity] autorelease];
[publishRequest startWithCompletionHandler:publishCompletionBlock];
Expand Down
1 change: 1 addition & 0 deletions src/Facebook.m
Expand Up @@ -150,6 +150,7 @@ - (void)dealloc {
}
[_lastAccessTokenUpdate release];
[_requests release];
_fbDialog.delegate = nil;
[_fbDialog release];
[_appId release];
[_urlSchemeSuffix release];
Expand Down
27 changes: 25 additions & 2 deletions src/tests/FBGraphObjectTests.m
Expand Up @@ -158,6 +158,19 @@ - (void)testGraphObjectTypedRequest
[blocker wait];
}

- (void)testGraphObjectTypedRequest2
{
FBTestBlocker *blocker = [[[FBTestBlocker alloc] init] autorelease];
[FBRequestConnection startWithGraphPath:@"4" // Zuck
completionHandler:^(FBRequestConnection *connection, id<FBGraphUser> zuck, NSError *error) {
STAssertTrue([zuck.first_name isEqualToString:@"Mark"], @"zuck != zuck");
STAssertTrue([zuck.last_name isEqualToString:@"Zuckerberg"], @"zuck != zuck");
[blocker signal];
}];

[blocker wait];
}

- (void)testGraphObjectSameID
{
NSString *anID = @"1234567890";
Expand Down Expand Up @@ -315,12 +328,22 @@ - (void)testCommentRoundTrip
- (id)postEvent
{
id<FBGraphObject> event = [FBGraphObject graphObject];
NSDate *startTime = [NSDate dateWithTimeIntervalSinceNow:24 * 3600];

// The "Events Timezone" platform migration affects what date/time formats Facebook accepts and returns.
// Apps created after 8/1/12 (or apps that have explicitly enabled the migration) should send/receive
// dates in ISO-8601 format. Pre-migration apps can send as Unix timestamps. Since the future is ISO-8601,
// that is what we support here. Apps that need pre-migration behavior can explicitly send these as
// integer timestamps rather than NSDates.
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateFormat:@"yyyy-MM-dd'T'HH:mm:ssZ"];
id startTime = [NSDate dateWithTimeIntervalSinceNow:24 * 3600];
id endTime = [dateFormatter stringFromDate:[NSDate dateWithTimeInterval:3600 sinceDate:startTime]];
startTime = [dateFormatter stringFromDate:startTime];

[event setObject:[NSString stringWithFormat:@"My event on %@", startTime]
forKey:@"name"];
[event setObject:@"This is a great event. You should all come."
forKey:@"description"];
NSDate *endTime = [NSDate dateWithTimeInterval:3600 sinceDate:startTime];
[event setObject:startTime forKey:@"start_time"];
[event setObject:endTime forKey:@"end_time"];
[event setObject:@"My house" forKey:@"location"];
Expand Down

0 comments on commit 01e476b

Please sign in to comment.