BadgeManager
@objc
public class BadgeManager : NSObject
BadgeManager provides easy to use APIs to interact with user’s badges.
-
Collection of user’s badges. If auto update behavior is enabled then this collection will be updated with latest badge data.
Declaration
Swift
public private(set) var badges: [Badge]
-
Map of badge ID to the badge.
Declaration
Swift
public private(set) var badgesByBadgeId: [String : Badge]
-
Map of organization ID to badge.
Declaration
Swift
public private(set) var badgesByOrgId: [String : Badge]
-
Initialize a non-auto-updating instance of BadgeManager. Designed for the use cases where you only need the current state of the badge data and the badge manager instance will be discarded immediately after use.
Declaration
Swift
override public init()
-
Convenience initializer that configures the instance to auto update its badge containers every time the underlying badge collection changes. Auto-updating guarantees that the values for
badges
,badgesByBadgeId
,badgesByOrgId
will always reflect latest data.Declaration
Swift
public convenience init(autoUpdating: Bool)
-
This API lets the caller subscribe to the changes of user’s badges. The closure will be called every time there is a change in the badge collection. Subscribing for changes also makes instances of this class auto-updating.
Declaration
Swift
public func subscribeForChanges(_ closure: @escaping (CollectionChange<[Badge]>) -> Void)
-
Returns a badge for a specified badge ID if it exists; nil otherwise
Declaration
Swift
@objc public func badge(withBadgeId badgeId: String) -> Badge?
-
Returns a badge for a specified organization id if it exists; nil otherwise. If more than one badge exists only the first it returned.
Declaration
Swift
@objc public func badge(withOrgId orgId: String) -> Badge?
-
Delete badges from this device. The badge is deleted from the device only. User’s membership to the organization is not affected. The user will still be able to reqacuire all his badges.
Declaration
Swift
public func delete(badges: [Badge])
-
This API lets you reorder the user’s collection of badges. The default order for badges is as they were received from the server. The reordering can be done by the application by implementing its own UI.
Declaration
Swift
public func moveBadge(_ badge: Badge, at sourceIndex: Int, to destinationIndex: Int)
-
Fetch latest data from the server for all badges.
Declaration
Swift
@objc public func reload()
-
Fetch latest data from the server for the badge.
Declaration
Swift
@objc public func reload(badge: Badge, completion: (() -> Void)? = nil)