Poker Royale Game for iPhone and iPad

15.03.2013 0

Introducing Poker Royale

Poker Royale is a FREE, stylish and easy-to-play Texas Hold’em multiplayer game for iPhone, iPad and iPod Touch. Challenge Game Center and Facebook friends to join you and climb your way up through the high stakes tables to win millions of virtual poker chips!

Poker Royale is an app that I created with 2 other developers – Ben Dowling and Mike Ross. It’s a project that’s been in development for about six months but we are finally live in the App Store and going strong!

Building a multiplayer game that can host thousands of simultaneous real users playing against each other anywhere in the world on their iPhones and iPads is no easy task! We’ve built something that really stands out from the competition and our users seem to be loving the results.

I jumped at the chance to be involved in developing a Poker app as for me this kind of project is a real mix of business and pleasure :-) I play a weekly poker game with friends and have been known to dabble online occasionally. As well as being a game of skill, probability and maths, poker can be a great sociable game. We’ve worked hard to ensure it’s really easy to play and invite your friends to tables in the game and developed a fun chat experience so that you can banter with players around the poker table. It’s kind of funny when you find yourself chatting to a Russian or Japanese player though – thankfully, Poker’s a global language!

Check out the promo video we made for the app:

What Makes us Unique?

♦ Have You Made The Rich List?
Poker Royale features the most successful poker players and friends in The Rich List – a chart of the top 100 highest rollers in the game based on real-time chip counts.

♥ Social
Poker Royale leverages Facebook and Game Center social networks to instantly connect players with their friends and family by inviting friends to join virtual poker tables. Find your online friends, join their tables, send them challenges, chat messages and compare scores.

♣ Multi-table
Poker Royale is the only iOS Poker game to enable players to compete on more than one table simultaneously. Win more hands on up to 4 tables at once!

♠ Chip Rewards
Win free chips for inviting friends and playing regularly.

What Players Say…

Here are a few of the five star reviews we’ve been getting on a daily basis:

This brings back the enjoyment I got from iOS Poker before the AppStore got saturated with clones…

If you want a higher brow alternative to the popular but annoyingly slutty Zynga poker, this is a great option!

Amazing setup with multiple tables that each have their own blind value and buy in amount from 1/2 all the way to 500M/1B

Wonderfully smooth easy to use game

Works really well, clearly lots of thought has been put into this, really slick design, fast animations, and speedy between games! And looks amazing on iPad! Great job.

The best poker app I’ve found with great graphics and so easy to use. I’m addicted!

If you love poker you’re gonna love Poker Royale. Download it for free from the App Store and don’t forget to tell your friends!

Book Update: Facebook Chapter

05.12.2012 4

A few weeks ago, my new book was published by ApressFoundation iPhone App Development: Build An iPhone App in 5 Days with iOS 6 SDK 

It’s been wonderful hearing from readers and receiving great feedback. It’s my first book and it took about 8 months to write alongside the day job so not an insubstantial project for me!

Build an iPhone App in 5 Days covers a very broad range of iOS topics such as Storyboarding, Skinning, Core Data and interacting with the iOS Address Book and Facebook.

Since going to print Facebook have made a couple of tweaks to the way native iOS Apps can integrate with the Facebook Graph API using the new iOS 6 Social Framework. As such some of their changes have broken the Facebook integration code found in Chapter 11 of my book. But fear not, I have a fix – the main reason I’m writing this blog post.

The original source code for my book can be downloaded directly from my book’s page on the Apress website.

But you’ll want to replace Chapter 11 source code with the new source code for this chapter that you can download here.

Within the new source code the only file that I’ve updated is in the Completed Code project folder – BRDModel.m – and I’ve highlighted my tweaks and changes in the file adding NEWCODE in the comments.

The Issue

If you’ve run into the follow printed error from Facebook servers when working with the original Chapter 11 source code then this blog post should get you back on track:

{NSLocalizedDescription=The Facebook server could not fulfill this access request: The app must ask for a basic read permission at install time.}

Facebook now require iOS apps to first request the minimal read permission before requesting extended permissions like friends_birthday and publish_stream. This means that apps using Apple’s Social Framework to interact with Facebook will need to fire multiple account store access requests rather than just one. This is annoying to program but does make sense IMHO. ie we can’t just ask for an endless list of permissions when our users first authenticate, signing their privacy away to our evil plans :-)

The Fix

So here’s how to do it. We should only start requesting Facebook access permissions from our users when and if they actually try to use a Facebook feature of our app. So the Facebook authentication process will still be lazily called when an if it’s required in Birthday Reminder.

The main change to the source code is in the authenticateWithFacebook method. What we do is call this method twice: once to request get the minimal Facebook permissions, and when granted we call loop back into the authenticateWithFacebook method and this time ask for the required extended permission. Here’s the full updated method:

- (void)authenticateWithFacebook {

//Centralized iOS user Twitter, Facebook and Sina Weibo accounts are accessed by apps via the ACAccountStore

ACAccountStore *accountStore = [[ACAccountStore alloc] init];

ACAccountType *accountTypeFacebook = [accountStore accountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierFacebook];

//NEW CODE start

NSArray *permissions;

NSString *facebookAudience = ACFacebookAudienceFriends;

if (self.facebookAccount == nil) {

//we need to deal with very basic authenication first

permissions = @[@"email"];

facebookAudience = ACFacebookAudienceOnlyMe;

}

else {

switch (self.currentFacebookAction) {

case FacebookActionGetFriendsBirthdays:

permissions = @[@"friends_birthday"];

break;

case FacebookActionPostToWall:

permissions = @[@"publish_stream"];

break;

default:

return;

}

}

//Replace with your Facebook.com app ID

NSDictionary *options = @{ACFacebookAppIdKey: @"125381334264255",

ACFacebookPermissionsKey: permissions,ACFacebookAudienceKey:facebookAudience};

//NEW CODE end

/* OLD CODE

//Replace with your Facebook.com app ID

NSDictionary *options = @{ACFacebookAppIdKey: @"125381334264255",

ACFacebookPermissionsKey: @[@"publish_stream",@"friends_birthday"],ACFacebookAudienceKey:ACFacebookAudienceFriends};

*/


[accountStore requestAccessToAccountsWithType:accountTypeFacebook options:options completion:^(BOOL granted, NSError *error) {

if(granted) {

//The completition handler may not fire in the main thread and as we are going to

NSLog(@"Facebook Authorized!");

NSArray *accounts = [accountStore accountsWithAccountType:accountTypeFacebook];

//NEW CODE start

//now repeat the authenticateWithFacebook call and get the next required permission

if (self.facebookAccount == nil) {

self.facebookAccount = [accounts lastObject];

[self authenticateWithFacebook];

return;

}

//we store the facebookAccount property again as this code may be called in a a different thread

self.facebookAccount = [accounts lastObject];

//NEW CODE end

//By checking what Facebook action the user was trying to perform before the authorization process we can complete the Facebook action when the authorization succeeds

switch (self.currentFacebookAction) {

case FacebookActionGetFriendsBirthdays:

[self fetchFacebookBirthdays];

break;

case FacebookActionPostToWall:

[self postToFacebookWall:self.postToFacebookMessage withFacebookID:self.postToFacebookID];

break;

}

} else {

if ([error code] == ACErrorAccountNotFound) {

NSLog(@"No Facebook Account Found");

}

else {

NSLog(@"Facebook SSO Authentication Failed: %@",error);

}

}

}];

}

 

Here’s how the above process works. When the authenticateWithFacebook method is first called self.facebookAccount is nil. So we first ask for basic access by setting the permissions array to email and facebook audience just to me:

if (self.facebookAccount == nil) {

//we need to deal with very basic authenication first

permissions = @[@"email"];

facebookAudience = ACFacebookAudienceOnlyMe;

}

This results in the basic profile access alert show here. If the user taps ‘OK’ then the request access completion handler code will run. If self.facebookAccount is still nil then we can assume that we’ve been granted basic access to the user’s Facebook data. So we set self.facebookAccount to the newly granted access account and recall authenticateWithFacebook:

//NEW CODE start

//now repeat the authenticateWithFacebook call and get the next required permission

if (self.facebookAccount == nil) {

self.facebookAccount = [accounts lastObject];

[self authenticateWithFacebook];

return;

}

This time, when our authenticateWithFacebook method runs it checks that self.facebookAccount is not nil and then picks the relevant extended permissions:

switch (self.currentFacebookAction) {

case FacebookActionGetFriendsBirthdays:

permissions = @[@"friends_birthday"];

break;

case FacebookActionPostToWall:

permissions = @[@"publish_stream"];

break;

default:

return;

}

In the case of retrieving the user’s Facebook friend birthdays we now need to request access to the friends_birthday Facebook permission which will result in the following iOS alert:

The user grants access to the extended permission and then bingo, we can now call fetchFacebookBirthdays which will in turn use the iOS 6 Social Framework to call the Facebook Graph API and retrieve an array of the user’s friend birthdays.

The only additional line of code we need to add is to nil out the self.facebookAccount reference when we’re done with it to ensure that our changes to the authentication flow will be repeatedly called. ie, we also call the Facebook Graph API to post directly to user’s Facebook walls so we need the authentication to rerun and request the publish_stream extended permission.

Does that all make sense? Hope so!

Enjoy the rest of the book :-)

Find me on twitter.

60secondreviews iPhone/iPad App

31.10.2012 2

60secondreviews are a new UK-based startup offering a simple and engaging proposition: concise, interesting 60 second video reviews of Movies, Restaurants, Books and Wine on your iPhone, iPod Touch or iPad. The video reviews are delivered by industry-leading expert critics and was founded by Euan MacDonald and Nick Duncalf.

I was hired by 60secondreviews as a Consultant and iOS Developer to build an e-commerce iOS app that could deliver the video reviews, giving users a free taster of the content before enticing them to subscribe using Apple’s in-app purchase subscription model.

The content covered by 60secondreviews (Movies, Restaurants, Books and Wine) is quite broad and whereas it makes sense for Movie content to appear in the App Store’s Entertainment category, Food and Drink are more appropriate the Wine and Restaurant based content. It was these differences which led us to conclude in an early brainstorming session that by creating 4 apps, one for each product, we could divide up the content nicely across a suite of apps. Those only interested in Wine (no wino jokes please!) would be presented with only Wine reviews.

However, we’ve also connected the 4 apps by creating a custom toolbar that enables users to flip between the apps using multitasking in iOS. If an app find that you have also installed additional 60secondreview apps on the same device then it displays a launch icon for each. If you haven’t already installed the other apps then we display a download icon to enable users to download the other apps for free, making great use of in-app cross-promotion.

All of the 60secondreview apps have been built in iOS 6 and make extensive use of the new Apple components and APIs such as collection views, appearance skinning and native Facebook and Twitter sharing.

Want to know more? I’ve even got my own 60secondreview video about the development of the iOS apps and the use of iOS 6. Check it out below.

Core Data Migration Woes with Binary Data and External Storage == Data Loss

09.06.2012 9

I’m currently on a flight to San Francisco to attend Apple’s WWDC 2012 Conference – with 10 hours of time to kill I thought I’d spend a few hours writing a post about a CoreData bug I discovered recently. I’m also planning on showing the bug to Apple engineers next week so with a bit of luck this issue may get fixed in iOS 6. Fingers crossed.

Apple’s Binary Data attribute type

In iOS 5 Apple introduced a great new Core Data attribute type, Binary Data. This was a great new attribute – prior to iOS 5 it was typical to manage and store images and other binary files to disk outside of Core Data and store references to the files from Core Data entities – not ideal.

Use Case Scenario

A lot of the apps I build make extensive use of caching images so that users of my apps can continue to use my apps even when they’re offline. A good example of this is my latest iPad App, Portfolio Pro. Portfolio Pro is an app for Photographers and Designers to import their photos and videos into the app and then be able to present those binary files to clients in a coffee shop for example. The images need to be cached by the app for offline use.

The Problem

I’ve been using Apple’s Binary Data attribute type to store both the large photographs imported by users of my app and thumbnails for the photos. I’ve updated the app a few times without experiencing any problems accessing the previously cached Core Data binary attributes. Until that is, I tried to attempt a very simple automated Core Data model migration in a recent update. A strange bug occurred. Cached Core Data binary data started disappearing!

What was odd was that all of the cached thumbnails remained after an automated migration but the larger binary data attributes containing the original large sized photographs (2048 pixels long side) became nullified.

I was using exactly the same approach to store the thumbnail binary data and the large photo binary data. So why was one migrating and the other not? In both cases in addition to setting the Core Data attribute type to Binary Data I’d also selected Allows External Storage option. It seemed like the sensible choice, as I’d expect an optimized database framework to read/write large binary files to disk.

Allows External Storage

While investigating the migration issue I was experiencing in Portfolio Pro I discovered that Core Data writes large binary data to disk but not smaller binary data. Exactly what size it uses as the cut-off limit I don’t know but with large photo data I found that Core Data had created external binary files on disk in a subfolder of my app’s documents folder named “_EXTERNAL_DATA” within another folder named “.[MyProjectName]_SUPPORT”. So if your Xcode target is named MyCoolApp then the path to Core Data’s external storage will be [DocumentsFolder]/.MyCoolApp_SUPPORT/_EXTERNAL_DATA

Goodbye External Storage

Once I’d discovered this hidden storage folder I then found the cause of my disappearing photos. When Core Data performs an automated model migration it deletes/resets the _EXTERNAL_DATA folder – goodbye photos! All of my entities were being migrated just fine but the large, externally stored binary attributes were just disappearing because the storage directory was getting nuked in the migration process.

So that’s the bug with migrating a CoreData model that uses Binary Data attributes with Allows External Storage switched on.

See for yourself

I’ve put together an example project to demonstrate the bug. Download the source files here:

Download Source Files

Begin by opening up the Xcode project within the Before Migration folder. Run the project in the iOS Simulator. You should get similar results to figure 1.

Figure 1

Figure 1: Before CoreData Migration

The 2 image views are being populated by a single Core Data entity. The entity contains 2 identical Binary Data attribute types. 1 named smallImage and one named largeImage. Both have been set up to Allow External Storage. In the view I’m rendering the smallImage binary data into the first image view and the largeImage binary data into the second image view. Both image views have content mode set to aspect fit.

Close the Before Migration version of the project. Now open After Migration (Bug) version of the same project. The only difference between this version of the project and the first is that I’ve migrated the CoreData model by adding a model version and adding a new unused string attribute named newAttribute to the Core Data Entity.

The project is already set-up correctly for automatic Core Data migration. Build and run. This should replace your previous version of the example app and perform the automatic model migration. But what happens to the binary data attributes of our entity? Here’s what happens, the small image remains and the large image is deleted (see figure 2)!

Figure 2: After CoreData Migration

Figure 2: After CoreData Migration

Ok, point proven. Delete the demo app from your iOS Simulator. Run the original Before Migration version once more – you should now have both images displayed as before. Now for the solution…

The Solution

Now build and run the third version of the example app within the After Migration (Solution) folder. You should still have 2 images displayed after migration – hurray!

The solution I’ve come up with is when your code initializes a persistent store coordinator for your Core Data model run a few checks before attempting automatic migration. Check whether the new model is compatible with the current stored model. If it’s not then you know that Core Data is about to migrate your old model to your new version and in doing so will wipe the external storage folder. Before it does so simply move the external storage folder to a temporary location. Once the migration has completed replace new empty external storage folder generated by Core Data. Here’s the code that you’ll also find in the Model class of the example project within the After Migration (Solution) folder:

- (NSPersistentStoreCoordinator *)persistentStoreCoordinator

{

if (_persistentStoreCoordinator != nil) {

return _persistentStoreCoordinator;

}

NSURL *storeURL = [[self applicationDocumentsDirectory] URLByAppendingPathComponent:@"CoreDataBinaryBug.sqlite"];

NSError *error = nil;

NSDictionary *sourceMetadata = [NSPersistentStoreCoordinator metadataForPersistentStoreOfType:NSSQLiteStoreType

URL:storeURL

error:&error];

//Check if the new model is compatible with any previously stored model

BOOL isCompatibile = [self.managedObjectModel isConfiguration:nil compatibleWithStoreMetadata:sourceMetadata];

BOOL needsMigration = !isCompatibile;

NSFileManager *fileManager = [NSFileManager defaultManager];

//Prepare a temporary path to move CoreData's external data storage folder to if automatic model migration is required

NSString *documentsPath = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) lastObject];

NSString *tmpPathToExternalStorage = [documentsPath stringByAppendingPathComponent:@"tmpPathToReplacementData"];

NSString *pathToExternalStorage = [documentsPath stringByAppendingPathComponent:@".CoreDataBinaryBug_SUPPORT/_EXTERNAL_DATA"];

if (needsMigration) {

if ([fileManager fileExistsAtPath:pathToExternalStorage]) {

//Move Apple's CoreData external storage folder before it's nuked by the migration bug

[fileManager moveItemAtPath:pathToExternalStorage toPath:tmpPathToExternalStorage error:nil];

}

}

NSDictionary *options = [NSDictionary dictionaryWithObjectsAndKeys:

[NSNumber numberWithBool:YES],NSMigratePersistentStoresAutomaticallyOption,

[NSNumber numberWithBool:YES], NSInferMappingModelAutomaticallyOption, nil];

_persistentStoreCoordinator = [[NSPersistentStoreCoordinator alloc] initWithManagedObjectModel:[self managedObjectModel]];

if (![_persistentStoreCoordinator addPersistentStoreWithType:NSSQLiteStoreType configuration:nil URL:storeURL options:options error:&error]) {

 

NSLog(@"Unresolved error %@, %@", error, [error userInfo]);

abort();

}

else {

if (needsMigration) {

//Apple's automatic migration is now complete. Replace the default external storage folder with the version pre upgrade

[[NSFileManager defaultManager] removeItemAtPath:pathToExternalStorage error:nil];

[[NSFileManager defaultManager] moveItemAtPath:tmpPathToExternalStorage toPath:pathToExternalStorage error:nil];

}

}

return _persistentStoreCoordinator;

}

Once more, here are the source files for the example project:

Download Source Files

Interested in iOS Development and Core Data? Follow me on Twitter for more tidbits :-)

Portfolio Pro for iPad: Brandable Photo and Video Presentation App

04.05.2012 4

My wife is a photographer and when she meets clients she lugs about a very large portfolio case holding a selection of suitable prints for each client. The case is heavy and cumbersome. Sure, the prints are ordered but it can be a pain for her to sift through her portfolio to find particular photographs during a meeting. The situation is a similar problem for thousands of photographers and designers. Far from ideal.

The iPad
The iPad is the perfect device for photographers to present their portfolio to clients. Swiping and zooming through photos on the iPad not only looks amazing on it’s HD display, it enables professional photographers to take their entire portfolio to client meetings in a lightweight device that fits inside an A4 envelope.

Apple’s Photos App
But Apple provide a great Photos App for the iPad already so why not just use that? Here are a couple of reasons.

  • What about when your private pics get mixed in with your professional ones?
  • What if you want to add a title and description to each of your photos?
  • What if you want to import your photos from Flickr or Dropbox and not have to rely solely on iTunes and iPhoto syncing?

iPhoto is a great app for viewing photos and videos of family and friends but when it comes to the professional photographer, you want a bespoke looking app that that looks like it belongs to you. Your Brand. Your Portfolio. Your App.

Introducing Portfolio Pro
Portfolio Pro for iPad, my latest project, is a brandable photo & video presentation app built for photographers, designers & creatives.

With batch import from Flickr, Dropbox and your iPad, Portfolio Pro gives professional users an extensive collection of ways to get their work onto the iPad. The app consists of 3 main sections: home screensaver for featured work, galleries and flippable fullscreen slideshow mode.

Portfolio Management
While Portfolio Pro imports your high res JPGs, PNGs, TIFs, GIFs, MOVs, MP4s and M4Vs you are free to simultaneously drag and drop to rearrange galleries, add names and descriptions to your work (also automatically imported from Flickr and Dropbox).

An Intuitive Experience
Having tried and tested pretty much every portfolio app for iPad in the App Store I can honestly say I think it’s rare to find a portfolio app that is both beautiful to present with and easy to use and configure. That’s exactly what I’ve set out to achieve with Portfolio Pro. Not only does Portfolio Pro look beautiful when presenting your work to clients, making changes to galleries and media is also super-simple and intuitive. Triple-tap any screen to switch between client and edit modes. Check out the video to see it in action.

I’ve set-up a dedicated website for Portfolio Pro here showcasing screengrabs of the app in action and many further details but if you’re already sold already here’s a direct link to Portfolio Pro on the App Store: