Skip to content
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

Image Sharing for WhatsApp is not working #280

Closed
iSaadSalman opened this issue Jun 18, 2018 · 32 comments
Closed

Image Sharing for WhatsApp is not working #280

iSaadSalman opened this issue Jun 18, 2018 · 32 comments
Labels
bug help wanted os: ios stale There has been a lack of activity on this issue and it may be closed soon.

Comments

@iSaadSalman
Copy link

iSaadSalman commented Jun 18, 2018

So I'm saving a screenshot locally and passing the URI to Share options. Its working fine for every platform except Whats App.

`let shareOptions = {
title: "Share",
url: this.state.cameraRollUri,
type: 'image/png',
message: "Here it is",
subject: "Share Link", // for email,
};

Share.open(shareOptions)`

Just message appears but no image

@jgcmarins
Copy link
Member

@iSaadSalman application is crashing?
Do you have a stack trace?

@iSaadSalman
Copy link
Author

iSaadSalman commented Jun 18, 2018

@jgcmarins No it’s not crashing. Just the image is not being shared in WhatsApp. Check the description I wrote in op.

@jgcmarins
Copy link
Member

Is it happening on both platforms?

@iSaadSalman
Copy link
Author

@jgcmarins Just testing on iOS right now. It's happening there.

@iSaadSalman
Copy link
Author

@jgcmarins Do you have any idea what could be the problem?

@enieber enieber added this to To do in version 1.0.28 via automation Jun 19, 2018
@gaganjot-singh01
Copy link

Same problem

@iSaadSalman
Copy link
Author

@jgcmarins Any update on this?

@jgcmarins
Copy link
Member

jgcmarins commented Jun 30, 2018

@iSaadSalman can you try master branch?

@iSaadSalman
Copy link
Author

@jgcmarins I tried by overwriting the module in node_modules since I'm not able to update via npm.

I'm receiving this build error in Xcode:
Undefined symbols for architecture arm64: "_OBJC_CLASS_$_InstagramShare", referenced from: objc-class-ref in libRNShare.a(RNShare.o) ld: symbol(s) not found for architecture arm64 clang: error: linker command failed with exit code 1 (use -v to see invocation)

@iSaadSalman
Copy link
Author

@jgcmarins any update?

@jgcmarins
Copy link
Member

@iSaadSalman I could not take a deeper look.
But if you want to help us, PRs are welcome.

@jgcmarins
Copy link
Member

@jgcmarins I tried by overwriting the module in node_modules since I'm not able to update via npm.

I'm receiving this build error in Xcode:
Undefined symbols for architecture arm64: "OBJC_CLASS$_InstagramShare", referenced from: objc-class-ref in libRNShare.a(RNShare.o) ld: symbol(s) not found for architecture arm64 clang: error: linker command failed with exit code 1 (use -v to see invocation)

Your link is wrong here.
I recommend to remove all node_modules, install lib again, following README and also link again.

@kkbhav
Copy link
Collaborator

kkbhav commented Jul 4, 2018

@iSaadSalman can you please check after removing 'message' from options, if it is working or not. Whatsapp only allows one of them to be used, i.e. you can only use message or url at a time for whatsapp.

@iSaadSalman
Copy link
Author

@kkbhav sorry for the very late reply. Yeah you are right if I remove the message image shows up

@jgcmarins
Copy link
Member

Is this a bug or what? Can we close this one?
@iSaadSalman what do you think? README must be updated?

@iSaadSalman
Copy link
Author

@jgcmarins Well if the message overwriting URL is enforced, this but has been resolved

@iSaadSalman
Copy link
Author

@jgcmarins If you can, maybe add a readme note about this so people know

@jgcmarins jgcmarins added help wanted and removed bug labels Jul 16, 2018
@ahaus
Copy link

ahaus commented Dec 14, 2018

The problem with message override still exists. Url does not work if I add a message field. Tested with version 1.1.3.

@jgcmarins jgcmarins added the bug label Dec 14, 2018
@mjm918
Copy link

mjm918 commented Jan 7, 2019

any update?

@KPS250
Copy link

KPS250 commented Feb 25, 2019

The issue is only on iOS. For Android it works well. Any update on this?

@tktdw
Copy link

tktdw commented Mar 13, 2019

share image on WA work on my Device, and shareOption like this

let shareOptions = {
title: "",
url: this.state.cameraRollUri,
message: "",
subject: "", // for email,
}

then i add code

} else if ([options[@"url"] rangeOfString:@"wai"].location != NSNotFound || [options[@"url"] rangeOfString:@"png"].location != NSNotFound || [options[@"url"] rangeOfString:@"jpg"].location != NSNotFound) {
NSLog(@"Sending whatsapp image");

        documentInteractionController = [UIDocumentInteractionController interactionControllerWithURL:[NSURL fileURLWithPath:options[@"url"]]];
        documentInteractionController.UTI = @"net.whatsapp.image";
        documentInteractionController.delegate = self;
        [documentInteractionController presentOpenInMenuFromRect:CGRectMake(0, 0, 0, 0) inView:[[[[[UIApplication sharedApplication] delegate] window] rootViewController] view] animated:YES];
        NSLog(@"Done whatsapp image");
        successCallback(@[]);

on file WhatsAppShare.m line 49

if ([options[@"url"] rangeOfString:@"wam"].location != NSNotFound || [options[@"url"] rangeOfString:@"mp4"].location != NSNotFound) {
.....
successCallback(@[]);
// add code here
} else {
text = (NSString*)CFBridgingRelease(CFURLCreateStringByAddingPercentEscapes(NULL,(CFStringRef) text, NULL,CFSTR("!*'();:@&=+$,/?%#[]"),kCFStringEncodingUTF8));
......
}
}

@farhanaslam5151
Copy link

farhanaslam5151 commented May 20, 2019

url property will not work on android, try this
onSharePress = (image) => Share.share({
title: 'Pk Flyer offer',
message: 'your message here '+image,
url: Platform.OS === 'ios' ? image :"" //this will work only on ios
subject: 'Offer'
});

@LionelLindt
Copy link

LionelLindt commented Oct 25, 2019

url property will not work on android, try this
onSharePress = (image) => Share.share({
title: 'Pk Flyer offer',
message: 'your message here '+image,
url: Platform.OS === 'ios' ? image :"" //this will work only on ios
subject: 'Offer'
});

Share.share is a method from React Native Share, and not from this library, here it is open.

@EnclaveAnthony
Copy link

share image on WA work on my Device, and shareOption like this

let shareOptions = {
title: "",
url: this.state.cameraRollUri,
message: "",
subject: "", // for email,
}

then i add code

} else if ([options[@"url"] rangeOfString:@"wai"].location != NSNotFound || [options[@"url"] rangeOfString:@"png"].location != NSNotFound || [options[@"url"] rangeOfString:@"jpg"].location != NSNotFound) {
NSLog(@"Sending whatsapp image");

        documentInteractionController = [UIDocumentInteractionController interactionControllerWithURL:[NSURL fileURLWithPath:options[@"url"]]];
        documentInteractionController.UTI = @"net.whatsapp.image";
        documentInteractionController.delegate = self;
        [documentInteractionController presentOpenInMenuFromRect:CGRectMake(0, 0, 0, 0) inView:[[[[[UIApplication sharedApplication] delegate] window] rootViewController] view] animated:YES];
        NSLog(@"Done whatsapp image");
        successCallback(@[]);

on file WhatsAppShare.m line 49

if ([options[@"url"] rangeOfString:@"wam"].location != NSNotFound || [options[@"url"] rangeOfString:@"mp4"].location != NSNotFound) {
.....
successCallback(@[]);
// add code here
} else {
text = (NSString*)CFBridgingRelease(CFURLCreateStringByAddingPercentEscapes(NULL,(CFStringRef) text, NULL,CFSTR("!*'();:@&=+$,/?%#[]"),kCFStringEncodingUTF8));
......
}
}

Yes. It works. But we need sharing with a caption. Does anyone have a solution for this?

@prajnarobo
Copy link

share image on WA work on my Device, and shareOption like this

let shareOptions = {
title: "",
url: this.state.cameraRollUri,
message: "",
subject: "", // for email,
}

then i add code

} else if ([options[@"url"] rangeOfString:@"wai"].location != NSNotFound || [options[@"url"] rangeOfString:@"png"].location != NSNotFound || [options[@"url"] rangeOfString:@"jpg"].location != NSNotFound) {
NSLog(@"Sending whatsapp image");

        documentInteractionController = [UIDocumentInteractionController interactionControllerWithURL:[NSURL fileURLWithPath:options[@"url"]]];
        documentInteractionController.UTI = @"net.whatsapp.image";
        documentInteractionController.delegate = self;
        [documentInteractionController presentOpenInMenuFromRect:CGRectMake(0, 0, 0, 0) inView:[[[[[UIApplication sharedApplication] delegate] window] rootViewController] view] animated:YES];
        NSLog(@"Done whatsapp image");
        successCallback(@[]);

on file WhatsAppShare.m line 49

if ([options[@"url"] rangeOfString:@"wam"].location != NSNotFound || [options[@"url"] rangeOfString:@"mp4"].location != NSNotFound) {
.....
successCallback(@[]);
// add code here
} else {
text = (NSString*)CFBridgingRelease(CFURLCreateStringByAddingPercentEscapes(NULL,(CFStringRef) text, NULL,CFSTR("!*'();:@&=+$,/?%#[]"),kCFStringEncodingUTF8));
......
}
}

Yes. It works. But we need sharing with a caption. Does anyone have a solution for this?

Any solution for this?

@msaqlain
Copy link

msaqlain commented Feb 4, 2020

Facing same issue any update?

@EnclaveAnthony
Copy link

It is impossible. Just share only message or image. Not both.

@msaqlain
Copy link

msaqlain commented Feb 4, 2020

@EnclaveAnthony Is there any way we can send two messages in one share. One for image and next for message.

@tktdw
Copy link

tktdw commented Feb 4, 2020

from this latest release note for Whatsapp. Enclave is right

@shreyakupadhyay
Copy link

I have found a working workaround for this problem. Currently, I also use it in one of my applications. You can directly plug and play the below onClick function on a button press.

RNFS.downloadFile, downloads the remote image using URL and save it to a path.
RNFS.readFile, converts the locally saved file data to base64 which is supported directly by Whatsapp and other applications.

async onClick(url, id){
        const path = `${RNFS.DocumentDirectoryPath}/${id}.jpg`;
        await RNFS.downloadFile({ fromUrl: url, toFile: `file://${path}` }).promise
            .then((res) => {
                return res;
            })
            .catch((err) => {
                return err;
            });
        RNFS.readFile(`file://${path}`, 'base64').then((res) => {
            let shareOptionsUrl = {
                title: 'My Application',
                message: 'Use my application',
                url: `data:image/jpeg;base64,${res}`, // use image/jpeg instead of image/jpg
                subject: 'Share information from your application'
            };
            Share.open(shareOptionsUrl);
        })
    }

Url is the image remote URL and id is some unique identifier for that image.

@tarbundiyahitesh21
Copy link

tarbundiyahitesh21 commented Oct 29, 2020

Share.shareSingle(options) share image on whatsapp is not working while Share.open(options) working perfectly.
any solution in ios?

I tried many solution like:
=> pass base64 data in url
=> pass image path in url
this all option perfectly working on facebook sharing but whenever we try on whatsapp is not working.

@github-actions
Copy link

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. You may also mark this issue as a "discussion" and i will leave this open

@github-actions github-actions bot added the stale There has been a lack of activity on this issue and it may be closed soon. label May 19, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug help wanted os: ios stale There has been a lack of activity on this issue and it may be closed soon.
Projects
No open projects
version 1.0.28
  
To do
Development

No branches or pull requests