---
title: "add(_:completionHandler:)"
framework: ShazamKit
role: symbol
role_heading: Instance Method
platforms: [iOS 15.0+, iPadOS 15.0+, Mac Catalyst 15.0+, macOS 12.0+, tvOS 15.0+, visionOS 1.0+, watchOS 8.0+]
path: "shazamkit/shmedialibrary/add(_:completionhandler:)"
---

# add(_:completionHandler:)

Adds an array of songs to the user’s Shazam library.

## Declaration

```swift
func add(_ mediaItems: [SHMediaItem], completionHandler: @escaping @Sendable ((any Error)?) -> Void)
```

```swift
func add(_ mediaItems: [SHMediaItem]) async throws
```

## Parameters

- `mediaItems`: An array of media items that represents the songs to add to the library.
- `completionHandler`: The system calls this completion block after adding the media items to the library. This block takes the following parameters:

## Discussion

Discussion important: You can call this method from synchronous code using a completion handler, as shown on this page, or you can call it as an asynchronous method that has the following declaration: func add(_ mediaItems: [SHMediaItem]) async throws For information about concurrency and asynchronous code in Swift, see Calling Objective-C APIs Asynchronously. Saving a song to the user’s Shazam library also saves the following media item properties and their associated values: shazamID title subtitle, or artist if the subtitle is unavailable note: Saving to the user’s Shazam library works only for songs with a valid shazamID.

## See Also

### Adding a matched song to the library

- [default](shazamkit/shmedialibrary/default.md)
