Search Unity

Native Share for Android & iOS [Open Source]

Discussion in 'Assets and Asset Store' started by yasirkula, Mar 1, 2018.

  1. yasirkula

    yasirkula

    Joined:
    Aug 1, 2011
    Posts:
    1,179
    Please check logcat for any error messages. In addition, please share the relevant parts of your sharing script here.
     
  2. NewGame789

    NewGame789

    Joined:
    May 16, 2019
    Posts:
    15
    i didn't get an error in unity

    this is the sharing script

    using System.Collections;
    using System.Collections.Generic;
    using UnityEngine;
    using UnityEngine.UI;

    public class Urls : MonoBehaviour {


    public string RateUsUrl;

    public string ShareUrl;





    public void RateUs ()
    {
    Application.OpenURL (RateUsUrl);
    }


    public void Share ()
    {
    new NativeShare().SetText( ShareUrl ).Share();
    }


    }
     
  3. yasirkula

    yasirkula

    Joined:
    Aug 1, 2011
    Posts:
    1,179
  4. Ikaro88

    Ikaro88

    Joined:
    Jun 6, 2016
    Posts:
    69
    at the and was an android problem, with another device all work GREAT!!

    THANK YOU A LOT MY SAVIOR!
     
  5. NewGame789

    NewGame789

    Joined:
    May 16, 2019
    Posts:
    15
    I found the problem is the space between "ShareUrl" .SetText( ShareUrl ) should be .SetText(ShareUrl)

    thank you so much for your help
     
  6. Vasilis-Mbakalis

    Vasilis-Mbakalis

    Joined:
    May 23, 2017
    Posts:
    16
    Hi! I want to ask a question, I have a created an app for android and iOS and i download some files from a server and i want the user to be able to open the download file.I was using openURL for this but it is not possible any more.Can your asset help me with that?
     
  7. yasirkula

    yasirkula

    Joined:
    Aug 1, 2011
    Posts:
    1,179
    NativeShare doesn't have such functionality, sorry :/
     
  8. KRSBX

    KRSBX

    Joined:
    Nov 18, 2016
    Posts:
    10
    So, I import the plugin from the asset store and i copy the example code and i tried to run it in my phone but nothing happens. Any idea how to fix it? Currently using Unity 2019.1.7f1
     
  9. yasirkula

    yasirkula

    Joined:
    Aug 1, 2011
    Posts:
    1,179
    Did you attach the component (example script) to an object in your scene? If so, please check logcat or Xcode console for any meaningful error messages.
     
  10. xuan_celestial

    xuan_celestial

    Joined:
    Jul 17, 2018
    Posts:
    7
    Hi, is it possible for this plugin to support sharing on LinkedIn?
     
  11. yasirkula

    yasirkula

    Joined:
    Aug 1, 2011
    Posts:
    1,179
    If LinkedIn doesn't appear in the apps list, then try omitting subject/text/image from the shared content (e.g. try sharing only image or only text). It is possible that LinkedIn doesn't accept image+text sharing via native functions that NativeShare uses.
     
  12. Voloda2

    Voloda2

    Joined:
    Jan 7, 2017
    Posts:
    5
    NativeShare works only for iOS and don't work for android. What is wrong?


    Code (CSharp):
    1. var fileName = "stamps.pdf";
    2.         var pdfPath = Application.streamingAssetsPath + "/" + fileName;
    3.         if (System.IO.File.Exists(pdfPath)) {
    4.  
    5.             new NativeShare().AddFile(pdfPath).SetSubject("Марки").SetText("Марки").Share();
    6.         }
     
  13. yasirkula

    yasirkula

    Joined:
    Aug 1, 2011
    Posts:
    1,179
  14. xuan_celestial

    xuan_celestial

    Joined:
    Jul 17, 2018
    Posts:
    7
    Thank you for this awesome plugin, it works for me at least. One more thing to know:

    Can I filter/limit the user on what they can share on? Eg: I wanted user to only able to share on facebook & twitter
     
  15. yasirkula

    yasirkula

    Joined:
    Aug 1, 2011
    Posts:
    1,179
  16. xuan_celestial

    xuan_celestial

    Joined:
    Jul 17, 2018
    Posts:
    7
    It is possible to have a workaround for let say I wanted to share A content on Mail, and B content on Facebook, and C content on Twitter, etc
     
  17. kniger33

    kniger33

    Joined:
    Jul 14, 2018
    Posts:
    2
    Hi! I have a 2 little problems.
    1) If my app is locked by app locker(by password or fingerprint) and I try to share image, in my first try it will return me "error" or nothing to share. And in next try, when app to share is unlock, it works correctly.
    2) On some android devices not appear apps to share in my unity app, but in empty unity app with only native share it works good and shows all available apps.
    Thanks a lot.
     
  18. yasirkula

    yasirkula

    Joined:
    Aug 1, 2011
    Posts:
    1,179
    @xuan_celestial It might be possible but I've no such experience, sorry.

    @kniger33 1) You mean e.g. locking WhatsApp with app locker and then sharing on WhatsApp, right? Does the Gallery app's native share sheet work properly, though? If so, please check logcat for any meaningful error messages (I'm assuming that the "error" message is displayed on screen). 2) So, you have two NativeShare-integrated apps and app 1's share sheet doesn't work on some Android devices but app 2's share sheet works on all Android devices, am I correct? If so, honestly, I'm not sure what the issue here would be.
     
  19. kniger33

    kniger33

    Joined:
    Jul 14, 2018
    Posts:
    2
    1) Thanks, I will try it.
    2) Not exactly. Both of apps are install on one Android device. In the case of empty app with NativeShare-integrated only it shows all available to share app, and in second case it doesnt. But on other device with same Android version it works good in both cases.
     
  20. yasirkula

    yasirkula

    Joined:
    Aug 1, 2011
    Posts:
    1,179
    I can't say what would be causing this issue. The exact same code is executing on all those devices, maybe the problem has something to do with the file you're passing to the AddFile function? On some phones, the file is maybe not existent? You can check logcat to see if it is the case, there will be a "File does not exist at path or permission denied" log.
     
  21. xuan_celestial

    xuan_celestial

    Joined:
    Jul 17, 2018
    Posts:
    7
    Hi Yasir, another question here :

    is there a way, i can share some images that stored internally within my Resources/ folder, if so, which path and how should I access them to share them
     
  22. yasirkula

    yasirkula

    Joined:
    Aug 1, 2011
    Posts:
    1,179