Giter VIP home page Giter VIP logo

Comments (6)

ibenettaleb avatar ibenettaleb commented on August 24, 2024 1

Thank you very much #yasirkula you are awesome 👍 😃

from unitynativeshare.

yasirkula avatar yasirkula commented on August 24, 2024

You can either share the download link as plain text (SetText), or download the PDF file to the device and then share it as a file (AddFile).

P.S. Sharing the download link as plain text may not work as desired; e.g. if user decides to share on Facebook, it will be shared as a link rather than as an attached file.

from unitynativeshare.

ibenettaleb avatar ibenettaleb commented on August 24, 2024

You Can Put C# Example Code.

from unitynativeshare.

yasirkula avatar yasirkula commented on August 24, 2024

How do you plan to share the PDF? As a link or as a file?

from unitynativeshare.

ibenettaleb avatar ibenettaleb commented on August 24, 2024

The PDF are in Node Js serve in Public folder i want to download and put it in piece joint send after that deleted

from unitynativeshare.

yasirkula avatar yasirkula commented on August 24, 2024
using System.Collections;
using System.IO;
using UnityEngine;
using UnityEngine.Networking;

public void Share( string url )
{
	StartCoroutine( DownloadAndShare( url ) );
}

private IEnumerator DownloadAndShare( string url )
{
	// Credit: https://docs.unity3d.com/Manual/UnityWebRequest-CreatingDownloadHandlers.html
	var uwr = new UnityWebRequest( url, UnityWebRequest.kHttpVerbGET );
	string path = Path.Combine( Application.temporaryCachePath, "temp.pdf" );
	uwr.downloadHandler = new DownloadHandlerFile( path );
	
	yield return uwr.SendWebRequest();
	
	if( uwr.isNetworkError || uwr.isHttpError )
		Debug.LogError( uwr.error );
	else
		new NativeShare().AddFile( path ).Share();
	
	// It may not be safe to delete the file immediately afterwards,
	// maybe it is currently being shared? Instead, you can delete the file
	// at that "path" later in your app's lifecycle or when your app starts
	// File.Delete( path );
}

from unitynativeshare.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.