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

Is there any way to share an image together with text? #68

Open
odedBartov opened this issue Nov 2, 2020 · 2 comments
Open

Is there any way to share an image together with text? #68

odedBartov opened this issue Nov 2, 2020 · 2 comments

Comments

@odedBartov
Copy link

No description provided.

@nicolaric
Copy link

Would also like to see that!

@odedBartov
Copy link
Author

Would also like to see that!

I modified the original code and now it works.
In node_modules => nativescript-socail-share => social-share.android.js
Replace the function "shareImage" with the following:

function shareImage(image, subject) {
    numberOfImagesCreated++;
    context = application.android.context;
    var intent = getIntent("*/*");
    var stream = new java.io.ByteArrayOutputStream();
    image.android.compress(android.graphics.Bitmap.CompressFormat.JPEG, 100, stream);
    var imageFileName = "imageNum" + numberOfImagesCreated + ".jpg";
    var newFile = new java.io.File(context.getExternalFilesDir(null), imageFileName);
    var fos = new java.io.FileOutputStream(newFile);
    fos.write(stream.toByteArray());
    fos.flush();
    fos.close();
    var shareableFileUri;
    var sdkVersionInt = parseInt(platform.device.sdkVersion);
    if (sdkVersionInt >= 21) {
        shareableFileUri = FileProviderPackageName.FileProvider.getUriForFile(context, application.android.nativeApp.getPackageName() + ".provider", newFile);
    }
    else {
        shareableFileUri = android.net.Uri.fromFile(newFile);
    }
    intent.putExtra(android.content.Intent.EXTRA_STREAM, shareableFileUri);
    intent.putExtra(android.content.Intent.EXTRA_TEXT, subject);
    share(intent, subject);
}

You can just add another one for share with text instead of overriding the old one.
Notice that you will have to also update the interface for the new function

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

2 participants