Quick Links: Download Gideros Studio | Gideros Documentation | Gideros community chat | DONATE
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="https://forum.gideros.rocks/profile/iOSDevTips.png" rel="nofollow">@iOSDevTips.png</a>]];
    [twitter addURL:[NSURL URLWithString:[NSString stringWithString:@"<a href="http://www.fawzma.com&quot" rel="nofollow">http://www.fawzma.com&quot</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
        {"tweet",tweet},
In your LUA code call the function from a button or something like so
		gamekit:tweet(1000)
Takes less than 5 minutes to set up

Enjoy.

Likes: phongtt, pmanna, larf

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

Comments

Sign In or Register to comment.