Shows a list of users in a portal group.
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
- Initialize an
AGSPortal
object. - Retrieve a group from this portal using
findGroups(with:completion:)
, which returns an array of user names. - Obtain all the users in this group by using
fetchUsers(completion:)
. - Create an
AGSPortalUser
object for each user name usinginit(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
// 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
}
}
}
}
}
}
}