I'd like to receive files in my app, but only certain UIScenes can receive a file. How do I tell the system which of the UIScenes in my app can receive that file? How does the system pick a scene?
I've tried using UISceneActivationConditions(). Here is what I put in the scenes that can receive files:
var preferredActivatePredicates = [NSPredicate]()
var canActivatePredicates = [NSPredicate]()
// Any scene *can* be activated at any time
canActivatePredicates.append(NSPredicate(value: true))
if hasWriteAccess {
// We are also the preferrred scene for receiving files
for fileExtension in ["png", "jpeg", "jpg", "pdf"] {
preferredActivatePredicates.append(NSPredicate(format: "SELF ENDSWITH[c] '.%@'", fileExtension))
}
}
let conditions = UISceneActivationConditions()
conditions.canActivateForTargetContentIdentifierPredicate = NSCompoundPredicate(orPredicateWithSubpredicates: canActivatePredicates)
conditions.prefersToActivateForTargetContentIdentifierPredicate = NSCompoundPredicate(orPredicateWithSubpredicates: preferredActivatePredicates)
scene.activationConditions = conditions
Unfortunately, this does not seem to have an effect. It does not activate the hasWriteAccess scenes for func scene(_ scene: UIScene, openURLContexts URLContexts: Set<UIOpenURLContext>)
Is there any way to tell what content identifier the system is using when a file share activates an app?
Thank you for your help!
Topic:
UI Frameworks
SubTopic:
UIKit