Sharing is Caring

Back from a long weekend so I figured I would let you guys know some of the dev stuff accomplished over the weekend.  First off, you should go check out the sneak peak of the new color scheme for Block'd!, if you haven't already.  I'm pretty excited about the new colors and I'm also excited about the updates to the UI we are going to be implementing for our v1.1 update.  But that's a post for a different day.  The main thing that got accomplished over the weekend was setting up sharing for Color Fall.

Having people share your game is probably the best, and cheapest, way to get more people playing.  So our job is to make sharing as easy as possible.  We got our first taste of this when we were developing Block'd!  Or I guess I should say Austin got his first look at sharing when we were developing Block'd! (since he was kinda in charge of that).  So he set off to learn about all of that stuff and then next thing I know, we have a button that will post a predetermined message, link, and photo to Facebook.  But then it was my turn to get sharing set up for Color Fall.  

My first instinct was to just copy and paste the code from Block'd! and see what happened.  Well, as I'm sure you could have guessed, this did not go exactly as I had planned.  It turned out I was missing the Facebook SDK library which caused a number of errors.  So I headed over to the library selector in Xcode, eager to add the SDK to my project and have all my problems resolved, when I discovered that there was no Facebook SDK in the default libraries.  So off to the internet I go to try and figure out what this Facebook SDK is when I stumble upon this

This magical little thing that, will not only let you share to Facebook and Twitter, but also let you e-mail or text it to someone!  And the best part, it's pretty much built into iOS 7.  The share sheet, as it's called, seemed to be the solution to all my problems.  So I start doing a little more research and finally find everything I need to implement it in Color Fall (on another note, I actually found it a little difficult to find a good tutorial on how to implement this.  This is the one I ended up using, in case you are looking for the same thing)  The second best part about using the share sheet instead of the Facebook SDK and Twitter SDK is that the roughly hundred lines or so of code it took to implement just the Facebook Sharing can be condensed into about 20 lines of code. So with those 20 lines written I press run on the iOS simulator, press the share button and. . . nothing. . . (although I'm not sure I expected anything less)

Long story short is that the share sheet is really a ViewController and I was trying to implement it in an SKScene which is already in a ViewController.  So I had to access the Scene's view controller to present this new view controller.  Once again, the internet did not fail in supplying me with all the knowledge I needed.  So with two more lines of code I run it again, press the share button and. . . nothing. . . again . . .

So at this point I think the code I got from the internet is a little on the iffy side so I go back and start looking for other ways to do it.  But after wading though pages of google and trying different search phrases I can't find anything.  So at this point I'm starting to get a little more than frustrated with the code.  Finally, I decide that it's time to turn on the debugger in Xcode and get this figured out once and for all.  The first thing I notice with the debugger is that the method setting up and presenting the share sheet . . . is never getting called. . . because when I copy and pasted the share button code from another button I forgot to make the proper changes.  So with the proper changes made, I run the code, press the share button and . . . the share sheet comes up! YES!!  (Also, here's what I ended up using to deal with the ViewController problem)

So finally, after a couple days of internet searching and fiddling with a couple lines of code, I had sharing set up for Color Fall.  There are a few things that make the share sheet less than ideal.  The main one being that you have to be logged into Facebook and Twitter on your iPhone (like in the settings part of the phone) to have them show up.  I'm also not sure if it's going to work with devices not running iOS 7, which is a little bit of a problem.  But despite all of that, I still think this is the best way to get Facebook and Twitter and all the other sharing stuff set up.

So that's basically what I accomplished over the weekend.  We also did a touch of theoretical development on Block'd!, figure out exactly what we want to implement in v1.1 before we actually start dividing up the tasks and getting to work on that.  Anyways, keep checking back here for more updates on the stuff we're doing.

Thanks for reading,