-
Notifications
You must be signed in to change notification settings - Fork 23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
not working with Cordova 2.5 #3
Comments
The first problem is easily fixed. The available function expects a callback function, which in turn gets a variable that is either 1 or 0, not true or false. Using a callback and checking on 1 or 0 will fix your first issue. I've also got the second problem. I send a title, link and image, but only the title seems to be actually used. A fix would be great! |
+1 to the problem with missing URL (and IMAGE) |
Guys, do you have an idea on how to fix URL sharing? |
I'm still using Cordova 2.2 on my projects but I don't see why there would be any issues with 2.5 as the actual plugin is dead simple. Make sure the image you are passing is relative to the app's base directory and not www. So something like 'www/images/image.jpg'. I haven't had any problems with the URLs myself except when passing dead or not-live URLs--I haven't looked into this but it appears the social framework must be doing some validation on the URL before showing it--perhaps this is your problem? |
Thanks for quick reply! Is image parameter required? I'm trying to make a post with message and URL only, do you know if that's an option. The URL is valid youtube video link. Thanks for your help! |
Everything works good with local images attached. Checked with cordova-2.5. |
Does anyone have this working with 2.6? I followed the instructions but the plugin isn't doing anything. Thanks |
Hi, |
All working now.
<plugin name="Social" value="Social" />
1. When providing image URL, make sure to include relative path to your image including the "www" (just as the Readme says).
window.plugins.social.share('This is my test message', 'http://www.url.com', 'www/images/myImage.png');
Everything should work then even under Cordova 2.6.0. PS This is a fairly fragile plugin but it does the job. Thanks a lot for this! |
I was having a similar problem. The way I fixed it was adding the Social.h and Social.m files to the Xcode project. I thought adding the files to the directory was enough, you need to right click on the plugins folder in Xcode then click add files to the project. Then select the two files. Once I did that everything worked great! |
Is there a way to have an image that you take with your phone's camera be the image that is shared instead of a predefined image? How would one go about doing that? |
You'd have to use the Capture API in phonegap. Then use the captureSuccess callback. |
Sorry I should have been a little more specific. I already have the camera function set up. I was just wondering what I would have to put in place of the image location to get the image that I have taken with the camera to share. How would I tell the plugin to share the image that was just taken instead of a predefined image. Thanks for your reply swilla! |
Hi, |
What if I want to share only the title and a URL, without an attached image, isn't there a way? |
I am almost sure you can simply use empty quotes and the plugin will not post any image for you. |
When I do that, the 'url' parameter is ignored as well, and only the title is shared |
Hmmm. This will probably require a little digging then. On May 11, 2013, at 1:35 PM, apolinario [email protected] wrote:
|
Ok. I'll look forward to it. I really don't have a local image to share in every link I'd like to share |
Stopped working completely! I've added this plugin more than 3 times already and I don't know what makes it stop working once a get it to work for a while. I had recently added the Facebook SDK and all it's required frameworks. |
You shouldn't need Facebook SDK for this to work. On Jun 14, 2013, at 10:18 AM, originalp [email protected] wrote:
|
Facebook SDK is for another purpose. Not getting any errors, just not working. On Fri, Jun 14, 2013 at 2:22 PM, Victor Tsaran [email protected]
|
Can you share the piece of your code where you're calling Social plugin? On Jun 14, 2013, at 12:54 PM, originalp [email protected] wrote:
|
Add me to the list of people who can only share the text. No URL and no image, although I am trying to load an image URL of an image hosted on Amazon S3. I know you stated you have not tested image URLs, but can anyone point me in the right direction so I can get this working? Would that be an issue with this plugin or with the Sharing framework? |
I've sorted out my aforementioned issues with help from benwilkins (Actually, he did all of the work). Planning on forking with the updates. |
Hmmmmm seems to have an issue not loading in Cordova 2.9 |
@thomasthesecond Could you share how you did this? Just adding a complete url doesn't work as you say, but my knowledge of Coacoa is limited at best :) |
I'm just going to post the code that I'm using in Social.m verbatim; I figured it would be easier that way. Hope it helps. And again, thanks to benwilkins. //
// Social.m
//
// Cameron Lerch
// Sponsored by Brightflock: http://brightflock.com
//
#import "Social.h"
@interface Social ()
@end
@implementation Social
- (void)available:(NSMutableArray*)arguments withDict:(NSMutableDictionary*)options {
BOOL avail = false;
if (NSClassFromString(@"UIActivityViewController")) {
avail = true;
}
CDVPluginResult* pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsInt:avail];
[self writeJavascript:[pluginResult toSuccessCallbackString:[arguments objectAtIndex:0]]];
}
- (void)share:(NSMutableArray*)arguments withDict:(NSMutableDictionary*)options {
if (!NSClassFromString(@"UIActivityViewController")) {
return;
}
NSString *text = [arguments objectAtIndex:1];
NSString *imageName = [arguments objectAtIndex:2];
UIImage *image = nil;
// Check if this is a cached image.
if ([imageName rangeOfString:@"http://"].location == NSNotFound) {
if (imageName) {
image = [UIImage imageNamed:imageName];
}
// No? Then it must be an external image.
} else {
image = [UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:imageName]]];
}
NSString *urlString = [arguments objectAtIndex:3];
NSURL *url = nil;
if (urlString) {
url = [NSURL URLWithString:urlString];
}
NSArray * activityItems = @[text, [NSURL URLWithString:urlString], image];
NSArray * applicationActivities = nil;
NSArray * excludeActivities = @[UIActivityTypeAssignToContact, UIActivityTypeCopyToPasteboard, UIActivityTypePostToWeibo, UIActivityTypePrint, UIActivityTypeMessage];
UIActivityViewController *activityVC =
[[UIActivityViewController alloc] initWithActivityItems:activityItems
applicationActivities:applicationActivities];
activityVC.excludedActivityTypes = excludeActivities;
[self.viewController presentViewController:activityVC animated:YES completion:nil];
}
@end |
I've tried it with your code. Local images still work, although some options are now no longer available in the share screen (Facebook, Print etc). When trying to share an external image, the app breaks with the following error: Any ideas? |
I'm sorry, I can't really help you beyond the code I posted. I don't know Obj-C at all. As far as the share options go, you can add/remove what you want excluded by editing this line: NSArray * excludeActivities = @[UIActivityTypeAssignToContact, UIActivityTypeCopyToPasteboard, UIActivityTypePostToWeibo, UIActivityTypePrint, UIActivityTypeMessage]; |
Wouldn't posting external images break cross-domain security rules? I am not sure if such posting is possible using standard iOS flows. I believe you have to cash the image first and then post its local copy through to the framework. On Jul 23, 2013, at 7:58 AM, Jelmer van Dulst [email protected] wrote:
|
I can see Twitter but Facebook has disappeared, any idea why? |
After installing the plugin on a fresh codebase (Cordova 2.5) it doesn't seem to work as expected:
The text was updated successfully, but these errors were encountered: