Ich versuche, einen exklusiven UTI-Typ für meine iOS-App zu erstellen/exportieren (sehr ähnlich wie Instagram ausschließlich die UTI com.instagram.exclusivegram behandelt).Exklusive iOS UTI
Grundsätzlich möchte ich com.photoapp.photo, was eine App verwenden kann, wenn sie in der Lage sein möchten, das Foto in jeder App zu öffnen, die für die Aufnahme von Fotos registriert ist (ähnlich wie bei Instagram com.instagram.photo). Dann möchte ich, dass com.photoapp.exclusive nur in meiner App geöffnet werden kann (ähnlich wie com.instagram.exclusivegram).
Was auf meinem Gerät passiert ist, dass selbst bei Verwendung von com.photoapp.exclusive der UIDocumentController mich dazu auffordert, es entweder in PhotoApp oder DropBox zu öffnen, wo es nur PhotoApp sein sollte.
Ich habe meine App, die die UTI sowie eine Beispielanwendung registriert, die ich verwende, um die Öffnungsfähigkeit zu überprüfen. Der Code, den ich im Beispiel app unter:
if ([[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:@"photoapp://"]]) {
NSData *imageData = UIImageJPEGRepresentation([UIImage imageNamed:@"derp.png"], 1.0);
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *fullPathToFile = [[paths objectAtIndex:0] stringByAppendingPathComponent:@"photoapp.pae"];
[imageData writeToFile:fullPathToFile atomically:NO];
interactionController = [UIDocumentInteractionController interactionControllerWithURL:[NSURL fileURLWithPath:[NSString stringWithFormat:@"file://%@", fullPathToFile]]];
interactionController.UTI = @"com.photoapp.exclusive";
interactionController.delegate = self;
[interactionController presentOpenInMenuFromRect:self.view.frame inView:self.view animated:YES];
}
Und hier ist das, was ich in meiner plist-Datei für meine app:
<key>UTExportedTypeDeclarations</key>
<array>
<dict>
<key>UTTypeDescription</key>
<string>Exclusive PhotoApp Photo</string>
<key>UTTypeConformsTo</key>
<array>
<string>com.photoapp.photo</string>
</array>
<key>UTTypeIdentifier</key>
<string>com.photoapp.exclusive</string>
<key>UTTypeTagSpecification</key>
<dict>
<key>public.filename-extension</key>
<string>pae</string>
</dict>
</dict>
<dict>
<key>UTTypeTagSpecification</key>
<dict>
<key>public.filename-extension</key>
<string>pa</string>
</dict>
<key>UTTypeIdentifier</key>
<string>com.photoapp.photo</string>
<key>UTTypeDescription</key>
<string>PhotoApp Photo</string>
<key>UTTypeConformsTo</key>
<array>
<string>public.png</string>
<string>public.jpeg</string>
</array>
</dict>
</array>
<key>UIFileSharingEnabled</key>
<true/>
<key>CFBundleDocumentTypes</key>
<array>
<dict>
<key>LSItemContentTypes</key>
<array>
<string>com.photoapp.exclusive</string>
<string>com.photoapp.photo</string>
</array>
<key>CFBundleTypeName</key>
<string>Photo</string>
<key>LSHandlerRank</key>
<string>Default</string>
</dict>
</array>
Sobald Sie angeben, dass Ihr Dateiformat mit 'public.png' oder' public.jpeg' oder ähnlichem übereinstimmt, können alle Apps, die angeben, dass sie Dateien dieser UTIs öffnen können, diese öffnen. Wenn Sie Ihr Array "UTTypeConformsTo" entfernen, sollte das Ihr Problem lösen. – Greg
Mit anderen Worten, geben Sie nicht an, dass Ihr 'com.photoapp.exclusive' mit' com.photoapp.photo' übereinstimmt. Belassen Sie 'com.photoapp.photo' wie es ist, und geben Sie keine Übereinstimmung für' com.photoapp.exclusive' an. – Greg
Danke! Möchtest du einen Kommentar abgeben, damit ich deine Antwort annehmen kann? – joshholat