1

I am going through : Apple : DocInteration code and they have given a DirectoryWatcher.m which watches for directory changes in your app's Document Directory.

Whenever a user shares a file with Microsoft Outlook App the app will directly attach the file to a mail. Basically it is triggering an event when a file is getting copied to its Document Directory. I also want to trigger an event ( Not preview the document ) How do I do that ? He PDF Viewer Source Code has also done that and is triggering the app to open the PDF file copied in his custom viewer. But it only does when the app is in background and then it becomes active. I want to have the app ( even if terminated state ) to trigger an event when a file is shared with that app.

Omkar Jadhav
  • 1,046
  • 3
  • 16
  • 41

1 Answers1

0

To receive file from an other app:

Basically, you have to enable that functionality in your app.

From Apple doc:

Opening Files From Other Apps

The system may ask your app to open a specific file and present it to the user. This typically occurs because another app encountered a file of a type that you have registered to support. In this scenario, the system provides your app with a URL to the file and brings your app to the foreground.

You can wakeup an app from an other app if it's registered by the system.

Apple Doc: Registering the File Types Your App Supports

https://stackoverflow.com/a/26351211/2707614

It also have the delegate called when some data is send to your app:

func application(application: UIApplication, openURL url: NSURL [...]

To send file to an other app:

You can use the "Open In" functionality which is provided by the system.

Apple Doc: Open In class

A github example for UIDocumentInteractionController usage.

Community
  • 1
  • 1
Alban
  • 1,624
  • 11
  • 21
  • I know till the part of adding every type of data. But I don't know how to trigger an event when a new file is copied to the app. – Omkar Jadhav Jan 14 '16 at 09:42