Select to view content in your preferred language

Introduction to Inter-app Communication - Share Sheet

2285
1
01-09-2018 09:07 AM
by Anonymous User
Not applicable
1 1 2,285
This functionality is currently in beta, meaning functionality isn’t yet finalized, and we’re looking forward to your feedback.

Applications can communicate with each other through a variety of ways. For example, you can use a custom URL scheme to launch one app from another one and invoke actions specified in the link, check out this blog post for understandingSurvey123's custom URL scheme. You can also use the newly added inter-app communication functionality to pass text or a URL to another app. Inter-app communication functionality brings up the standard iOS, macOS or Android share sheet that allows you to share text or URL to other applications. For instance, instead of copying a URL, navigating and pasting URL into another app, you can easily share a URL in the source app by triggering share sheet using inter-app communication functionality. This blog post explains how to achieve this. 

First of all, you need to enter data or copy data to the clipboard.

    property url urlInfo: "https://appstudio.arcgis.com/"

    Column {
        spacing: 10

        TextField {
            id: inputText
            placeholderText: "Enter some text"
        }

        Text {
            id: sampleURL
            text: urlInfo
        }

        Button {
            id: copyURL
            text: "Copy as URL"

            onClicked: {
                AppFramework.clipboard.copy(sampleURL.text)
            }
        }
    }‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

Once data is entered or copied to the clipboard, you can use the AppFramework.clipboard.share(QJSValue) method to share text or a URL to other apps. The following code snippet shows how to share input text across apps.

        //Share input text
        TextField {
            id: inputText
            placeholderText: "Enter some text"
        }

        Button {
            id: shareURLButton
            text: "Share as Text"

            onClicked: {
                AppFramework.clipboard.share(inputText.text)
            }
        }‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

The following code demonstrates how to share a URL from clipboard. 

 

        // Share URL from clipboard
        Text {
            id: sampleURL
            text: urlInfo
        }

        Button {
            id: copyURL
            text: "Copy as URL"

            onClicked: {
                AppFramework.clipboard.copy(sampleURL.text)
            }
        }


        Button {
            id: shareURL
            text: "Share as URL"

            onClicked: {
                AppFramework.clipboard.share()
            }
        }‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

Inter-app Communication Sample App

The Inter-app Communication sample app is available on AppStudio Desktop.  To create an app based on this sample, follow these steps:

  • Open AppStudio Desktop
  • Click on the New App button 
  • Search and select Inter-App Communication sample 
  • Click on the Create Button

   

 This sample is also available in the appstudio-samples GitHub repo.                   

Hopefully, this blog post gives you some idea of what this functionality is currently capable of.
Feedback and suggestions are welcomed in the comment section below, and I would also like to hear
how you plan to use this feature in your own AppStudio apps.

To learn more about Inter-app communication, check out the API Guide.  

1 Comment