yasirkula / UnityNativeShare

A Unity plugin to natively share files (images, videos, documents, etc.) and/or plain text on Android & iOS
MIT License
891 stars 131 forks source link

Share link on iOS #72

Closed fi4sk0 closed 3 years ago

fi4sk0 commented 4 years ago

Hey there @yasirkula and thanks for your assets. I just found them and they saved a ton of time for me! Keep up the good work!

Something I struggled with was to share links. I found out, that on iOS you can just send a list of objects to the share menu and depending on what kind of object they are, the menu changes.

Since I just wanted to share a link in my app, I changed line 24 of NativeShare.mm https://github.com/yasirkula/UnityNativeShare/blob/7beb32c3b2f0b71cf8b2a158bdecc08d95c8d986/Plugins/NativeShare/iOS/NativeShare.mm#L24

to

[items addObject:[NSURL URLWithString:filePath]];

but maybe there could be a more general approach? Maybe something new NativeShare().AddLink(). I haven't tested that yet but I'll probably run into the same problem on Android. Any thoughts on that?

Cheers, Timo

yasirkula commented 4 years ago

Does new NativeShare().SetText("INSERT_URL_HERE").Share(); not work? If it doesn't, I might have to change the code as you suggested.

cihadturhan commented 4 years ago

@yasirkula setText doesn't do the same thing because some apps use url to fetch website metada and add website image and title like below:

image

Nice plugin btw, thanks for your efforts.

yasirkula commented 4 years ago

AFAIK, WhatsApp can fetch the link from the text (SetText) and show the website metadata. Which apps failed to show the website metadata when using SetText? On which platform did this happen?

cihadturhan commented 4 years ago

I did a quick test by adding NSURL into share items. Seems like current solution works except twitter app:

IMG_5157 IMG_5158

I guess that's ok because it'll probably create website card after you press "tweet" button.

yasirkula commented 4 years ago

Thanks for the test! I also think that the current solution is OK at the moment.

icanb commented 3 years ago

+1, AddLink() method would be really nice