M
M
MyMeta2019-02-08 12:27:35
Swift
MyMeta, 2019-02-08 12:27:35

How to use mechanism to receive data from "share" menu on iOS swift?

good afternoon
How to implement the function of receiving data (photos, files) through the "Actions - Share" menu from another application?
The bottom line is that another program (for example, a photo) can transfer data (photo - a pack) to my program for further processing.
I don't even know where to start looking.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
N
NSA-bot, 2019-02-08
@NSA-bot

Maybe this will help you.
I passed the contents of an email from native mail to one of my applications by writing the following method in the AppDelegate:

// Принимает файл из внешней программы mail или другой.
  func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool {
    // url содержит URL к файлу, который нужно открыть в приложении

    // Если переданные снаружи данные нормально извлеклись
    if let data = NSData(contentsOf: url) {
      // Тут я сохранял их в файл
      ..
      // Сохраняем данные в файл
      return true
    } else {
      return false
    }
  }

True, in the Plist of the application, you need to prescribe something

B
briahas, 2019-02-15
@briahas

There are several options: (transfer from another site)
1) To receive files sent to your application using AirDrop, do the following:
- In Xcode, declare support for the types of documents that your application is able to open.
- In your application delegate, implement the application:openURL:sourceApplication:annotation: method.
Use this method to receive data that was sent by another application. The "Info" tab of your Xcode project contains a "Document Types" section for specifying the document types supported by your application. At a minimum, you must provide a name for your document type and one or more UTIs that represent the data type. For example, to declare support for PNG files, you must include public.png as a UTI string. iOS uses the specified UTIs to determine if your app is authorized to open a given document.
2) Via Custom URL Schemes

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question