Permalink
Browse files

Merge pull request #1 from RandyMcMillan/master

Updating Twitter entries in Cordova.plist courtesy of @RandyMcMillan
  • Loading branch information...
2 parents fdb5204 + 330092b commit 9175fbe6631854eceb44fc64d16959986be2192f @ianserlin committed Apr 25, 2012
View
@@ -0,0 +1,24 @@
+# Xcode
+build/*
+*.pbxuser
+!default.pbxuser
+*.mode1v3
+!default.mode1v3
+*.mode2v3
+!default.mode2v3
+*.perspectivev3
+!default.perspectivev3
+*.xcworkspace
+!default.xcworkspace
+xcuserdata
+profile
+*.moved-aside
+
+.DS_Store
+
+# Thumbnails
+._*
+
+# Files that might appear on external disk
+.Spotlight-V100
+.Trashes
@@ -26,7 +26,7 @@
</array>
<key>Plugins</key>
<dict>
- <key>org.apache.cordova.twitter</key>
+ <key>TwitterPlugin</key>
<string>TwitterPlugin</string>
<key>org.apache.cordova.facebook.Connect</key>
<string>FacebookConnectPlugin</string>
@@ -7,11 +7,11 @@
#import "TwitterPlugin.h"
#ifdef CORDOVA_FRAMEWORK
- #import <Cordova/JSONKit.h>
- #import <Cordova/CDVAvailability.h>
+#import <Cordova/JSONKit.h>
+#import <Cordova/CDVAvailability.h>
#else
- #import "JSONKit.h"
- #import "CDVAvailability.h"
+#import "JSONKit.h"
+#import "CDVAvailability.h"
#endif
#define TWITTER_URL @"http://api.twitter.com/1/"
@@ -22,24 +22,21 @@ - (void) isTwitterAvailable:(NSMutableArray*)arguments withDict:(NSMutableDictio
NSString *callbackId = [arguments objectAtIndex:0];
TWTweetComposeViewController *tweetViewController = [[TWTweetComposeViewController alloc] init];
BOOL twitterSDKAvailable = tweetViewController != nil;
-
+
// http://brianistech.wordpress.com/2011/10/13/ios-5-twitter-integration/
if(tweetViewController != nil){
[tweetViewController release];
}
- if (IsAtLeastiOSVersion(@"3.0")) {
- NSString *version = @"5.1";
- NSLog(@"The TwitterPlugin requires iOS %@ or above due to is dependency on Twitter.framework.", version); // @RandyMcMillan
- }
+
[super writeJavascript:[[CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsInt:twitterSDKAvailable ? 1 : 0] toSuccessCallbackString:callbackId]];
}
- (void) isTwitterSetup:(NSMutableArray*)arguments withDict:(NSMutableDictionary*)options{
NSString *callbackId = [arguments objectAtIndex:0];
BOOL canTweet = [TWTweetComposeViewController canSendTweet];
-
+
[super writeJavascript:[[CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsInt:canTweet ? 1 : 0] toSuccessCallbackString:callbackId]];
}
@@ -62,7 +59,7 @@ - (void) composeTweet:(NSMutableArray*)arguments withDict:(NSMutableDictionary*)
}
}
-
+
if(imageAttach != nil){
// Note that the image is loaded syncronously
@@ -85,14 +82,22 @@ - (void) composeTweet:(NSMutableArray*)arguments withDict:(NSMutableDictionary*)
errorMessage = @"URL too long";
}
}
-
+
if(!ok){
[super writeJavascript:[[CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR
- messageAsString:errorMessage] toErrorCallbackString:callbackId]];
+ messageAsString:errorMessage] toErrorCallbackString:callbackId]];
}
else{
+
+#if TARGET_IPHONE_SIMULATOR
+ NSString *simWarning = @"Test TwitterPlugin on Real Hardware.";
+ //EXC_BAD_ACCESS occurs on simulator unable to reproduce on real device
+ //running iOS 5.1 and Cordova 1.6.1
+ NSLog(@"%@",simWarning);
+#endif
+
[tweetViewController setCompletionHandler:^(TWTweetComposeViewControllerResult result) {
switch (result) {
case TWTweetComposeViewControllerResultDone:
@@ -101,7 +106,7 @@ - (void) composeTweet:(NSMutableArray*)arguments withDict:(NSMutableDictionary*)
case TWTweetComposeViewControllerResultCancelled:
default:
[super writeJavascript:[[CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR
- messageAsString:@"Cancelled"] toErrorCallbackString:callbackId]];
+ messageAsString:@"Cancelled"] toErrorCallbackString:callbackId]];
break;
}
@@ -131,8 +136,8 @@ - (void) getPublicTimeline:(NSMutableArray*)arguments withDict:(NSMutableDiction
}
else{
jsResponse = [[CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR
- messageAsString:[NSString stringWithFormat:@"HTTP Error: %i", [urlResponse statusCode]]]
- toErrorCallbackString:callbackId];
+ messageAsString:[NSString stringWithFormat:@"HTTP Error: %i", [urlResponse statusCode]]]
+ toErrorCallbackString:callbackId];
}
[self performCallbackOnMainThreadforJS:jsResponse];
@@ -165,7 +170,7 @@ - (void) getMentions:(NSMutableArray*)arguments withDict:(NSMutableDictionary*)o
}
else{
jsResponse = [[CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR
- messageAsString:[NSString stringWithFormat:@"HTTP Error: %i", [urlResponse statusCode]]]
+ messageAsString:[NSString stringWithFormat:@"HTTP Error: %i", [urlResponse statusCode]]]
toErrorCallbackString:callbackId];
}
@@ -175,19 +180,19 @@ - (void) getMentions:(NSMutableArray*)arguments withDict:(NSMutableDictionary*)o
}
else{
NSString *jsResponse = [[CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR
- messageAsString:@"No Twitter accounts available"]
- toErrorCallbackString:callbackId];
+ messageAsString:@"No Twitter accounts available"]
+ toErrorCallbackString:callbackId];
[self performCallbackOnMainThreadforJS:jsResponse];
}
}
else{
NSString *jsResponse = [[CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR
- messageAsString:@"Access to Twitter accounts denied by user"]
- toErrorCallbackString:callbackId];
+ messageAsString:@"Access to Twitter accounts denied by user"]
+ toErrorCallbackString:callbackId];
[self performCallbackOnMainThreadforJS:jsResponse];
}
}];
-
+
[accountStore release];
}
View
@@ -0,0 +1,17 @@
+**I wish I could help but I cant repro the issue. - [@RandyMcMillan](https://twitter.com/#!/RandyMcMillan)
+**
+
+
+![image](https://github.com/RandyMcMillan/iOS-Cordova-Facebook-Template/raw/2ab316307d6e463b17d96e929b3aa03cc008f414/Screenshot%202012.04.25%2003.33.24.png)
+
+![image](https://github.com/RandyMcMillan/iOS-Cordova-Facebook-Template/raw/2ab316307d6e463b17d96e929b3aa03cc008f414/Screenshot%202012.04.25%2003.33.35.png)
+
+![image](https://github.com/RandyMcMillan/iOS-Cordova-Facebook-Template/raw/2ab316307d6e463b17d96e929b3aa03cc008f414/Screenshot%202012.04.25%2003.33.41.png)
+
+![image](https://github.com/RandyMcMillan/iOS-Cordova-Facebook-Template/raw/2ab316307d6e463b17d96e929b3aa03cc008f414/Screenshot%202012.04.25%2003.33.49.png)
+
+![image](https://github.com/RandyMcMillan/iOS-Cordova-Facebook-Template/raw/2ab316307d6e463b17d96e929b3aa03cc008f414/Screenshot%202012.04.25%2003.33.59.png)
+
+![image](https://github.com/RandyMcMillan/iOS-Cordova-Facebook-Template/raw/2ab316307d6e463b17d96e929b3aa03cc008f414/Screenshot%202012.04.25%2003.34.06.png)
+
+
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
@@ -1,37 +1,35 @@
var Twitter = function(){};
Twitter.prototype.isTwitterAvailable = function(response){
- cordova.exec(response, null, "org.apache.cordova.twitter", "isTwitterAvailable", []);
- //cordova.exec(response, null, "TwitterPlugin", "isTwitterAvailable", []);
+ cordova.exec(response, null, "TwitterPlugin", "isTwitterAvailable", []);
};
Twitter.prototype.isTwitterSetup = function(response){
- cordova.exec(response, null, "org.apache.cordova.twitter", "isTwitterSetup", []);
+ cordova.exec(response, null, "TwitterPlugin", "isTwitterSetup", []);
};
Twitter.prototype.composeTweet = function(success, failure, tweetText, options){
options = options || {};
options.text = tweetText;
- cordova.exec(success, failure, "org.apache.cordova.twitter", "composeTweet", [options]);
+ cordova.exec(success, failure, "TwitterPlugin", "composeTweet", [options]);
};
Twitter.prototype.getPublicTimeline = function(success, failure){
- cordova.exec(success, failure, "org.apache.cordova.twitter", "getPublicTimeline", []);
+ cordova.exec(success, failure, "TwitterPlugin", "getPublicTimeline", []);
};
Twitter.prototype.getMentions = function(success, failure){
- cordova.exec(success, failure, "org.apache.cordova.twitter", "getMentions", []);
+ cordova.exec(success, failure, "TwitterPlugin", "getMentions", []);
};
cordova.addConstructor(function() {
/* shim to work in 1.5 and 1.6 */
- if (!window.Cordova) {
- window.Cordova = cordova;
- };
-
+ if (!window.Cordova) {
+ window.Cordova = cordova;
+ };
+
if(!window.plugins) window.plugins = {};
window.plugins.twitter = new Twitter();
});
-

0 comments on commit 9175fbe

Please sign in to comment.