
#SWIFT SHARE EXTENSION URL CODE#
For retrieving that data, run the code block in ShareViewController.swift. The above JavaScript file will be now scraping the data from it. For more in-depth details, you can refer to the Apple documentation guide. Now, the OS will be looking for an object with the name ExtensionProcessingJS that will be performing at the runtime. Next, make an addition of another row from dictionary NSExtensionActivationRule containing the key NSExtensionActivationSupportsWebURLWithMaxCount.Ĭopy and paste the image you have selected to share into GetURL.js. Select the key named NSExtensionJavascriptProcessingFile with the created value “GetURL” (without the extension. The extension file ist needs editing with a key from the dictionary named NSExtensionAttributes available in NSExtension. Under it, on the Other tab, you will find Empty and then tap Next to rename the file “GetURL.js” So, go to your extensions folder in Xcode and select a New File. Hence, here you might want to run a JavaScript file for parsing the document and attain some more information. However, you would need more information than what is provided in the sheet. It receives the page title and then sets that information as the body text.

Once the extension is enabled, the share sheet is able to retrieve all the information automatically for streamlining the sharing process in mobile app development. As you click on the icon, you will be presented with the default implementation associated with SLComposeServiceViewController. If its not there, click on the More button to enable it. The extension name you have created earlier should appear on the list. You can then test whatever you have done till now by running the project on Safari or any other option you have selected.Īs you open Safari, click on the icon displaying “Share”. This will allow you to test your extension. Now, activate the option of running the app on a browser like Safari or any other you have selected, to enable a smoother and responsive app design. Select the iOS tab, click on Share Extension and then Next. You can either choose to open a new project to start adding share extension from scratch or open an existing one you want to add the extension. This helps a user in switching easily from one app to another. It enables displaying an icon on the common share sheet associated with the main mobile app while handling the content sharing as requested by a user. Building a share extension in iOS with Swift programming language is pretty easy and simplifies some essential tasks. The main aim behind building a share extension is enabling an app to save a URL as rich content and to configure some options. In this post, we will be describing the process by using Swift 4.0.
#SWIFT SHARE EXTENSION URL HOW TO#
In our earlier post, we explained how to build a Share Extension using Swift 3.0.
