List portal group users

View on GitHubSample viewer app

Shows a list of users in a portal group.

List Portal Group Users

Use case

This portal information can be used to provide a customized UI experience for the user. For example, you can show a thumbnail next to their username in the header of an application to indicate that they are currently logged in. Additionally, apps such as Collector and Explorer use this functionality to integrate with Portal.

How to use the sample

When launched, this sample displays a list of users in the Runtime Group portal. Notice that along with displaying each user's name and picture, their description is displayed as well.

How it works

  1. Initialize an AGSPortal object.
  2. Retrieve a group from this portal using findGroups(with:completion:), which returns an array of user names.
  3. Obtain all the users in this group by using fetchUsers(completion:).
  4. Create an AGSPortalUser object for each user name using init(portal:username:).

Relevant API

  • AGSPortal
  • AGSPortalGroup
  • AGSPortalUser

About the data

This sample displays users who are a part of the Runtime Group portal.

Tags

account, cloud and portal, description, profile, user, username

Sample Code

GroupUserCell.swiftGroupUserCell.swiftGroupUsersViewController.swift
Use dark colors for code blocksCopy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
// Copyright 2016 Esri.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//   http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

import UIKit
import ArcGIS

class GroupUserCell: UITableViewCell {
    @IBOutlet private var thumbnailImageView: UIImageView!
    @IBOutlet private var titleLabel: UILabel!
    @IBOutlet private var descriptionLabel: UILabel!

    var portalUser: AGSPortalUser! {
        didSet {
            self.titleLabel.text = portalUser.fullName
            self.descriptionLabel.text = portalUser.userDescription
            self.thumbnailImageView.layer.cornerRadius = 40
            self.thumbnailImageView.layer.masksToBounds = true

            self.thumbnailImageView.image = UIImage(named: "Placeholder")

            if let thumbnail = portalUser.thumbnail {
                if thumbnail.image != nil {
                    self.thumbnailImageView.image = thumbnail.image
                } else {
                    thumbnail.load { [weak self] (error: Error?) in
                        if error == nil {
                            self?.thumbnailImageView.image = thumbnail.image
                        }
                    }
                }
            }
        }
    }
}

Your browser is no longer supported. Please upgrade your browser for the best experience. See our browser deprecation post for more details.