Game Development Reference
In-Depth Information
we get a reference to a GKAchievement by passing the achievement's ID (as defined in iTunes
Connect) to the initWithIdentifier task of GKAchievement . Once we have a reference, we simply
assign 100 to the property percentComplete , call reportAchievementWithCompletionHander , and we
are done.
There are a few things to note about achievements. First, as shown in Listing 9-5, achievements can
be partially complete. We could have set percentComplete to 30 or 50. This is an important feature
for long-running achievements. Say, for example, our achievement was to destroy 10,000 asteroids.
We would want to let users know how far they have progressed to date or they may not pursue
it further.
Another thing to note about achievements is that each has a value. Our achievement is worth
5 points, as shown in Figure 9-11 . The value of an achievement can be whatever the developer
Twitter Integration
Love it or hate it, Twitter exists. As a mobile application developer, you need to be aware that it is
more and more common for clients to ask for social media integration in their apps. On the short
list of everyone's social services is Twitter. Twitter provides a very nice and useful REST service that
can be used to tweet on behalf of a user. New to iOS 6 is the Social Framework. This framework
extends and replaces the Twitter API from iOS 5. The Social Framework allows a user to do a sort
of single sign-on with their Twitter or Facebook account, making it simple for application developers
to request access to this global account. This feature is great for users, because they have to
authenticate only once with the device, and they still have control over which applications are
allowed to tweet for them.
This feature is also great for developers. It makes tweeting really, really easy. If you have ever worked
with any OAuth service on an embedded device, you know there is a bit of a disconnect between
how OAuth works and how native applications operate. In short, OAuth was designed to work within
a browser, and our application was not written on HTML. One solution was to pop up a UIWebView
and do the authentication through it. This works, but it is clumsy. This new approach is much better.
Not only does this new Twitter API provide a simple way to authenticate, it also has a simple
component where users can enter their tweets, as shown in Figure 9-12 .
 
Search WWH ::




Custom Search