2

EDIT: As requested added info.pslist and code.

I have a custom Document Type and I have registered the UTIs and a new MIME type. I basically followed the steps by this tutorial. I am using a Codable object that it is no more than a JSON file with a custom extension and a custom icon. Honestly it looks pretty cool to me. The app I am doing is is a Grocery list app that makes a lot of sense being able to share it by a note or iMessage.

Like the finalised app in the tutorial I followed it opens in mail and even in notes!!! but iMessage does not recognise the extension and shows a folder icon and does not open it.

My question is how can I tell iMessage that this file is meant to be opened by my App. Do I need an iMessage extension? I am pretty new to iOS. info.pslist:

enter image description here

And now code:

func exportToUrl() -> URL? {
    let contents = try? JSONEncoder().encode(shoppingList)

    guard let path = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask).first else {
        return nil
    }

    let saveUrl = path.appendingPathComponent("/list.grabgrocerieslist")
    try? contents?.write(to: saveUrl, options: .atomic)
    return saveUrl
}

@IBAction func sharedTapped(_ sender: UIBarButtonItem) {

    guard let url = exportToUrl() else {
        return
    }


    let activityController = UIActivityViewController(activityItems: ["Shopping List", url], applicationActivities: nil)
    activityController.excludedActivityTypes = [.assignToContact, .saveToCameraRoll, .postToFacebook ]
    activityController.popoverPresentationController?.barButtonItem = sender
    self.present(activityController, animated: true, completion: nil)
}

Many Thanks,

Juanjo
  • 670
  • 7
  • 17

1 Answers1

1

I ran into the same issue and finally managed to solve it using this answer:

Custom extension file not opening in iMessage

So in short, you need to create a Quick Look Preview extension that defines how your shared file will be presented when tapped in the iMessage conversation. From that screen, the user can then tap the Share icon and select your app to open the file. (If this is hard to find for your users, you can display some instructions as part of your Quick Look preview.)

Martin
  • 145
  • 7