How to add GREE to your iOS game

[box type=”info”] Edit: I’ve created another writeup on integrating GREE with cocos2d , read it here ![/box]

Hey Geeks !

So , if you’re a game developer, you’ve probably heard the news, GREE is out, OpenFeint is dead,  you went to get started, and found out it has worse documentation than OpenFeint and probably couldn’t compile it !

I took the time to play around with it, and this is a little writeup on how I registered the test app on the developer panel, and compiled the test app and made it work.

NOTE: If this post gets enough attention, I’ll also show you how to integrate it with Cocos2d and add leaderboards/achievements to your Cocos2d game and migrate from OpenFeint AND show you how it works with GameCenter, just let me know in the comments, I’ll also include a downloadable project for your convenience 🙂

So, let’s begin, you’ll need to have the following before starting

  • XCode 4.2 or above
  • iOS 4.0 or above (GREE won’t work on devices below 4.0, BOO…)
  • The iOS SDK
  • A developer account on GREE
So, start by logging in the developer Center
  • Head to the SandBox tab, and click on Test Application and add a new app.
  • Choose iOS SDK, since we’re building an iOS app 🙂
  • Next step is to choose the default languages, select English (US), then click Next
  • You can Ignore the Gadget.xml part (this is used when you want to log game lifecycle events)
  • Select (again) English as the default language
  • Choose App name (I used MyAmazingGame), if yours isn’t amazing, just call it (MyGame)
  • Congrats, your test app is now added, you’ll be taken back to a table that shows your current apps, yours should be there now
  • Click the (Detail) button next to your app then Copy the “AppId”, “Consumer key” and “Consumer secret” and put them in a text file or something, we’ll need that later.
  • Now you’ll need to create at least one test account (Not required though, but I strongly recommend it to be able to test all GREE’s features!).
  • Head again to the Sandbox tab, and click “Test Accounts”
  • Go ahead, Add a new user
  • Fill in the user’s data (any bogus email and username/password will do) then register !
  • But Wait, The user isn’t active yet, you need to click on the link where it says “Click here to complete the account”, Don’t even ask me why, they require that step to be a pain in the ass i guess !
  • You’ll get a light window with an ugly link in it, click that link (in a new window/tab)
  • Congrats, your test account has now been verified to be a … fake one?? who cares !
  • Go back the test accounts page and make sure your user was registered, it should look like this
  • (Optional) you can add a leader board since you’r here already to give us something to tinker with !
  • Back to your sandbox app list, click your app and scroll down, Click on Add next to LeaderBoard
  • Click on Register LeaderBoard
  • Leave default settings unless you need something different.
  • Choose a name for your new leader board, also choose the type of scores it’ll be holding under Score Format, add something like “Seconds”, “Stars”, “Coins”, “Points”, etc..
  • Add a language to your leader board (English ?)
  • Now submit, and enjoy the job you’ve done so far !
Awesome, now you’ve done the most annoying part, now you can close the website and open the XCode Example project, it’s located in the
SDK’s Applications folder.
<pre>File Location: GREEPlatformiOSSDK-3.0.0-en/applications/showcase/GreePlatformShowcase.xcodeproj</pre>
Now Xcode is loaded and running, let’s start modifying the basic settings:
Open up AppDelegate.m, this is where GREE is instantiated, and head on to the line where the settings are given (Line 64)
Should look like this:
NSDictionary* settings = [NSDictionary dictionaryWithObjectsAndKeys:

Remove it and paste this one instead:

NSDictionary* settings = [NSDictionary dictionaryWithObjectsAndKeys:
GreeDevelopmentModeSandbox, GreeSettingDevelopmentMode,
[NSNumber numberWithBool:NO], GreeSettingUseWallet,
[NSNumber numberWithBool:YES], GreeSettingEnableGrade0, nil];

So what happened here ?, we’ve setup an NSDictionary called settings, which we will feed to the GREE class later, this holds the settings that we want GREE to use.

GreeSettingDevelopmentMode is now set to GreeDevelopmentModeSandbox which tells the SDK we’re running a test application so it won’t use the productions servers !

NOTE: if you did like me and set it to @”develop” or @”developSandbox” you’ll get this error:

"Must specify a serverUrl suffix if you are using development mode: develop or developSandbox"

Just a tip cause it got me scratching my head for a little while 😉

GreeSettingUseWallet is now set to NO, this disable the use of currency and all that other in-app purchase blood sucking features.. I hate them !

IMPORTANT: GreeSettingEnableGrade0 is now set to YES, This enables the users to run your app without being FORCED to register !, if you set this to NO the players won’t be able to use your app without registering and logging into GREE, totally not recommended !

Now we’ve got our settings straight (there are way more but those are enough for  a basic setup)

Now we’ll add our app ID and Consumer Key, etc..

a few lines below settings, you’ll find this

//print encrypted strings to console
[GreePlatform printEncryptedStringWithConsumerKey: consumerSecret: scramble:]

You can comment that line out or fill it in with the data we saved earlier, this is simply a debug line that prints out the encoded data to your console..

A few extra lines below that again, you’ll finally Initialize GREE !!
[GreePlatform initializeWithApplicationId:@"14587"
consumerKey:@"c03d99c0fc77" consumerSecret:@"f9a7bb03e4cbc784b609af29c560e87c" settings:settings delegate:self];

Fill in with your own data that you saved earlier (Those are just my test data)

Now you’re set to go !, build and run your code, should run without any hassles !

GREE will now popup just like OpenFeint used to, asking the user to play with GREE, hit play (Notice you can also hit the X button to close the window and disable GREE)

Hit Play, and login using the test account we made earlier !

Now it’s all on you pirate !, check around and get acquainted with GREE!

Go out and check the Leaderboards, you’ll notice the one we created in the Portal earlier is now there, add stuff to it and experiment how things work !

BTW, I don’t really like it, but let’s see where it goes !

 

Cheers !

26 comments

  1. Matthew   •  

    Mostafa,

    Awesome post dude! I was trying for hours trying to get this work…& now I can finally run the test app! yeah, in business.

    I ams also trying to convert a game engine I wrote that uses OpenFeint – particularly the Leaderboards – & would be very interested to see the
    same code you mentioned.

    Thanks,
    Matt

    • Berg   •     Author

      You’re very welcome, GREE isn’t well documented and has lots of bugs.. really annoying,
      Sure, I’ll create a post on how to migrate your games from OF’s platform !

      you’re working on cocos2d ?

  2. Matthew   •  

    After creating a new Loaderboard on the GREE developer web-site, I always see a network timeout when I click the Leaderboards button in the Sample App?

    Does it work for you?

    • Berg   •     Author

      Yeah it works immediately, but of course this is sandbox so you can expect timeouts, does it ever show tho ?

  3. John S.   •  

    I am a little disappointed with GREE because they seem to have removed some functionality that OpenFeint had. It is now not clear to me how to implement multiplayer other than a complex custom interaction through their Request API. It seems it is still possible, but much more difficult. It also seems that some of the interactions they used to provide are now simply brokered through GREE and I will have to implement my own game server.

    • Berg   •     Author

      I didn’t look into multiplayer yet since I have no multiplayer games out yet…

      have you found anything yet on that ?

    • John S.   •  

      After looking through SDK much more thoroughly, I have concluded the GREE is quite a step backward (compared to OpenFeint). Since all of my games are just on the iOS platform, I see no advantage now to using GREE over GameKit/GameCenter. I am now preparing updates to my existing games to switch to just GameCenter, as GREE recently reminded everyone that the OpenFeint servers will be shut off at the end of Q3 2012.

    • Berg   •     Author

      True, I share the same view here, I’ll probably remove it too and stick with game center in future updates, I prefer Gamecenter too.
      Also lately OpenFeint began to feel a little to “spammy?”..
      Only time will show if GREE is any good, but for now it gets thumbs down !
      I took a look at your games, nice work ! 🙂

  4. Diablo404   •  

    ” NOTE: If this post gets enough attention, I’ll also show you how to integrate it with Cocos2d and add leaderboards/achievements to your Cocos2d game and migrate from OpenFeint AND show you how it works with GameCenter, just let me know in the comments, I’ll also include a downloadable project for your convenience ”

    I’m definetely waiting for that, every single day!

    • Berg   •     Author

      Sure man, I was really busy with a new game for a client, but I’ll try getting a simple tutorial with full code this week !, would that be okay ?

    • Diablo404   •  

      That wouldn’t be just okay, that would be perfect!
      Thanks in advance!

  5. R.Payet   •  

    Hello Berg, I’m looking forward the Cocos2d implentation with leaderboard and achievement, and it’s link with GameCenter.

    Thanks for any help!

    • Berg   •     Author

      Sure, I’ll start working on that ! 🙂

  6. Pingback: Integrating GREE into your cocos2d game ! | Berg's Blog

  7. Berg   •     Author

    I’ve written the cocos2d version of the post guys !, hope you find it helpful !

  8. sumit   •  

    Hi Berg I am using GREE SDK for unity platform. Its working fine for iOS but for Android its crashing shall i have to change anything in code? and one more thing in android they dont allow to close the window after logout how to do? I will be thankful to you if you could help..

    thanks.

  9. Bharat   •  

    Hi Berg,

    I have a android Game application and have separate Server side API for this game application .I need to integrate GREE APIs with our server side APIs.
    I would like to know if GREE API supports integration with server side API or not? If yes, please let me know how we can integration it with Server side API.

    I have create a test account on GREE Developer side but whenever i am trying to verify it from my PC, its showing below message :-

    Your device is not supported.

    Sorry, you cannot access GREE.
    Supported OS: iOS 3 / Android 1.6 or later

    • Berg   •     Author

      Hi Bharat, I’m not exactly sure what you mean by “GREE API supports inegration with server side API” ? the GREE SDK is an API to the GREE server, if you meant you want to use your own scoring system, yes this is very possible, you can use the callbacks that GREE supports to update your own API in the appropriate places, very doable !
      about your second problem, you can’t do that from PC, it has to be done from the actual device or at least the simulator !

    • Bharat   •  

      Hi Berg,Thanks you reply.Our second issue has resolved.
      Let me explain you more about first one issue :-
      we have a ios gaming application which interact with our server side application for user authentication etc,which is running at our server.i would like to know that GREE API integrate only with IOS or can we integrate it with our server side application also if yes, please let me know the help section where it is explained.

    • Bharat   •  

      Hi Berg,Thanks for reply.Our second issue has resolved.
      Let me explain you more about first one issue :-
      we have a ios gaming application which interact with our server side application for user authentication etc,which is running at our server.i would like to know that GREE API integrate only with IOS or can we integrate it with our server side application also if yes, please let me know the help section where it is explained.

    • Berg   •     Author

      Yes I understand what you want, you have your own scoring system in the backend and you want GREE to post scores to your own server, this is not directly possible, as the SDK only communicates with GREE’s servers, of course this works on android and iOS, in order to have GREE send scores and achievements to your own server, you do things exactly the same way, and when you use GREE’s methods to post an updated score, in the method’s callback you simply use your own code that posts that exactly same score to your own server, you may use any protocol you’d like, but you can use JSONKit ! and parse your data on the server… if that’s not clear enough please let me know !

  10. Ashley Cooke   •  

    I am quite new at this but this seems to be a very interesting topic. I think I will bookmark it for future reading.

  11. Bharat   •  

    Hi Berg, One more think i would like to know. I think we need to create new user registration before sharing user information,user achievement and sending message to each other etc..,but its not given anywhere how new user will create.Can you help me here also.

  12. Arpit   •  

    Thanks Burg, That was really a help. You Said it right that ios-developer-guied is real pain to read. But I am having a issue as if I try to implement it on my own project, (any out of, showcase) then I face a trouble, linker error as it can’t fine GreeWallet.h and a sequntial trail of these type of issues. One goes another comes but inside downloaded folder it goes good. Any help?

    • Berg   •     Author

      Can you give a little more details about what you’re getting ? you may also email it to me and i’ll fix it for you if you want !

  13. Utopia   •  

    [OpenFeint launchDashboard]; very very easy,

    how to GREE launchDashboard (idiot GREE SDK)

Leave a Reply

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