Quick Links: Download Gideros Studio | Gideros Documentation | Gideros Development Center | Gideros community chat
Integrate Twitter (IOS 5.0) - Gideros Forum

Integrate Twitter (IOS 5.0)

fawzmafawzma Member
edited March 2012 in Step by step tutorials
start here http://iphonedevelopertips.com/core-services/ios-5-twitter-framework-part-1.html

I 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="/profile/iOSDevTips.png">@iOSDevTips.png</a>]];
    [twitter addURL:[NSURL URLWithString:[NSString stringWithString:@"<a href="http://www.fawzma.com&quot" target="_blank" rel="nofollow">http://www.fawzma.com&quot</a>; ]]];
    NSString *s = [NSString stringWithFormat:<a href="/profile/Just%20scored%20%25d%20on%20app%20name%20for%20iPad%21">@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="/profile/Tweet%20Status">@Tweet Status</a>;
        NSString *msg; 
        if (result == TWTweetComposeViewControllerResultCancelled)
            msg = <a href="/profile/Tweet%20compostion%20was%20canceled.">@Tweet compostion was canceled.</a>;
        else if (result == TWTweetComposeViewControllerResultDone)
            msg = <a href="/profile/Tweet%20composition%20completed.">@Tweet composition completed.</a>;
        // Show alert to see how things went...
        UIAlertView* alertView = [[UIAlertView alloc] initWithTitle:title message:msg delegate:self cancelButtonTitle:<a href="/profile/Okay">@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);
    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


Likes: phongtt, pmanna, larf

+1 -1 (+3 / -0 ) Share on Facebook


Sign In or Register to comment.