Discussion Forums  >  Plugins, Customizing, Source Code

Replies: 15    Views: 228

Absentia
buzztouch Evangelist
Profile
Posts: 960
Reg: Oct 20, 2011
Alaska
20,600
01/14/13 02:47 PM (13 years ago)

Here's a way to share quiz scores (Socialize required)...

I have been struggling with finding a easy way to share scores from the quiz for a while - yesterday, I suddenly realized how simply it can be done using the Socialize SDK - here's a quick run through of the steps NOTE: This tutorial assumes you have the Socialize SDK integrated and in your app - if you do a forum search for "Socialize" you will come up with a ton of threads on how to get working with buzztouch 1. Go to the Localizable.strings file in the BT_Config group and add the following line all the way at the bottom - "shareScore" = "Share Score"; 2. Go to BT_screen_quiz.m - around line 1255, right before where it says "//try again button", add the following - //share button [finishedButtons addObject:NSLocalizedString(@"shareScore", @"Share Score")]; 3. Find the actionSheet method - Around line 1540, right before where it says "//try again", add the following - //share score if([buttonTitle isEqual:NSLocalizedString(@"shareScore", @"Share Score")]){ [self showShareDialog]; } 4. Add this method somewhere inside of BT_screen_quiz.m (directly after the actionSheet method works fine) - - (void)showShareDialog { NSString *sharePoints = [NSString stringWithFormat:@"I just scored %d points playing Your_Quiz_Name_Here! Think you can beat it?", totalPoints]; id<SZEntity> entity = [SZEntity entityWithKey:sharePoints name:sharePoints]; [SZShareUtils showShareDialogWithViewController:self entity:entity completion:^(NSArray *shares) { // `shares` is a list of all shares created during the lifetime of the share dialog NSLog(@"Created %d shares: %@", [shares count], shares); } cancellation:^{ NSLog(@"Share creation cancelled"); }]; } And there you go...if you go here - http://www.facebook.com/jonny.brake.1 - you can see what the above code produces when shared on Facebook. The key is this part: NSString *sharePoints = [NSString stringWithFormat:@"I just scored %d points playing the One Direction Quiz! Think you can beat it?", totalPoints]; It creates a variable entity for Socialize to use - The majority of the text can of course be changed in whatever way fits your app best. The only vital part is having the" %d" in there so that the totalPoints variable has somewhere to go If anybody gets hung up on anything let me know
 
SmugWimp
Smugger than thou...
Profile
Posts: 6316
Reg: Nov 07, 2012
Tamuning, GU
81,410
like
01/14/13 02:55 PM (13 years ago)
Eventually I'll have to try that! I'm just starting to utilize the 'quiz' plugin, so I'm not advanced yet. But this seems very cool! Cheers! -- Smug
 
mysps
Code is Art
Profile
Posts: 2082
Reg: May 14, 2011
Palma
33,320
like
01/14/13 02:58 PM (13 years ago)
Sweet good share! Thanks.
 
SheriDee
Code is Art
Profile
Posts: 1094
Reg: Sep 23, 2011
location unknow...
22,840
like
01/14/13 03:37 PM (13 years ago)
Sweet! Another great resource! Thank you!
 
ceerup
Code is Art
Profile
Posts: 1033
Reg: Oct 10, 2011
New York City
16,380
like
01/14/13 03:58 PM (13 years ago)
question 1: so only socialize is required and not game center? question 2: is there a way to have your highest score saved without using the game center integration ? also thanks for the find
 
Absentia
buzztouch Evangelist
Profile
Posts: 960
Reg: Oct 20, 2011
Alaska
20,600
like
01/14/13 04:05 PM (13 years ago)
@ ceerup 1. game center is not required for this to work, but if anybody is wondering this doesn't interfere with the Game Center integration in any way. You can have both the "Submit Score" and "Share Score" options appearing on the screen. Once the Share is completed you will be returned to the Submit,Share,Try Again, Quit menu. 2. I'm sure there IS a way to save the highest score...unfortunately I don't know how
 
feraco
Aspiring developer
Profile
Posts: 705
Reg: Jan 23, 2012
nyc
15,050
like
01/14/13 06:17 PM (13 years ago)
Amazing I just integrated socialize and was wondering about that. Great instructions!
 
Absentia
buzztouch Evangelist
Profile
Posts: 960
Reg: Oct 20, 2011
Alaska
20,600
like
01/14/13 07:17 PM (13 years ago)
Cool! Hopefully you guys get some use out of it
 
tonycelestino
Aspiring developer
Profile
Posts: 213
Reg: Jun 24, 2011
Maceio
4,080
like
01/15/13 01:18 PM (13 years ago)
Good stuff @Absentia I have just integrated the iOS social framework to my Quiz Game (https://itunes.apple.com/us/app/flamengo-quiz-voce-e-flamenguista/id500599738?mt=8) and it took a lot more code than this Socialize hack. Thanks for sharing this! Starting update to version 1.6 in 3, 2, 1...
 
Absentia
buzztouch Evangelist
Profile
Posts: 960
Reg: Oct 20, 2011
Alaska
20,600
like
01/15/13 04:43 PM (13 years ago)
no problem - I'm currently trying to figure out how to have individual "Share on Facebook" and "Share on Twitter" buttons. I had the idea that it might be cool to have a twitter specific entity in which you insert a hashtag with your app name
 
tonycelestino
Aspiring developer
Profile
Posts: 213
Reg: Jun 24, 2011
Maceio
4,080
like
01/15/13 04:53 PM (13 years ago)
Hey Absentia, check out my app... I have done that. At quizEnded I add "Tweet Results" and "Share on Facebook" buttons to the UIActionSheet. If you want I can show you how I did it. It even hides the "Share on Facebook" and the Twitter button falls back to "TWTweetComposeViewController" when running on iOS5 (there is no social framework). I actually started messing around with this after I saw one of your posts. :P Let me know!
 
feraco
Aspiring developer
Profile
Posts: 705
Reg: Jan 23, 2012
nyc
15,050
like
01/15/13 05:13 PM (13 years ago)
I would to know how to do that! Can you post how you did that?
 
ceerup
Code is Art
Profile
Posts: 1033
Reg: Oct 10, 2011
New York City
16,380
like
01/21/13 02:02 AM (13 years ago)
hey i followed every instruction, when i click the share button, nothing happens, even when i log into socialize on my app
 
AppOne
buzztouch Evangelist
Profile
Posts: 348
Reg: Apr 03, 2012
London
13,980
like
01/21/13 10:28 PM (13 years ago)
@Ceerup In addition to the above tutorial, you still have to paste into the .h file inside the plugin folder you want the bar to appear in: #import <Socialize/Socialize.h> Then right below all the other #imports declare the properties. Paste: @property (nonatomic, retain) SZActionBar *actionBar; @property (nonatomic, retain) id<SZEntity> entity; ...right below the other @properties @Absentia - thanks for another great tutorial
 
ceerup
Code is Art
Profile
Posts: 1033
Reg: Oct 10, 2011
New York City
16,380
like
01/21/13 10:40 PM (13 years ago)
it says in the log that has nowhere to send the URL its still not working
 
MobileAppsABC
Aspiring developer
Profile
Posts: 28
Reg: Dec 19, 2012
Longueuil
4,480
like
08/20/13 06:25 AM (12 years ago)
Hey, I did try it, it's a nice way to share score with Socialize, I looking for the same result with Scringo : At the end of the quiz two more buttons, Tweet Score and Share Facebook. Anybody share score at the end of the quiz whit with Scringo ?? Thank for these nice ideas.
 

Login + Screen Name Required to Post

pointerLogin to participate so you can start earning points. Once you're logged in (and have a screen name entered in your profile), you can subscribe to topics, follow users, and start learning how to make apps like the pros.