Skip To Content ArcGIS for Developers Sign In Dashboard

Share a portal item

When one of your users creates a portal item and adds it to a portal, using ArcGIS Online or this ArcGIS Runtime API, the item is private by default. Only the owner of the item (and the organization's administrators) are able to view it. This level of sharing is indicated by the portal item's access property.

self.portalItem.access == AGSPortalAccessPrivate

The access property indicates the item's highest level of sharing. So if the portal item has an access value of:

  • Private—The item is not be shared with anybody. Only the owner and administrator can view the item.
  • Public—The item can be viewed by everybody.
  • Organization—The item can be viewed by every member of the organization that the item is created in.
  • Shared—The item can only be viewed by members of a group that the item is shared with.

You can allow users to change this level of sharing so that the portal item is available to the right users.

Share with everyone or a portal's organization

If you want your portal item to be accessible to everyone, you need to make it public. Any user who has access to the portal website can then find and use the portal item. To make a portal item public, call the sharewithEveryone:org method and pass true .

//Share with everyone   
[self.portalItem shareWithEveryone:TRUE org:FALSE completion:^(NSError * _Nullable error) {
 if (!error) {
  NSLog(@"Shared with Everyone");

To ensure only members of the user's portal have access to an item, you can share it with just the user's portal organization. To do this, pass true for the org parameter of the sharewithEveryone:org method.

//Share with just the user's organization
[self.portalItem shareWithEveryone:FALSE org:TRUE completion:^(NSError * _Nullable error) {
 if (!error) {
  NSLog(@"Shared with the organization");

Share with a portal group

If a user is a member of a group, they can share items that they own with that group. Sharing items with specific groups restricts access to a smaller, more focused set of people. For details on portal groups, see What is a group? The following sections describe how to:

  • Find the groups that the portal item belongs to
  • Find the groups the user is a member of
  • Share a portal item with a group
  • Unshared a portal item from a group

Find a portal item's groups

You can determine which groups a portal item is currently shared with by calling the fetchGroupsWithCompletion method on the portal item. This asynchronous method returns three types of groups. In this example:

  • adminGroups contains the groups which the current user is an administrator of.
  • memberGroups contains the groups in which the user is a member.
  • otherGroups contains the public groups or groups that are shared to the user's organization but that the user is not a member of.

This code displays the title of the groups that the item is shared with.

[self.portalItem fetchGroupsWithCompletion:^(NSArray<AGSPortalGroup *> * _Nullable adminGroups, 
 NSArray<AGSPortalGroup *> * _Nullable memberGroups, 
 NSArray<AGSPortalGroup *> * _Nullable otherGroups, 
 NSError * _Nullable error) {

 if (!error) {
  for (int i=0; i<adminGroups.count; i++){
   AGSPortalGroup *group = adminGroups[i];
   NSLog(@"%@", group.title);
  for (int i=0; i<memberGroups.count; i++){
   AGSPortalGroup *group = memberGroups[i];
   NSLog(@"%@", group.title);
  for (int i=0; i<otherGroups.count; i++){
   AGSPortalGroup *group = otherGroups[i];
   NSLog(@"%@", group.title);


Share a portal item with specific groups

To share a portal item with specific groups, first determine which groups it should be shared with. For example, you can determine which groups the current user is a member of by iterating through the groups returned from the portal user's groups property as follows:

@property (nonatomic, strong) AGSPortalUser *portalUser;
@property (nonatomic, strong) AGSPortalGroup *portalGroup;   
self.portalUser = self.portal.user;
for (int i=0; i<self.portalUser.groups.count; i++){
 AGSPortalGroup *group = self.portalUser.groups[i];
 NSLog(@"%@", group.title);

Note that some groups are view-only; that is, members can view the items already in the group, but cannot share other items with that group. To learn more about users and groups, see List the groups a user belongs to and Portals, users, roles, groups, and sharing.

Then to share the portal item with those groups, pass these groups to the shareWithGroups method as follows:

NSArray *thePortalGroups;
//Add groups to this array as defined above

[self.portalItem shareWithGroups:thePortalGroups completion:^(NSArray<AGSPortalGroup *> * _Nullable excludedGroups, NSError * _Nullable error) {
 if (!error) {
  NSLog(@"Shared with Groups");

If there is a problem sharing the portal item with some groups, the failures will be indicated in the values returned from the shareWithGroups method.

Unshare a portal item from specific groups

To stop sharing a portal item with specific groups pass these groups to the unshareWithGroups method as follows:

//Add groups to this array
NSArray *thePortalGroups;
[self.portalItem unshareWithGroups:thePortalGroups completion:^(NSArray<AGSPortalGroup *> * _Nullable excludedGroups, NSError * _Nullable error) {
 if (!error) {
  NSLog(@"Unshared from the groups");

Stop sharing

To stop sharing the item, call the unshare method. Calling this method:

  • Makes the item private and accessible to only the item owner (and the organization's administrator)
  • Removes all groups from the item's groups list

//Make the portalitem private    
[self.portalItem unshareWithCompletion:^(NSError * _Nullable error) {
 if (!error) {
  NSLog(@"Unshared from Public, Org and Groups");