Game Development Reference
In-Depth Information
associated with each device. So, we just grab the last (and only) account and assign it to
facebookAccount , which is an ACAccount object, defined in the header (source not show).
If this is the first time we have called requestAccessToAccountsWithType:options:completion: , then
the user will be prompted with a dialog like the one shown in Figure 9-14 .
Figure 9-14. User Being Asked to Grant Permission
If the user touches the OK button in Figure 9-14 , the application has permission to make posts on
their behalf. Next, let's take a look at how Belt Commander uses this permission to make those
posts.
Making Posts to Facebook
We just explored how an application requests permission to make Facebook posts. In Belt
Commander, we are going to make a Facebook post whenever a player's game is over, reporting the
score. We do this in the task reportToFacebook , as shown in Listing 9-8.
Listing 9-8. notifyFacebook (RootViewController.m)
-(void)notifyFacebook{
if (facebookAccount){
NSString* desc = [NSString stringWithFormat:@"I just scored %ld points
on Belt Commander.", [beltCommanderController score]];
NSDictionary* params = @{
@"link": @" http://itunes.apple.com/us/app/belt-commander/id460769032 " ,
@"caption": @"Presented by ClayWare Games, LLC",
@"description": desc,
@"message": @"A new high score!"
};
NSURL* feedURL = [NSURL URLWithString:@" https://graph.facebook.com/me/feed "];
 
Search WWH ::




Custom Search