0

Trying to upload a file through my app but it says that I don't have access to the file:

In my plist:

<key>CFBundleDocumentTypes</key>
<array>
    <dict>
        <key>CFBundleTypeIconFiles</key>
        <array/>
        <key>CFBundleTypeName</key>
        <string>pdf file</string>
        <key>CFBundleTypeRole</key>
        <string>Editor</string>
        <key>LSHandlerRank</key>
        <string>Owner</string>
        <key>LSItemContentTypes</key>
        <array>
            <string>com.adobe.pdf</string>
        </array>
    </dict>
 </array>

In AppDelegate:

- (BOOL)application:(UIApplication *)app openURL:(NSURL *)url options:(NSDictionary<UIApplicationOpenURLOptionsKey, id> *)options{
     /*When I try to upload here it returns an error saying that the 
      url is pointing to a private file*/
} 

I believe if I registered the app to be shown as copy to' like email clients, and slack for example the problem would be solved. But I'm failing to find the right way to do it.

By changing the LSHandlerRank from owner to alternate did the trick of copy to but still gave me the privacy error:

Error Domain=NSCocoaErrorDomain Code=257 "The file “xyzd.pdf” couldn’t be opened because you don’t have permission to view it." UserInfo={NSFilePath=/private/var/mobile/Containers/Data/Application/42A9C8AD-4AE2-4F2E-91F0-C399719F19D4/Documents/xyz.pdf, NSUnderlyingError=0x282ec6460 {Error Domain=NSPOSIXErrorDomain Code=1 "Operation not permitted"}}

rmaddy
  • 314,917
  • 42
  • 532
  • 579
keriackus
  • 83
  • 8
  • This one did the trick for me: https://stackoverflow.com/questions/27650658/the-file-appname-app-couldn-t-be-opened-because-you-don-t-have-permission-to – Mirzohid Akbarov Aug 05 '19 at 03:40
  • @MirzohidAkbarov The question in your link is irrelevant. – keriackus Aug 05 '19 at 07:31
  • For me this provided a solution: https://stackoverflow.com/questions/58223929/how-do-i-get-around-nscocoaerrordomain257-when-pulling-a-file-from-the-files-ap – Philip De Vries Nov 05 '19 at 02:43

0 Answers0