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

window.plugins.socialsharing.shareWithOptions failed to sent pdf in Whatapps #856

Open
WilsonYHChan opened this issue Jul 19, 2017 · 3 comments

Comments

@WilsonYHChan
Copy link

Hi, i am using Android phone and manage to use window.plugins.socialsharing.shareViaEmail to sent email together with the attachment as below:

window.plugins.socialsharing.shareViaEmail(
'Document sent from Testing',
'Test Subject AAA',
['abcd@gmail.com'],
null, // CC: must be null or an array
null, // BCC: must be null or an array
['file:///storage/MicroSD/Download/testAttach.pdf'],
null, null
);
*** if i remove one slash in file:///xxx become file://xxx , the attachemnt will not able to attach in the email.

my problem is when i try to use window.plugins.socialsharing.shareWithOptions as below, the attachment cannot attach into whatapps, only message appear in whatapps. i have try to set the option as

files: pdfBase64String, or
files: 'file:///storage/MicroSD/Download/testAttach.pdf',

the attachment is missing but no error. if i change it to

files: [pdfBase64String], or
files: ['file:///storage/MicroSD/Download/testAttach.pdf'], below error occur:

Sharing failed with message: Attempt to invoke virtual method 'android.....' on a null object reference

            var pdfBase64String = 'data:application/pdf;df:myOwnName.pdf;base64,' + 'jkAAABccaj..';
            try {
                var options = {
                    message: 'Document sent from Testing',
                    subject: 'Hi, i am email subject here', 
                    files: pdfBase64String, 
                    chooserTitle: 'Pick an app and share' 
                }
                var onSuccess = function (result) {
                }
                var onError = function (msg) {
                }
                window.plugins.socialsharing.shareWithOptions(options, onSuccess, onError);
            }
            catch (err) {
                alert(err.message);
            }

Any idea what is the probelm ???

Thanks.

@mfdeveloper
Copy link

mfdeveloper commented Mar 1, 2018

@WilsonYHChan I've got the same problem using window.plugins.socialsharing.share() method. Did you resolve this? @EddyVerbruggen, can you help us ? Please!! 😅

@EddyVerbruggen
Copy link
Owner

No time. But PR’s are accepted as always.

@mfdeveloper
Copy link

mfdeveloper commented Mar 2, 2018

Hey @WilsonYHChan @EddyVerbruggen, I found a solution for whatsapp:

For some reason, you can't pass message. If you pass message + files parameter, whatsapp ignores the files and share the text msg. This is strange, and I don't know why, but it works!

So, the code to share for any app, is:

window.plugins.socialsharing.share(null | "", "My subject", ["native/path/of/myfile.extension"]);

Only for whatsapp:

window.plugins.socialsharing.shareViaWhatsApp(null | "", ["native/path/of/myfile.extension"]);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants