Skip to content
Built natively in XCode, using Objective-C, C++ and OpenGLES2, Friend Smash for iOS shows you how to integrate the Facebook SDK for iOS to provide easy login, increased engagement and improved organic distribution.
Objective-C C++ Objective-C++ C
Latest commit 4786db4 Dec 9, 2015 @skoggkatt skoggkatt Merge pull request #7 from youminkim/master
Support iPhone 6 Plus / 6S Plus and fix crashes

README.md

Friend Smash sample Facebook game

Authors:

  • Ali Parr (aliparr)
  • Youmin Kim (youminkim)

Overview

To help better understand different products and services available to game developers, Facebook maintains a sample game called Friend Smash!

The game is implemented on different platforms:

There are minor differences between the four implementations, but overall the goal and structure of all is similar. This is the iOS version of the game.

What is “Friend Smash!”?

Friend Smash is a simple game which utilizes Facebook platform to enhance the gameplay by making it more fun and social. It uses variety of products and services, such as Facebook Login, Graph API, Game Requests and Sharing. The code examples serve as a guide of how they may be used in a games context. It also serves as an implementation guide - parts of source code relevant to Facebook integration are clearly separated from the pure gaming-logic and clearly documented with in code comments.

Please note that Friend Smash! was not designed as an example of how to design or code a game. The focus is on Facebook integration - other parts of the project may not be as clear and well designed and documented.

Friends Smash! is a game in which players are tasked with "smashing" (mouse-clicking or screen-tapping) pictures of a specific person while avoiding smashing pictures of anyone else. Player gets points for each correct picture smashed. Each miss or wrong smash causes the player to lose a heart. After losing 3 lives, the game is over. Player can also smash images of coins to collect them and later redeem these coins to buy bombs. In turn, bombs can be used in game to smash all correct pictures on the screen, helping to achieve a higher score. Additionally, the web version of the game allows players to purchase coins with Facebook Payments.

Facebook integration

To make the experience more fun and social, players are asked to log in with Facebook and grant user_friends permission. When granted, the game will have access to subset of player's friends data, specifically those who also logged in to Friend Smash! and granted user_friends permission. This means the game will use the profile picture of randomly selected friend as the picture the player is asked to smash. If user_friends permission hasn’t been granted or the player doesn't have friends who also logged in to Friend Smash! and granted user_friends permission, a picture of randomly selected celebrity is used instead.

At different points in the game player has an opportunity to share to Facebook. For example after the game is over, player can brag about the score achieved by posting a custom Open Graph story. The game also shows how to ask for publish_actions permission (which is required for API based sharing) and how to handle the case when publish_actions permission is not granted. If publish_actions permission is granted - the game uses Scores API to publish and store the top score achieved by the player.

Game Requests are used in the game for two main purposes. First to let the player invite their friends who are not playing the game to try it. Second, to send a challenge to a friend who is already playing to bring them back to the game. Additionally on the web version, the game uses Facebook Payments to allow players to purchase in-game currency and In-Game Gifting to allow purchasing gifts for players’ friends. The web example also includes reference implementation of a payments server handling static pricing and payments verification.

Friend Smash! also logs App Events, which enables Facebook Analytics for Apps - a free tool allowing developers to learn how people use their app across all platforms and devices, get insights about the people using the app, and improve marketing.

How to use “Friend Smash!”?

All versions of Friend Smash! are available as part of Facebook Platform Samples on github: Web, Android, iOS, Unity.

The recommended way to explore the projects is to begin with how Facebook products are integrated. To make it easier code responsible for Facebook integration is separated and well documented with in code comments for all versions. You can find it here for different versions: Web, Android, iOS, Unity. The reference implementation of a payments server is included in the Web repository.

To play Friend Smash! on Web, simply go to apps.facebook.com/friendsmashsample. To play it on mobile, download the Android, iOS or Unity project and build it from source and try on your device.

Please note it is likely that unless you have friends who also installed Friend Smash! you will not see any of your friends in the game. If this is the case, you can invite some of your friends to play Friend Smash! to fully explore how social integration works in Friend Smash!

Installing

Before running the sample, please see the Getting Started on iOS guide

Additional Resources

Facebook SDK for iOS documentation

Contributing

All contributors must agree to and sign the Facebook CLA prior to submitting Pull Requests. We cannot accept Pull Requests until this document is signed and submitted.

Something went wrong with that request. Please try again.