diff --git a/iPhone/Twitter/example/www/demo.js b/iPhone/Twitter/example/www/demo.js index 4aea609a..1839b7b5 100644 --- a/iPhone/Twitter/example/www/demo.js +++ b/iPhone/Twitter/example/www/demo.js @@ -17,7 +17,7 @@ TwitterDemo = { }, setup:function(){ - var tests = ["isAvailable", "isSetup", "tweet", "compose", "timeline", "mentions"]; + var tests = ["isAvailable", "isSetup", "tweet1", "tweet2", "tweet3", "tweet4", "tweet5", "compose", "timeline", "mentions"]; for(var i=0, l=tests.length; iHey, it's Twitter on PhoneGap!
  1. isAvailable
  2. isSetup
  3. -
  4. tweet through API
  5. -
  6. compose new tweet popup
  7. +
  8. tweet (text, img, url)
  9. +
  10. tweet (text, img)
  11. +
  12. tweet (text, url)
  13. +
  14. tweet (text)
  15. +
  16. tweet (empty)
  17. timeline
  18. mentions
diff --git a/iPhone/Twitter/native/ios/TwitterPlugin.h b/iPhone/Twitter/native/ios/TwitterPlugin.h index 601cca6c..cfa6bb64 100644 --- a/iPhone/Twitter/native/ios/TwitterPlugin.h +++ b/iPhone/Twitter/native/ios/TwitterPlugin.h @@ -21,8 +21,6 @@ - (void) isTwitterSetup:(NSMutableArray*)arguments withDict:(NSMutableDictionary*)options; -- (void) sendTweet:(NSMutableArray*)arguments withDict:(NSMutableDictionary*)options; - - (void) composeTweet:(NSMutableArray*)arguments withDict:(NSMutableDictionary*)options; - (void) getPublicTimeline:(NSMutableArray*)arguments withDict:(NSMutableDictionary*)options; diff --git a/iPhone/Twitter/native/ios/TwitterPlugin.m b/iPhone/Twitter/native/ios/TwitterPlugin.m index 4b55d1c9..674f15a9 100644 --- a/iPhone/Twitter/native/ios/TwitterPlugin.m +++ b/iPhone/Twitter/native/ios/TwitterPlugin.m @@ -36,21 +36,23 @@ - (void) isTwitterSetup:(NSMutableArray*)arguments withDict:(NSMutableDictionary [super writeJavascript:[[PluginResult resultWithStatus:PGCommandStatus_OK messageAsInt:canTweet ? 1 : 0] toSuccessCallbackString:callbackId]]; } -- (void) sendTweet:(NSMutableArray*)arguments withDict:(NSMutableDictionary*)options{ +- (void) composeTweet:(NSMutableArray*)arguments withDict:(NSMutableDictionary*)options{ // arguments: callback, tweet text, url attachment, image attachment NSString *callbackId = [arguments objectAtIndex:0]; - NSString *tweetText = [arguments objectAtIndex:1]; - NSString *urlAttach = [arguments objectAtIndex:2]; - NSString *imageAttach = [arguments objectAtIndex:3]; + NSString *tweetText = [options objectForKey:@"text"]; + NSString *urlAttach = [options objectForKey:@"urlAttach"]; + NSString *imageAttach = [options objectForKey:@"imageAttach"]; TWTweetComposeViewController *tweetViewController = [[TWTweetComposeViewController alloc] init]; BOOL ok = YES; NSString *errorMessage; - ok = [tweetViewController setInitialText:tweetText]; - if(!ok){ - errorMessage = @"Tweet is too long"; + if(tweetText != nil){ + ok = [tweetViewController setInitialText:tweetText]; + if(!ok){ + errorMessage = @"Tweet is too long"; + } } if(urlAttach != nil){ @@ -98,16 +100,6 @@ - (void) sendTweet:(NSMutableArray*)arguments withDict:(NSMutableDictionary*)opt [tweetViewController release]; } -- (void) composeTweet:(NSMutableArray*)arguments withDict:(NSMutableDictionary*)options{ - TWTweetComposeViewController *tweetComposeViewController = [[TWTweetComposeViewController alloc] init]; - [tweetComposeViewController setCompletionHandler: ^(TWTweetComposeViewControllerResult result) { - [[super appViewController] dismissModalViewControllerAnimated:YES]; - }]; - - [[super appViewController] presentModalViewController:tweetComposeViewController animated:YES]; - [tweetComposeViewController release]; -} - - (void) getPublicTimeline:(NSMutableArray*)arguments withDict:(NSMutableDictionary*)options{ NSString *callbackId = [arguments objectAtIndex:0]; NSString *url = [NSString stringWithFormat:@"%@statuses/public_timeline.json", TWITTER_URL]; diff --git a/iPhone/Twitter/www/TwitterPlugin.js b/iPhone/Twitter/www/TwitterPlugin.js index e211e5e8..51e35fe1 100644 --- a/iPhone/Twitter/www/TwitterPlugin.js +++ b/iPhone/Twitter/www/TwitterPlugin.js @@ -8,15 +8,10 @@ Twitter.prototype.isTwitterSetup = function(response){ PhoneGap.exec(response, null, "com.phonegap.twitter", "isTwitterSetup", []); }; -Twitter.prototype.sendTweet = function(success, failure, tweetText, urlAttach, imageAttach){ - if(typeof urlAttach === "undefined") urlAttach = ""; - if(typeof imageAttach === "undefined") imageAttach = ""; - - PhoneGap.exec(success, failure, "com.phonegap.twitter", "sendTweet", [tweetText, urlAttach, imageAttach]); -}; - -Twitter.prototype.composeTweet = function() { - PhoneGap.exec(null, null, "com.phonegap.twitter", "composeTweet", []); +Twitter.prototype.composeTweet = function(success, failure, tweetText, options){ + options = options || {}; + options.text = tweetText; + PhoneGap.exec(success, failure, "com.phonegap.twitter", "composeTweet", [options]); }; Twitter.prototype.getPublicTimeline = function(success, failure){