iOS UIActivity Sharing
iOS UIActivity Sharing
UIActivity Sharing Simplified
Από το iOS 6 και μετά, οι εφαρμογές τρίτων έχουν ενεργοποιηθεί να μοιράζονται δεδομένα όπως κείμενα, URLs ή εικόνες χρησιμοποιώντας μηχανισμούς όπως το AirDrop, όπως περιγράφεται στον οδηγό Επικοινωνίας Μεταξύ Εφαρμογών της Apple. Αυτή η δυνατότητα εκδηλώνεται μέσω ενός συστήματος sheet δραστηριότητας κοινής χρήσης που εμφανίζεται κατά την αλληλεπίδραση με το κουμπί "Κοινή Χρήση".
Μια ολοκληρωμένη απαρίθμηση όλων των ενσωματωμένων επιλογών κοινής χρήσης είναι διαθέσιμη στο UIActivity.ActivityType. Οι προγραμματιστές μπορούν να επιλέξουν να αποκλείσουν συγκεκριμένες επιλογές κοινής χρήσης εάν τις θεωρούν ακατάλληλες για την εφαρμογή τους.
How to Share Data
Πρέπει να δοθεί προσοχή σε:
Τη φύση των δεδομένων που μοιράζονται.
Την ένταξη προσαρμοσμένων δραστηριοτήτων.
Τον αποκλεισμό ορισμένων τύπων δραστηριοτήτων.
Η κοινή χρήση διευκολύνεται μέσω της δημιουργίας ενός UIActivityViewController
, στον οποίο περνιούνται τα αντικείμενα που προορίζονται για κοινή χρήση. Αυτό επιτυγχάνεται καλώντας:
Developers should scrutinize the UIActivityViewController
for the activities and custom activities it's initialized with, as well as any specified excludedActivityTypes
.
Πώς να Λάβετε Δεδομένα
The following aspects are crucial when receiving data:
The declaration of custom document types.
The specification of document types the app can open.
The verification of the integrity of the received data.
Without access to the source code, one can still inspect the Info.plist
for keys like UTExportedTypeDeclarations
, UTImportedTypeDeclarations
, and CFBundleDocumentTypes
to understand the types of documents an app can handle and declare.
A succinct guide on these keys is available on Stackoverflow, highlighting the importance of defining and importing UTIs for system-wide recognition and associating document types with your app for integration in the "Open With" dialogue.
Dynamic Testing Approach
To test sending activities, one could:
Hook into the
init(activityItems:applicationActivities:)
method to capture the items and activities being shared.Identify excluded activities by intercepting the
excludedActivityTypes
property.
For receiving items, it involves:
Sharing a file with the app from another source (e.g., AirDrop, email) that prompts the "Open with..." dialogue.
Hooking
application:openURL:options:
among other methods identified during static analysis to observe the app's response.Employing malformed files or fuzzing techniques to evaluate the app's robustness.
References
Last updated