EddyVerbruggen / SocialSharing-PhoneGap-Plugin

👨‍❤️‍💋‍👨 Cordova plugin to share text, a file (image/PDF/..), or a URL (or all three) via the native sharing widget
MIT License
1.78k stars 907 forks source link

SocialSharing popup only shows when I close and open the app #703

Open dshaw002 opened 7 years ago

dshaw002 commented 7 years ago

I have the current version of SocialSharing (5.1.3) with Ionic 2 and latest Cordova.

On my phone iOS 10, when I open the app and tap the button to trigger the event, nothing happens. If I leave the app and open it again, however, the share popup shows.

Any ideas what's causing this? Other events don't have this issue.

jampod-dev commented 7 years ago

I was able to fix this by adding gap://ready to the default-src section of the Content Security Policy

shoebrizwanathar commented 7 years ago

Yeah! It worked for me as well!!

I am working on Ionic and Cordova project and was struggling with this issue. By adding gap://ready to the default-src section of the Content Security Policy works for opening share sheet smoothly without any blockage or hiding behind and also it works for Email Composer to open smoothly.

I have tested it on iOS 10.1 version iPhone and android.

Solution (1) Use this in your index.html in head section:

meta http-equiv="Content-Security-Policy" content="default-src gap://ready; style-src 'self' 'unsafe-inline'; script-src 'unsafe-inline' 'unsafe-eval'"

Solution (2)

remove this entire meta tag from index.html and use whitelist plugin of cordova because it will do all these things automatically. If you already have whitelist plugin installed then remove it and reinstall.

mateusbello commented 7 years ago

I have the exact same problem but the the solutions above didn't work.

I have

<meta http-equiv="Content-Security-Policy" content="default-src * gap://ready data: 'unsafe-eval'; img-src * data: gap://ready; frame-src *; connect-src * ; style-src * 'self' 'unsafe-inline' 'unsafe-eval'; media-src *; script-src * data: 'self' 'unsafe-inline' 'unsafe-eval' gap://ready; ">

and `

`

Any ideas why it does not work? Its fine on Android.

vinicoliveira commented 6 years ago

Hello. How did you solve it? I am still getting error!!!!

mateusbello commented 6 years ago

For me it was a matter of adding

<meta http-equiv="Content-Security-Policy" content="default-src * gap://ready data: 'unsafe-eval'; img-src * data: gap://ready; frame-src *; connect-src * ; style-src * 'self' 'unsafe-inline' 'unsafe-eval'; media-src *; script-src * data: 'self' 'unsafe-inline' 'unsafe-eval' gap://ready; ">

And changing the config.xml to have

  <allow-navigation href="*://*.mysite.com/*" />
  <allow-intent href="*" />
  <allow-navigation href="*" />
vinicoliveira commented 6 years ago

Hello. Thanks for your fast answer =] But it is still not working.

No errors...it just does not launch the sheet with apps.

$cordovaSocialSharing .share("My MSG", "My Title", '', 'https://mylink') .then(function(result) { alert(result); }, function(err) { alert(err); });

No alerts.

I put the meta tag in index.html And I addded the in config.xml

What is wrong?

mateusbello commented 6 years ago

If you close and open the app, does it work ? If not, it is something else not related to the issue on this topic.

vinicoliveira commented 6 years ago

no. it does not work. By the way, none of the $cordovaSocialSharing are working on iOS. I cannot get any error.

vinicoliveira commented 6 years ago

Let me update my answer..

The thing is... if I press the share button nothing happens. But if I press the share button and then focus an input the sheet appears.

mateusbello commented 6 years ago

Sorry but this is not related to this topic. Could you please create another one ? Thanks ... I'm not sure what is the issue you are having btw, but I guess it is not related to security.