Skip To Content ArcGIS for Developers Sign In Dashboard

Accessing content

After you successfully connect to a portal or a subscription within a portal using valid credentials, the user property on AGSPortal contains a valid AGSPortalUser object representing a registered user.


An item is a unit of content in the portal. It's represented by an object of type AGSPortalItem. An item contains binary or textual data and some metadata describing itself. Items can be of various types such as web maps, tile packages, feature collections, and so on. Some types, such as globe documents and map templates, may only be relevant to desktop systems. Although you can access such items using the API, you may not be able to use them on a mobile device.

Item ID

Each item has a unique identifier. If you know this identifier, you can instantiate an AGSPortalItem object using it as follows:

let portal:AGSPortal = ... //The portal where the item resides
let portalItem = AGSPortalItem(portal: portal, itemId: "<item_id>")
When you instantiate the AGSPortalItem object, the item's metadata is fetched from the portal in the background. To verify the metadata was fetched properly, you must set one of your classes as the item's delegate.
portalItem.delegate = self

Your class must also adopt the <AGSPortalItemDelegate> protocol in the swift file and implement the relevant methods.

class MyViewController: UIViewController, AGSPortalItemDelegate {

 func portalItemDidLoad(portalItem: AGSPortalItem!) {
  //now it is safe to access the item's properties
 func portalItem(portalItem: AGSPortalItem!, didFailToLoadWithError error: NSError!) {
  //handle or report the error


Even when the item's metadata is loaded, the item's actual data is not retrieved. The actual binary or textual data needs to be explicitly fetched using fetchData. This allows you to work with an item using a minimum amount of memory and delay fetching the actual data until it's really needed.


If you don't know the item's unique identifier, or if you want to access all items that belong to you, you can use the fetchContent method on AGSPortalUser. This returns a list of your folders as well as items you own that reside outside these folders. You can then usefetchContentInFolder: to retrieve items within a specific folder.

let portalUser:AGSPortalUser = ...  //The user who own the items


Portals do not currently allow subfolders within a folder.

The results of fetchContent and fetchContentInFolder: are provided to the delegate of AGSPortalUser. You must set one of your classes as the delegate to get these results or be informed of any errors that were encountered.

portalUser.delegate = self

Your class must also adopt the <AGSPortalUserDelegate> protocol in the swift file and implement the relevant methods.

class MyViewController: UIViewController, AGSPortalUserDelegate {

	func portalUser(portalUser: AGSPortalUser!, operation: NSOperation!, didFetchContent items: [AnyObject]!, folders: [AnyObject]!, inFolder folderId: String!) {
  //process the items
  for item in items as [AGSPortalItem] {
  //also iterate through the folders and fetch items within them
  for folder in folders as [String] {
 func portalUser(portalUser: AGSPortalUser!, operation op: NSOperation!, didFailToFetchContentInFolder folderId: String!, withError error: NSError!) {
  //handle or report the error


You can get information about the groups you belong to from the groups property on AGSPortalUser. This property contains an array of AGSPortalGroup objects, which contain information about each group. Each group has a unique group identifier. You can use this identifier to Searching the portal for items belonging to that group.

let groups = portalUser.groups
for group in groups as [AGSPortalGroup] {
 //display group to the user
 //or fetch items within each group

See also

In this topic
  1. Items
  2. Groups
  3. See also