Location>code7788 >text

FAQ】HarmonyOS SDK Closed Source Open Capability -Share Kit

Popularity:511 ℃/2024-11-18 10:55:11

1. Description of the problem:

To share a local file using the system sharing component, click "Save As" under the sharing menu to share the file to the system file management, and view the shared file in the file management as 0B. 3 uri writing methods have been tried, the code is as follows:

const uri = getContext().getApplicationContext().filesDir + '/'
const uri1 = 'file://' + getContext().getApplicationContext().filesDir + '/'
const uri2 = 'file://' + getContext(). + '/' + getContext().getApplicationContext().filesDir + '/'

Solution:

The correct uri splice should be:

const uri = 'file://' + getContext(). + getContext().getApplicationContext().filesDir + '/';

Or convert the sandbox path to a uri via getUriFromPath:

let pathInSandbox = 'getContext().getApplicationContext().filesDir + '/';
let uri = (pathInSandbox);

2. Description of the problem:

(computer) file/consumer/cn/doc/harmonyos-references-V5/share-system-share-V5#section20696483813 SharedRecord uriWhether or not to supporthttplink (on a website)?

Solution:

The haredRecord uri supports http links.

3. Description of the problem:

Calling the system to share an image or file and clicking the save button in the system sharing panel prompts a save failure.

demo:

const data = new ({

      utd: ,

      uri: (path)

    })

    const controller = new (data)

    const context = ().getApp() as 

    (context, {

      selectionMode: ,

      previewMode: 

    })

Solution:

The current known failure scenarios can be caused by file names containing symbols not supported by media library naming. In the gallery rename, add a . / these symbols, you will see a hint about it and all unsupported characters will be listed;

Our side test Chinese is normal, if the feedback Chinese have problems, please provide a log, or other information that can help us check the problem, contact /consumer/cn/support/feedback/#/?feedbackchannel=PPSD0001

4. Description of the problem:

How to realize the app sharing to WeChat, displaying as a card, and clicking to open the specific link page?

Solution:

The Share Kit provides two capabilities: the host app initiates the share and the target app handles the content:

Where the host app initiates the share, which pulls up the Share Kit's sharing panel, and the target app handles the content of the share, which processes the received share information.

The specific display effect is parsed by the accessor to display the final card effect according to the sharedata data format.

5. Description of the problem:

App needs to use file sharing related functions, uris is a must configure, if you delete the related configuration, then the app can not receive the message, please ask what should be done.

Solution:

1, uris and actions can exist at the same time. However, actions and uris cannot be in the same object, they need to be in different objects.

2、Taking the skills on the homepage as an example, the skills configuration below can receive messages normally and there is no problem in clicking on them:

“skills”: [

    {

“entities”: [

“”

      ],

“actions”: [

“”,

“”,

      ]

    },

    {

“uris”: [

        {

“scheme”: “https”,

“port”:“8080”,

“host”: “”,

“path”: “notify_detai”

      }

    ]

  }

]