in apps/chat-ios/AmazonChimeSDKMessagingDemo/models/NotificationSettingsModel.swift [63:90]
func setChannelPreferences() {
guard let currentUser = currentUser else {
print("\(self.TAG) currentUser is nil")
return
}
let pushNotificationsPreferences: AWSChimeSDKMessagingPushNotificationPreferences = AWSChimeSDKMessagingPushNotificationPreferences()
if selectedLevelTitle == K.notificationLevelFull {
pushNotificationsPreferences.allowNotifications = .all
} else if selectedLevelTitle == K.notificationLevelNormal {
pushNotificationsPreferences.allowNotifications = .filtered
pushNotificationsPreferences.filterRule = "{\"mention\":[\"@\(currentUser.chimeDisplayName)\"]}"
} else if selectedLevelTitle == K.notificationLevelMute {
pushNotificationsPreferences.allowNotifications = .none
}
let channelPreferences: AWSChimeSDKMessagingChannelMembershipPreferences = AWSChimeSDKMessagingChannelMembershipPreferences()
channelPreferences.pushNotifications = pushNotificationsPreferences
chimeMessagingService.putChannelMembershipPreferences(channelArn: channelArn, chimeBearer: currentUser.chimeAppInstanceUserArn, preferences: channelPreferences) { response, error in
if let error = error {
print("\(self.TAG) setChannelPreferences() chimeMessagingService.putChannelMembershipPreferences() error \(error)")
return
}
if response == nil {
print("\(self.TAG) setChannelPreferences() chimeMessagingService.putChannelMembershipPreferences() response is nil")
}
}
}