start here
http://iphonedevelopertips.com/core-services/ios-5-twitter-framework-part-1.htmlI Used the gamekit.mm to make things easier
Make sure you add the twitter framework
#import <Twitter/Twitter.h> |
above the function -(void) presentViewController:(UIViewController*)vc create a new function
- (void) tweet:(int)score
{
// Create the view controller
TWTweetComposeViewController *twitter = [[TWTweetComposeViewController alloc] init];
// Optional: set an image, url and initial text
//[twitter addImage:[UIImage imageNamed:<a href="https://forum.gideros.rocks/profile/iOSDevTips.png" rel="nofollow">@iOSDevTips.png</a>]];
[twitter addURL:[NSURL URLWithString:[NSString stringWithString:@"<a href="http://www.fawzma.com"" rel="nofollow">http://www.fawzma.com"</a>; ]]];
NSString *s = [NSString stringWithFormat:<a href="https://forum.gideros.rocks/profile/Just%20scored%20%25d%20on%20app%20name%20for%20iPad%21" rel="nofollow">@Just scored %d on app name for iPad!</a>,score];
[twitter setInitialText:s];
// Show the controller
//[self presentModalViewController:twitter animated:YES];
UIViewController* rootVC = g_getRootViewController();
[rootVC presentModalViewController:twitter animated:YES];
// Called when the tweet dialog has been closed
twitter.completionHandler = ^(TWTweetComposeViewControllerResult result)
{
NSString *title = <a href="https://forum.gideros.rocks/profile/Tweet%20Status" rel="nofollow">@Tweet Status</a>;
NSString *msg;
if (result == TWTweetComposeViewControllerResultCancelled)
msg = <a href="https://forum.gideros.rocks/profile/Tweet%20compostion%20was%20canceled." rel="nofollow">@Tweet compostion was canceled.</a>;
else if (result == TWTweetComposeViewControllerResultDone)
msg = <a href="https://forum.gideros.rocks/profile/Tweet%20composition%20completed." rel="nofollow">@Tweet composition completed.</a>;
// Show alert to see how things went...
UIAlertView* alertView = [[UIAlertView alloc] initWithTitle:title message:msg delegate:self cancelButtonTitle:<a href="https://forum.gideros.rocks/profile/Okay" rel="nofollow">@Okay</a> otherButtonTitles:nil];
[alertView show];
// Dismiss the controller
[rootVC dismissModalViewControllerAnimated:YES];
};
} |
In the GameKit class, below the void dispatchEvent() function add the following
void tweet(int score){
[helper tweet:score];
} |
add the next function above the static int loader(lua_State* L) function
static int tweet(lua_State* L)
{
GameKit* gamekit = getInstance(L, 1);
int score = luaL_checkint(L, 2);
gamekit->tweet(score);
return 0;
} |
in the const luaL_Reg functionlist[] add the following
In your LUA code call the function from a button or something like so
Takes less than 5 minutes to set up
Enjoy.
Comments
Dislikes: bgcis
https://dev.twitter.com/docs/twitter-libraries#java
Might check for iOS5 and add some autorelease where using [alloc] code for non ARC.
// check for iOS 5 Twitter integration
Class tweeterClassExists = NSClassFromString(@”TWTweetComposeViewController”);
if(tweeterClassExists != nil) {
// do the twitter
}