Silent Mode Guide
The StreamLayer SDK now supports a more flexible configuration for notifications called Silent Mode. This new parameter is found in StreamLayer.config() as shown below:
SLRNotificationsMode it’s an OptionSet, so you can combine different types of notifications that you need for your application. This allows a degree of customization and freedom to implement a custom notification system for your users.
/// StreamLayer SDK support different notification modes for different modules.
/// You can combine/disable/enable notifications as you want.
public struct SLRNotificationsMode: OptionSet {
public let rawValue: Int
public init(rawValue: Int) {
self.rawValue = rawValue
}
/// Chat notifications
static let messaging = SLRNotificationsMode(rawValue: 1)
/// Notifications from live Watch Parties
static let watchParty = SLRNotificationsMode(rawValue: 1 << 1)
/// Notifications with Watch Party promotions
static let promotion = SLRNotificationsMode(rawValue: 1 << 1)
/// Notifications about friends online
static let arrival = SLRNotificationsMode(rawValue: 1 << 2)
/// Twitter module notifications
static let twitter = SLRNotificationsMode(rawValue: 1 << 3)
/// Notifications from voting/trivias modules
static let vote = SLRNotificationsMode(rawValue: 1 << 4)
/// Enabling all notifications. It's a default mode
static let all: SLRNotificationsMode = [.messaging,
.watchParty,
.promotion,
.arrival,
.twitter,
.vote
]
/// All notifications are disabled
static let silent: SLRNotificationsMode = []
}We have already configured one set of options with SLRNotificationsMode.silent. This can be set in two different ways:
Option 1
StreamLayer.config.noticationMode = SLRNotificationsMode.silentOption 2
We have created a separate Configuration for completely silent behavior of StreamLayer SDK:
StreamLayer.config = StreamLayerSilentModeConfig() which represents following:
public struct StreamLayerSilentModeConfig: StreamLayerConfig {
public init() {}
public var isAlwaysOpened: Bool = false
public var phoneContactsSyncEnabled: Bool = true
public var whoIsWatchingEnabled: Bool = false
public var isUserProfileOverlayHidden: Bool = true
public var notificationsMode: SLRNotificationsMode = .silent
public var appStyle: SLRStyle = .blue {
didSet {
applyStyle()
}
}
}Updated 4 months ago
