Manage user-level push notification preferences that apply across all devices logged in with the same user account. Users can control notifications for different feature modules like chat, social features, and live streams.
Global Settings: User notification settings are synchronized across all devices where the user is logged in, ensuring consistent notification preferences.

Overview

User notification settings provide granular control over which types of notifications users receive. Settings are organized by feature modules and persist across user sessions and devices.

Supported Modules

  • CHAT - Direct messages, channel messages, and mentions
  • SOCIAL - Posts, comments, reactions, and community activities
  • LIVE_STREAM - Stream notifications, chat messages, and live events

Get Current Settings

Retrieve the user’s current notification preferences:
let userNotificationManager = client.notificationManager

// Get user notification settings
do {
    let notification = try await userNotificationManager.getSettings()
    
    // Notification top-level setting
    print("user notification enabled: \(notification.isEnabled)")
    
    // Each module setting
    for module in notification.modules {
        switch module.moduleType {
        case .chat:
            print("- module chat enabled: \(module.isEnabled)")
        case .social:
            print("- module social enabled: \(module.isEnabled)")
        case .videoStreaming:
            print("- module videoStreaming enabled: \(module.isEnabled)")
        @unknown default:
            print("- module unknown enabled: \(module.isEnabled)")
        }
    }
} catch {
    // Handle error here
    print("Failed to get notification settings: \(error)")
}

Update Settings

Modify notification preferences for specific modules:
let userNotificationManager = client.notificationManager

// Update settings for a particular module
// In case you would like to disable/enable notification for particular modules,
// Passing `AmityUserNotificationModule` instance that responsible for module settings.
//
// For example, to mute social notification.
do {
    let result = try await userNotificationManager.enable(for: [
        AmityUserNotificationModule(moduleType: .social, isEnabled: false, roleFilter: nil)
    ])
} catch {
    // Handle error here
    print("Failed to update notification settings: \(error)")
}

// Update notification top-level setting, to disable all notifications.
do {
    let result = try await userNotificationManager.disableAllNotifications()
} catch {
    // Handle error here
    print("Failed to disable all notifications: \(error)")
}

Next Steps