OpenFeint, Game Center Integration Tips for iOS

I have been adding OpenFeint Achievements (with Game Center integration) to my game, Pawns! for iOS. Here is a collection of time-saving tips that I wish I’d had to start with, particularly the Troubleshooting section. I include links to documents and forum posts that gave me useful answers.

Some of this information is specific to games made with Unity, but most isn’t. Some details may change when new versions of the OpenFeint SDK are released.

General Resources

OpenFeint’s developer website is a little disorganized, in my humble opinion. (For example, the developer forums are not listed in the main menu of the Developer Support page; they are mentioned in an announcement further down the page. ) Here are the main links developers need:

OpenFeint Developer Support: http://openfeint.com/ofdeveloper
OpenFeint Developer Forums: http://openfeint.com/developers/forum/
OpenFeint Developer Dashboard: https://api.openfeint.com/dd

Plus there are the usual Unity resources: answers.unity.com, the Unity forums (more active than OpenFeint’s), and this humble blog. 🙂

Setting up OpenFeint in Unity

° The instructions in the UnitySupport folder in the OpenFeint SDK covers most of what you need to know.

° As instructed I added the file openfeint_offline_config.xml to the Unity editor directory “Offline Config File Goes Here“. However, it didn’t copy automatically into my Xcode project so I had to add it manually. OpenFeint’s documentation does not tell you exactly where to put it. Inside the Xcode project folder OpenFeint/resources works, though it’s possible other places work as well. (Source: http://openfeint.com/developers/forum/showthread.php?89-Offline-Mode-Setup)

Achievements and Offline Mode

OpenFeint supports offline Achievements. After the first successful OpenFeint login and connection to the network, the player can view OpenFeint’s Achievements dashboard even if the device is offline. Achievements earned offline will be synchronized with OpenFeint’s servers later. But users who refuse OpenFeint in the first place cannot see the list.

Because of this I decided to implement my own Achievements page, as well as my own notification at the end of each level when they’ve earned one or more Achievements. It was more work than relying on OpenFeint’s dashboard and notifications, but it’s nice to know that even players who don’t use OpenFeint will be able to see their achievements.

Adding Game Center

° OpenFeint’s instructions for adding Game Center can be found in the Developer Support knowledge base. Currently the document is here: http://www.openfeint.com/ofdeveloper/index.php/kb/article/000089 It’s essential reading (it doesn’t cover Unity specifics, though.)

° As of OpenFeint 2.7.5, the Unity Editor plugin does not give access to the setting that turns on Game Center integration. For now you’ll have to go into the Xcode project and add it to the OpenFeint initialization settings manually, exactly as explained in the instructions. (Currently the code to change is in the file classes/AppController+OpenFeint.mm.)

° The instructions state to add your “OFGameCenter.plist” file to your Xcode project, but as usual they don’t suggest where. Put it in the folder OpenFeint/resources.

° Some versions of the instructions call the file “OFGame Center.plist”, but the filename should NOT have a space in it. (Thank you, Pete Royle for posting this tip in the comments!)

° Note that when you define your Game Center achievements with Apple’s dashboard, there’s nothing stopping you from reusing the OpenFeint Achievement ids. This makes your plist mapping even simpler:

    <?xml version=“1.0” encoding=“UTF-8”?>
    <!DOCTYPE plist PUBLIC “-//Apple//DTD PLIST 1.0//EN” “http://www.apple.com/DTDs/PropertyList-1.0.dtd”>
    <plist version=“1.0”>
    <dict>
          <key>Achievements</key>
          <dict>
                <key>677092</key>
                  <string>677092</string>
                <key>718142</key>
                  <string>718142</string>

                <-- etc. -->

          </dict>
    </dict>
    </plist>

° For comparison, here is an achievement image I uploaded to iTunes Connect, followed by the version Game Center presents it to the player. Keep the final appearance in mind when designing your achievement icons (e.g. keep away from the borders.)

Achievement icon as uploaded to iTunes Connect


Achievement as displayed by Game Center

Testing OpenFeint and Game Center

° Before testing your OpenFeint features, go to your OpenFeint developer dashboard and register the OpenFeint user you’ll use for testing. I used my regular OpenFeint user for this, or you could create a new account beforehand using any OpenFeint-enabled app.

If you have beta-testers you’ll unfortunately need the email and password of each of their logins, and your beta testers may not wish to share their passwords with you. So you will either have to create new email accounts and associated OpenFeint users for the testers to use, or ask them to create new test accounts first and send you the particulars.

° Apple recommends you do not use your real Game Center user for testing. To set up a new test account, simply run Game Center on your iOS device, and use it to log your regular account out before you start to test. This tells Game Center to prompt you to login (or create a new user) when it starts up in your game.

° When your app is first run, OpenFeint will let you pick from a list of existing users on the device (if any) or allow you to type a new one. If your test user wasn’t already active on this device you will need to link this new profile to the test user’s account. Do this in OpenFeint’s in-game dashboard: open the user profile and give the test user’s email address and password.

Once that’s done OpenFeint should then attempt to connect to Game Center. Since you logged out from Game Center beforehand it will prompt you to login. This is where you can create a new Game Center user.

° Don’t forget to also test the offline mode. After a successful OpenFeint test, try running the app again with no network connection, and try out the OpenFeint buttons.

Troubleshooting

° If OpenFeint doesn’t mention Game Center at all at startup, double-check that you properly enabled Game Center in OpenFeint’s initialization settings.

° If you get an error that “This game is not recognized by Game Center”, try deleting your app off the device and let Xcode reinstall it from scratch. (Source: http://www.cocos2d-iphone.org/forum/topic/10528)

° When testing offline mode, if you get an error that says that offline mode was not enabled, check that an up-to-date copy of your openfeint_offline_config.xml is in your Xcode project, inside the OpenFeint/resources folder.

° OpenFeint not posting to Facebook and Twitter: this is normal when testing with an app that hasn’t yet been released. Once it is submitted to OpenFeint (to let them know the version with OpenFeint has been submitted to Apple) they’ll turn on the social media links. (Source: http://openfeint.com/developers/forum/showthread.php?273-Can-t-able-to-see-published-event-in-facebook-after-submission-got-succeded&highlight=twitter)

° I had a problem with OpenFeint 2.7.5 notifications never showing when an Achievement was unlocked. I posted a solution for this last month.
http://www.mindthecube.com/blog/2010/11/openfeint-2-7-5-not-notifying-of-achievement
Alternatively, see the section “Achievements and Offline Mode” above for reasons to write your own notifications instead.

* If OpenFeint is working but there is no Achievements dashboard for your game, or some achievements are missing, make sure your game’s bundle version is set high enough. For example, you may have configured your OpenFeint achievements to be visible with version 1.1 or higher. (In Unity, the version is set in the project’s Player settings before rebuilding the XCode project. Non-Unity developers would update directly the Bundle Version in their game’s Info.plist file.)

If the achievements still aren’t visible, then make sure you registered the test user in OpenFeint’s Developer Dashboard. Also double-check that you added the test user’s email and password on the player dashboard on the device.

Conclusion

Adding OpenFeint and Game Center wasn’t difficult, but there was some trial and error, a couple of gotchas, and I had to do a bit of searching for some of the answers. Hopefully these tips will smooth the way for others, and for myself when I start working on my next game.

11 thoughts on “OpenFeint, Game Center Integration Tips for iOS

  1. LanceT

    Just wanted to say that I love your posts. I’ve been working on a game for the iPhone using Unity3D for a little while now and found your site as great resource for information. Definitely please keep up the great work!

    This talk about OpenFeint and Game Center has me wondering though. I know that OpenFeint came before Game Center, but aren’t they now filling similar roles? What is the advantage of having them both in an app together? Is it to fill an area that both one lacks of the other?

    Thanks again!

  2. Matt Post author

    Thank you for the kind words!

    Good question- it’s something I’ve wrestled with myself. Here’s my thinking. If all you want are features like leaderboards or achievements, then one or the other is good enough. But if the purpose is to get more eyeballs to your game, then there are advantages to supporting both:
    1) Apple may be more likely to feature you if you support GC. GC icon shows up next to your game in the App Store.
    2) OpenFeint has a large user-base, and tools to market your game to them.
    3) You’ll show up on more friends’ lists.

    Of the two services, OpenFeint is the more mature from a marketing point of view. They offer ways to promote your game within their network, such as free-for-a-day, in-game banners, stuff like that. GC’s adoption has been slow. So I think OF offers more bang for the buck at this time. But GC isn’t going away, it’s preinstalled with iOS 4.2, and I suspect Apple will expand it’s features, maybe hook it into the Mac App Store. And OpenFeint, rather than locking devs into their own service, is heavily pushing developers to support both- they’ve said that GC support is needed “if you want to be featured” (I’m not sure yet if they meant by themselves or by Apple.) That might just be an attempt by them to stay relevant as GC rolls over the competition.

    Short answer: in 6 months who knows? But at this moment in time supporting both is probably the right thing to do, and OpenFeint does a lot of the heavy lifting for you. (In fact the other options for adding GC to a Unity game are either a lot of work or cost money.)

  3. Curious

    Hmm, a very nice post, thank you Matt, I just found your post yesterday and thought it was a very nice material 😉

    I have a question though! Does this method make it possible to post on OF and GC at the same time? Is this enough? I mean, I just have to do my usual things and then this bridge will post them on GC as well or not?

  4. piyushnp

    Hi,
    I have been reading through several docs on OpenFeint Support site & Other resources on the web to learn how to integrate OpenFeint with UNITY3D.
    But unfortunately there is nothing i found useful to Start with.
    I have no clue how do i start with OpenFeint in Unity3d.
    Can you please help me out. It would be great help.. thanks 🙂

  5. Matt Post author

    Once you have downloaded the OpenFeint SDK, look for a UnitySupport folder inside. There is a README file inside that walks you through how to add OpenFeint to a Unity iPhone project.

    That should be enough to get you the OpenFeint login when you run your game. Step 2 you should add OpenFeint buttons to your game- usually you should have one on the main menu, and another when your game is paused. The SDK comes with a folder “Developer Assets” which has textures you can use for the buttons. Pressing these buttons should call:

    OpenFeint.LaunchDashboard();

    Step 3: Add leaderboard or achievements. See the SDK file OpenFeint-Unity-Documentation. It has examples near the end. You can search the Unity forums to see what examples other people have posted.

    My article above is intended to fill in some gaps in the documentation, and solve problems that I ran into as I did these three steps.

  6. Matt Post author

    Wish I could help but I haven’t done leaderboards yet. My next game will probably have them, but that’ll come too late to help you I’m afraid. Until then, all I can say is, doublecheck the basics: that the feature is turned on in the OpenFeint developer portal, and that you are sending the correct leaderboard id.

    They have had server issues over the last month, so there’s a small chance the problem is on their end. You can keep an eye on the OF forums and twitter to see if other people are reporting problems as well.

  7. Pete Royle

    Hi,

    First, thanks for this post, it helped me a lot in adding GC support to my OF game.

    I also just wanted to point out that the filename “OFGame Center.plist” is incorrect in the OF documentation, it should not have a space in it. It should be “OFGameCenter.plist”. Both versions appear in the OF documentation and unluckily for you, you seem to have copied the wrong one over to your post 🙂

    It took me longer to track down and fix this bug than it originally took me to integrate OF in the first place! I have notified OF of the error.

    Thanks again for the great posts (I also found the one about Achievement Notifications very useful)!

  8. Matt Post author

    I corrected the filename in the post, and added a couple sentences about the name being wrong in some versions of the documentation. Great tip; thanks!

  9. Pingback: Why I’m Removing OpenFeint From My Unity Game | MindTheCube

Leave a Reply

Your email address will not be published. Required fields are marked *