Sharing a base64 image on facebook is not working currently, The share window opens without any image.
Heres the test code:
let shareImageBase64 = {
url: "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADwAAAA8CAMAAAANIilAAAAAYFBMVEUAAAAAQIAAWpwAX5kAX5gAX5gAX5gAXJwAXpgAWZ8AX5gAXaIAX5gAXpkAVaoAX5gAXJsAX5gAX5gAYJkAYJkAXpoAX5gAX5gAX5kAXpcAX5kAX5gAX5gAX5YAXpoAYJijtTrqAAAAIHRSTlMABFis4vv/JL0o4QvSegbnQPx8UHWwj4OUgo7Px061qCrcMv8AAAB0SURBVEjH7dK3DoAwDEVRqum9BwL//5dIscQEEjFiCPhubziTbVkc98dsx/V8UGnbIIQjXRvFQMZJCnScAR3nxQNcIqrqRqWHW8Qd6cY94oGER8STMVioZsQLLnEXw1mMr5OqFdGGS378wxgzZvwO5jiz2wFnjxABOufdfQAAAABJRU5ErkJggg==", //this.props.screen,
social: "facebook"
};
Share.shareSingle(shareImageBase64);
Here is the output on Android:
SHARE SINGLE METHOD
com.facebook.katana
INSTALLED
java.io.FileNotFoundException: /storage/emulated/0/Download/1500128174012.png (Permission denied)
at java.io.FileOutputStream.open(Native Method)
at java.io.FileOutputStream.<init>(FileOutputStream.java:221)
at java.io.FileOutputStream.<init>(FileOutputStream.java:169)
at cl.json.ShareFile.getURI(ShareFile.java:120)
at cl.json.social.ShareIntent.open(ShareIntent.java:49)
at cl.json.social.SingleShareIntent.open(SingleShareIntent.java:41)
at cl.json.social.FacebookShare.open(FacebookShare.java:22)
at cl.json.RNShareModule.shareSingle(RNShareModule.java:63)
at java.lang.reflect.Method.invoke(Native Method)
at com.facebook.react.cxxbridge.JavaMethodWrapper.invoke(JavaMethodWrapper.java:372)
at com.facebook.react.cxxbridge.JavaModuleWrapper.invoke(JavaModuleWrapper.java:162)
at com.facebook.react.bridge.queue.NativeRunnable.run(Native Method)
at android.os.Handler.handleCallback(Handler.java:751)
at android.os.Handler.dispatchMessage(Handler.java:95)
at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(MessageQueueThreadHandler.java:31)
at android.os.Looper.loop(Looper.java:154)
at com.facebook.react.bridge.queue.MessageQueueThreadImpl$3.run(MessageQueueThreadImpl.java:199)
at java.lang.Thread.run(Thread.java:761)
I guess you save base64 to a file and then sharing the file. However on android M+ we need write external storage permission for that. So actually when I’m opening this issue, I just answered my question, but still better the issue stays here for others. Maybe this could be added into document or include permission request before sharing base64 for ease of use.
ask for persmissions