Search Unity

Native Share for Android & iOS [Open Source]

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

Thread Status:
Not open for further replies.
  1. kushwaha03

    kushwaha03

    Joined:
    Dec 18, 2019
    Posts:
    39
    Thanks for response.
     
  2. nbkhanhdhgd

    nbkhanhdhgd

    Joined:
    Apr 19, 2016
    Posts:
    23
  3. yasirkula

    yasirkula

    Joined:
    Aug 1, 2011
    Posts:
    2,879
    Probably an update to Instagram broke the sharing feature. I've found this stackoverflow entry, so the issue is probably not related to NativeShare: Instagram Android Share Intent: Unable to load image. I'd expect the Instagram team to push an update in the following days.
     
  4. nbkhanhdhgd

    nbkhanhdhgd

    Joined:
    Apr 19, 2016
    Posts:
    23
    Thank you for your answer soon.
    But why did you know Instagram update is error?
    I have read document about Instagram and it said that API will update in March 31, 2020.
    https://www.instagram.com/developer/
     
  5. yasirkula

    yasirkula

    Joined:
    Aug 1, 2011
    Posts:
    2,879
    If you read the stackoverflow entry, you'll see that I'm not the only one thinking that Instagram update is error. The API update you've mentioned seems to be related to the usage of Instagram SDKs, NativeShare doesn't use any app-specific SDKs so it shouldn't be affected.
     
  6. nessuka

    nessuka

    Joined:
    Apr 6, 2020
    Posts:
    5
    Hi, is there a way to use NativeShare through Facebook and Instagram websites instead of apps?
    That's because I need to have a way to logout every account logged in them and I can't find a way to logout from Facebook and Instagram apps through my app script.
    Thanks for helping in advance and for the plugin
     
  7. yasirkula

    yasirkula

    Joined:
    Aug 1, 2011
    Posts:
    2,879
    I haven't seen this functionality in any share sheet. NativeShare uses OS's share sheet functionality, so I don't think it is possible.
     
  8. brockemon

    brockemon

    Joined:
    Dec 21, 2012
    Posts:
    48
    After deploying NativeShare to our users we found a small percentage are getting this error

    Input dispatching timed out (Waiting to send non-key event because the touched window has not finished processing certain input events that were delivered to it over 500.0ms ago. Wait queue length: 14. Wait queue head age: 14742.6ms.)

    It appears to be mostly these devices

    HUAWEI Y5 2018 (HWDRA-MG) 56 37.3%
    moto e5 play (pettyl) 11 7.3%
    AQUA LIONS T1 LITE (AQUA_LIONS_T1_LITE) 6 4.0%
    Redmi Go (tiare) 5 3.3%
    HUAWEI Y5 lite 2018 (HWCAG-L6737M) 3 2.0%

    Do you know what might be causing this. Do they not support the share functionality?

    Thanks for the plugin!

    Regards
    Brock White
     
  9. yasirkula

    yasirkula

    Joined:
    Aug 1, 2011
    Posts:
    2,879
    At first glance, it looks like a warning you can safely ignore. Are you sure that NativeShare is causing this? Even if it does, it should be fine as long as the share functionality isn't affected.
     
  10. brockemon

    brockemon

    Joined:
    Dec 21, 2012
    Posts:
    48
    It is only showing up in the latest version in which Native Share was added. That error is an ANR on Google Play Console. The version is going out to 4 million devices so should be pretty accurate.
     
  11. brockemon

    brockemon

    Joined:
    Dec 21, 2012
    Posts:
    48
    Does it count as an ANR if the user begins the share process and then closes the app?
     
  12. yasirkula

    yasirkula

    Joined:
    Aug 1, 2011
    Posts:
    2,879
    I see. Thanks for reporting this. I don't think I will be able resolve this issue without reproducing it myself, though. I don't have access to these devices, so you may not see any fixes for this issue in the near future.
     
  13. brockemon

    brockemon

    Joined:
    Dec 21, 2012
    Posts:
    48
    Going to test one more thing incase it is to do with a Unity Ads changed instead. Will get back to you in a few days. Hopefully it is that instead
     
    Last edited: Apr 15, 2020
  14. santhosh_kumar_15

    santhosh_kumar_15

    Joined:
    Nov 12, 2019
    Posts:
    2
    hi yasirkula am using your plugin to send invite to Facebook Friends but with this i can post this only i cant send private invites what can i do for i want to send invite to my friend through private message not to post on my timeline
    Thx adv :)
     
  15. yasirkula

    yasirkula

    Joined:
    Aug 1, 2011
    Posts:
    2,879
    You may need to install Facebook Messenger.
     
  16. mcolombo

    mcolombo

    Joined:
    Sep 27, 2017
    Posts:
    16
    Hi Yasirkula,

    Thanks for making this pluign.
    I have a question.

    I just used an up where they use a share and it shows like the image attached,
    How can I add the icon and the text "We need to talk"?

    Im guessing the icon is being from the site itself, but the header as well (add me on houseparty)?

    The only thing i can share (when sharing links) with your plugin is the link itself.

    Thanks!
    Screen Shot 2020-04-23 at 08.42.00.png
     
  17. yasirkula

    yasirkula

    Joined:
    Aug 1, 2011
    Posts:
    2,879
  18. mcolombo

    mcolombo

    Joined:
    Sep 27, 2017
    Posts:
    16
    Ahh sorry about that!
    Thank you so much
     
    yasirkula likes this.
  19. HajiyevEl

    HajiyevEl

    Joined:
    Feb 19, 2020
    Posts:
    47
  20. yasirkula

    yasirkula

    Joined:
    Aug 1, 2011
    Posts:
    2,879
    As much as I would like to help, I simply don't know how to resolve this issue. Perhaps other solutions like this don't suffer from this issue?
     
  21. HajiyevEl

    HajiyevEl

    Joined:
    Feb 19, 2020
    Posts:
    47
    Thanks for fast reply, but they all suffer from same issue.
    Implemented workaround (if it even can be called like that) switching to portrait orientation right after taking screenshot
    Code (CSharp):
    1. Screen.orientation = ScreenOrientation.Portrait;
    and switch back orientation after sharing
    Code (CSharp):
    1. Screen.orientation = ScreenOrientation.AutoRotation;
     
    yasirkula likes this.
  22. inappindia

    inappindia

    Joined:
    Jul 25, 2019
    Posts:
    4
    Hello, is there any way to get our share to look like when we share a YouTube video on WhatsApp, the thumbnail, along with the URL and a short description pops up. Is that possible to do? If so can you please explain how. (If you could add some example code as you did in the GitHub page, that would be excellent). Thanks for developing. Awsome plugin.
     
  23. inappindia

    inappindia

    Joined:
    Jul 25, 2019
    Posts:
    4
    Hey, is there any way to get our share to look like what happens when we share a YouTube video on WhatsApp, with the URL but at the same time a thumbnail, the title and description that comes along with it automatically? I want to put the app that I'm developing on the PlayStore and I want the same to happen when I share the playstore link. Great plugin btw. And excellent support. Thanks.

    Capture.PNG
     
  24. yasirkula

    yasirkula

    Joined:
    Aug 1, 2011
    Posts:
    2,879
  25. inappindia

    inappindia

    Joined:
    Jul 25, 2019
    Posts:
    4
    Hmm, Is that so? I see. Thanks anyway. Great plugin.
     
    Last edited: Apr 29, 2020
  26. Antony-Blackett

    Antony-Blackett

    Joined:
    Feb 15, 2011
    Posts:
    1,778
    Hey yasirkula,

    Your plugin is amazing and it's working well for me: I have a general native sharing question though. Do you know if it's possible to share a link without that link appearing in the text of the share as well?

    Here's what i get using native share
    Screenshot 2020-05-05 at 12.55.13 PM.png


    Here's an example of what I would like to achieve. (Specifically in facebook because facebook messenger android has a bug with deep links when clicking the link in the text)
    Screenshot 2020-05-05 at 12.55.29 PM.png

    Is there a way to add a NativeShare.SetLink() function or is that not something that native share can do because of platform API restrictions?
     
  27. yasirkula

    yasirkula

    Joined:
    Aug 1, 2011
    Posts:
    2,879
    I don't know how this can be achieved or if this can be achieved. A quick google search didn't yield any useful results for me.
     
  28. Antony-Blackett

    Antony-Blackett

    Joined:
    Feb 15, 2011
    Posts:
    1,778
    Thanks for having a look anyway. I’ve found a workaround for the facebook link bug so i can live with the link in text for now. If i find a way to not have it I’ll be sure to share that with you.
     
    yasirkula likes this.
  29. abermann_O

    abermann_O

    Joined:
    Aug 16, 2018
    Posts:
    42
    Hello, what a great plugin this is! I´ve trying for some time now to solve this, without success: how can I use
    AddFile( filePath ), if I need filePath to be the path to an online jpg file? Thank you very much
     
  30. yasirkula

    yasirkula

    Joined:
    Aug 1, 2011
    Posts:
    2,879
    You need to download the file and save it to temporaryCachePath or persistentDataPath, NativeShare doesn't support sharing files that are stored on the cloud.
     
  31. abermann_O

    abermann_O

    Joined:
    Aug 16, 2018
    Posts:
    42
    Thanks, crystal clear! May I ask you another question? I can´t get rid of the red underline on NativeShare declaration on the script. It doesn´t seems to affect the behavior of the script itself, but maybe I can fix it adding some directive on the script? Thanks again!

     
  32. yasirkula

    yasirkula

    Joined:
    Aug 1, 2011
    Posts:
    2,879
    You don't need any using directives. I'm suspecting that this is a Visual Studio issue. Perhaps restarting both Unity and Visual Studio would resolve this issue? Otherwise, please make sure that Visual Studio Tools for Unity is installed.
     
  33. abermann_O

    abermann_O

    Joined:
    Aug 16, 2018
    Posts:
    42
    Hi, new question about this plugin (which I find amazing, btw).
    If I drop an image on WhatsApp and write some text under it, I get this:
    Pic1.jpg

    But when I do that with Nativeshare (same image, same text), I get this:
    Pic2.jpg

    The image shrinks somehow, it doesn´t make any difference if there is any text or not. It seems that the AR of the image makes a difference (for instance, if I modify the height of the image, that affects how is cropped in its weight in Whatsapp... it´s like when publish, it tends to a square shape, an 1:1 AR) Other than that, it works perfect, so I assume this must be something I´m doing wrong, but I can´t figure it out, so if anyone could help me, that would be great, thanks!!
     
  34. yasirkula

    yasirkula

    Joined:
    Aug 1, 2011
    Posts:
    2,879
    I can't find any related topics on google, so I'm as clueless at the moment. You can try loading the image to Unity via Texture2D.LoadImage to see if the image itself has these black borders, as well.
     
  35. nastenke

    nastenke

    Joined:
    Mar 3, 2017
    Posts:
    5
    Hi,
    I'm trying to publish my app with NativeShare plugin in App Store and they rejected my app with this explanation:

    Guideline 5.1.1 - Legal - Privacy - Data Collection and Storage
    We noticed that your app requests the user’s consent to access their photos but does not clarify the use of the photos in the applicable purpose string.
    Next Steps
    Please revise the relevant purpose string in your app’s Info.plist file to specify why the app is requesting access to the user's photos. You can modify your app's Info.plist file using the property list editor in Xcode.
    To help users understand why your app is requesting access to their personal data, all permission request alerts in your app should specify how your app will use the requested feature.
    Resources
    For additional information and instructions on requesting permission, please review the Requesting Permission section of the iOS Human Interface Guidelines and the Information Property List Key Reference. You may also want to review the Technical Q&A QA1937: Resolving the Privacy-Sensitive Data App Rejection page for details on how to provide a usage description for permission request alerts.
    Please help me. How to fix it?
     
  36. yasirkula

    yasirkula

    Joined:
    Aug 1, 2011
    Posts:
    2,879
    NativeShare adds a PHOTO_LIBRARY_USAGE_DESCRIPTION to Info.plist because selecting the "Save to Photos" option in the share sheet automatically asks for Photos permission (asked by OS, not NativeShare) and this description is displayed in the permission dialog. You can try changing it to
    "Save shared image to Photos"
    . I'd recommend you to double check your Info.plist file inside Xcode to verify that it contains this Photos description.
     
  37. nastenke

    nastenke

    Joined:
    Mar 3, 2017
    Posts:
    5
    Yes, you are right. Thank you. works and approved
     
  38. abermann_O

    abermann_O

    Joined:
    Aug 16, 2018
    Posts:
    42
    Hi, I´m developing in Android.

    If I want to share something in Facebook, I use
    Code (CSharp):
    1. myShare.SetTarget("com.facebook.katana");
    (because that is the name at the end of the url of Facebook app in Google Play). Likewise, if I want to do it in Instagram, I use
    Code (CSharp):
    1. myShare.SetTarget("com.instagram.android");
    .
    All that works fine, the only problem is that Android show me in both cases the share sheet (if I do the same with WhatsApp or with Facebook Messenger, it goes straight to that app, which is the expected behavior).
    The other problem is that in all those situations -except for WhatsApp-, when I finish the sharing and go back from the target app (Facebook, Facebook Messenger or Instagram) to my app, the share sheet appear, even if it wasn´t there at first (Facebook Messenger).

    So I guess I have two questions here:
    1. Any hint to block the share sheet to appear?
    2. How can I go straight to Facebook or Instagram, without the share sheet appearing at first?

    Thanks in advance!
     
  39. yasirkula

    yasirkula

    Joined:
    Aug 1, 2011
    Posts:
    2,879
    When share sheet appears, it contains at least two entries (e.g. one for posting a Story and another one for posting to feed). Is it not the case for you? You meant that the share sheet appears upon returning to Unity; does it appear out of nowhere, without any user interaction?
     
  40. abermann_O

    abermann_O

    Joined:
    Aug 16, 2018
    Posts:
    42
    Yes, the share sheet offers me those options, depending on the target platform, so there is no way to hide it? Because my plan was to customize the apps offered to the user for sharing, but if the share sheet will be shown anyway, it doesn´t make too much sense to develop that.
    (yes, once the user returns to Unity, the share sheet appears when the focus is on the app)
     
  41. yasirkula

    yasirkula

    Joined:
    Aug 1, 2011
    Posts:
    2,879
    The recommended way is to fill the androidClassName field of SetTarget. This way, you tell NativeShare which one of these two options it should pick. Otherwise, you need to modify the native source code: replace line 142 here with line 140.

    If you are using the example code that triggers the share sheet inside GetMouseButtonDown, you can instead call NativeShare when a UI button is clicked. This should fix the issue with share sheet appearing again. Otherwise, make sure that your code isn't calling Share() twice, or calling it when returning to Unity.
     
  42. abermann_O

    abermann_O

    Joined:
    Aug 16, 2018
    Posts:
    42
    Thank you very much for your kind and clear answer. I´m actually using a UI button, so I´ll double check why the share sheet reappears when focus back in my app.
    Regarding your first paragraph, perfectly clear, but I couldn´t find that file you linked me to (NativeShare.java). Can you give me a hint where to find it, so I can edit it? Thanks!
     
    Last edited: May 18, 2020
  43. yasirkula

    yasirkula

    Joined:
    Aug 1, 2011
    Posts:
    2,879
    You'll have to create a new Android Studio project, add these 2 Java files to the project, make any changes you want, recompile the project and replace NativeShare.aar with the project's output. Lastly, you'll need to replace AndroidManifest.xml inside the .aar with this file. I'd recommend you to check out native Android plugin tutorials for Unity first.
     
  44. ixmas93

    ixmas93

    Joined:
    Mar 16, 2020
    Posts:
    8
    Hello Yasirkula, first, thanks so much for your plugin, nice job!
    I have a problem, in some devices, when i share the screenshot, the image its completely gray. Any idea why this happens? Maybe its for permissions? Android version?

    Looks like i am the only one with that problem over here! Thanks so much in advance :)
     
  45. yasirkula

    yasirkula

    Joined:
    Aug 1, 2011
    Posts:
    2,879
    Could you assign the screenshot to an Image or RawImage object to see if the screenshot itself (the generated Texture) is gray?
     
  46. shi_no_gekai

    shi_no_gekai

    Joined:
    Mar 3, 2018
    Posts:
    14
    Hello yasirkula, this asset is great! i have a small problem, i can't share with messenger, but posting on FB works fine
     
  47. yasirkula

    yasirkula

    Joined:
    Aug 1, 2011
    Posts:
    2,879
    Are you sharing an image with a text?
     
  48. nbkhanhdhgd

    nbkhanhdhgd

    Joined:
    Apr 19, 2016
    Posts:
    23
    Hi @yasirkula

    I have imported your plugin and when I open app, app is crashed. Here it error:
    Code (JavaScript):
    1. java.lang.RuntimeException: Unable to get provider com.yasirkula.unity.UnitySSContentProvider: java.lang.ClassNotFoundException: Didn't find class "com.yasirkula.unity.UnitySSContentProvider"
    Here my AndroidManifest.xml:
    Code (JavaScript):
    1. <?xml version="1.0" encoding="utf-8"?>
    2. <manifest
    3.     xmlns:android="http://schemas.android.com/apk/res/android"
    4.     package="com.unity3d.player"
    5.     android:installLocation="preferExternal"
    6.     android:theme="@android:style/Theme.NoTitleBar"
    7.     android:versionCode="1"
    8.     android:versionName="1.0">
    9.     <uses-sdk android:minSdkVersion="14" android:targetSdkVersion="22" />
    10.     <uses-feature android:name="android.hardware.camera" />
    11.     <supports-screens
    12.         android:smallScreens="true"
    13.         android:normalScreens="true"
    14.         android:largeScreens="true"
    15.         android:xlargeScreens="true"
    16.         android:anyDensity="true"/>
    17.     <uses-permission android:name="android.permission.INTERNET" />
    18.     <uses-permission android:name="android.permission.CAMERA" />
    19.     <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
    20.     <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    21.    
    22.     <application
    23.         android:icon="@drawable/app_icon"
    24.         android:label="@string/app_name"
    25.         android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
    26.         android:debuggable="false">
    27.      
    28.         <activity android:name="com.unity3d.player.UnityPlayerActivity"
    29.                   android:label="@string/app_name">
    30.             <intent-filter>
    31.                 <action android:name="android.intent.action.MAIN" />
    32.                 <category android:name="android.intent.category.LAUNCHER" />
    33.             </intent-filter>
    34.             <meta-data android:name="unityplayer.UnityActivity" android:value="true" />
    35.             <meta-data android:name="unityplayer.ForwardNativeEventsToDalvik" android:value="false" />
    36.         </activity>
    37.         <activity android:name="com.unity3d.player.VideoPlayer"
    38.                   android:label="@string/app_name"
    39.                   android:screenOrientation="portrait"
    40.                   android:configChanges="fontScale|keyboard|keyboardHidden|locale|mnc|mcc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|uiMode|touchscreen">
    41.         </activity>
    42.         <!--
    43.             To support devices using the TI S3D library for stereo mode we must
    44.             add the following library.
    45.             Devices that require this are: ODG X6
    46.         -->
    47.         <uses-library android:name="com.ti.s3d" android:required="false" />
    48.         <!--
    49.             To support the ODG R7 in stereo mode we must add the following library.
    50.         -->
    51.         <uses-library android:name="com.osterhoutgroup.api.ext" android:required="false" />
    52.  
    53.       <provider
    54.         android:name="com.yasirkula.unity.UnitySSContentProvider"
    55.         android:authorities="com.nativeshare.test"
    56.         android:exported="false"
    57.         android:grantUriPermissions="true" />
    58.      
    59.     </application>
    60. </manifest>
    61.  
    62. <!-- android:installLocation="preferExternal" -->
    63.  
    Can you help me resolved this problem?
    Thank you!
     
  49. yasirkula

    yasirkula

    Joined:
    Aug 1, 2011
    Posts:
    2,879
    You can delete the provider tag from AndroidManifest since latest versions of NativeShare automatically adds it to AndroidManifest.
     
  50. nbkhanhdhgd

    nbkhanhdhgd

    Joined:
    Apr 19, 2016
    Posts:
    23
    I have imported the lastest version of NativeShare, but it still have error :(
    Here my AndroidManifest.xml:
    Code (JavaScript):
    1. <?xml version="1.0" encoding="utf-8"?>
    2. <manifest
    3.     xmlns:android="http://schemas.android.com/apk/res/android"
    4.     package="com.unity3d.player"
    5.     android:installLocation="preferExternal"
    6.     android:theme="@android:style/Theme.NoTitleBar"
    7.     android:versionCode="1"
    8.     android:versionName="1.0">
    9.     <uses-sdk android:minSdkVersion="14" android:targetSdkVersion="22" />
    10.     <uses-feature android:name="android.hardware.camera" />
    11.     <supports-screens
    12.         android:smallScreens="true"
    13.         android:normalScreens="true"
    14.         android:largeScreens="true"
    15.         android:xlargeScreens="true"
    16.         android:anyDensity="true"/>
    17.     <uses-permission android:name="android.permission.INTERNET" />
    18.     <uses-permission android:name="android.permission.CAMERA" />
    19.     <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
    20.     <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    21.    
    22.     <application
    23.         android:icon="@drawable/app_icon"
    24.         android:label="@string/app_name"
    25.         android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
    26.         android:debuggable="false">
    27.       <provider
    28.         android:name="com.yasirkula.unity.UnitySSContentProvider"
    29.         android:authorities="MY_UNIQUE_AUTHORITY"
    30.         android:exported="false"
    31.         android:grantUriPermissions="true" />
    32.         <activity android:name="com.unity3d.player.UnityPlayerActivity"
    33.                   android:label="@string/app_name">
    34.             <intent-filter>
    35.                 <action android:name="android.intent.action.MAIN" />
    36.                 <category android:name="android.intent.category.LAUNCHER" />
    37.             </intent-filter>
    38.             <meta-data android:name="unityplayer.UnityActivity" android:value="true" />
    39.             <meta-data android:name="unityplayer.ForwardNativeEventsToDalvik" android:value="false" />
    40.         </activity>
    41.         <activity android:name="com.unity3d.player.VideoPlayer"
    42.                   android:label="@string/app_name"
    43.                   android:screenOrientation="portrait"
    44.                   android:configChanges="fontScale|keyboard|keyboardHidden|locale|mnc|mcc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|uiMode|touchscreen">
    45.         </activity>
    46.         <!--
    47.             To support devices using the TI S3D library for stereo mode we must
    48.             add the following library.
    49.             Devices that require this are: ODG X6
    50.         -->
    51.         <uses-library android:name="com.ti.s3d" android:required="false" />
    52.         <!--
    53.             To support the ODG R7 in stereo mode we must add the following library.
    54.         -->
    55.         <uses-library android:name="com.osterhoutgroup.api.ext" android:required="false" />
    56.     </application>
    57. </manifest>
    58.  
    59. <!-- android:installLocation="preferExternal" -->
    60.  
     
Thread Status:
Not open for further replies.