---
title: "initWithURL:mode:"
framework: avsystemrouting
role: symbol
role_heading: Instance Method
path: "avsystemrouting/avsystemroutesession-5i6j6/initwithurl:mode:"
---

# initWithURL:mode:

Creates a session for initiating playback on a remote device.

## Declaration

```occ
- (instancetype) initWithURL:(NSURL *) url mode:(AVSystemRouteLaunchMode) mode;
```

## Parameters

- `url`: The URL identifying the media content to play. This URL is passed to the remote application or player. For application mode, your remote application receives this URL to handle appropriately (for example, to navigate to specific content). For player mode, the system uses this URL to load media directly.
- `mode`: The launch mode determining whether to start your app’s counterpart (doc://com.apple.avsystemrouting/documentation/AVSystemRouting/AVSystemRouteLaunchMode/application) or the system media player (doc://com.apple.avsystemrouting/documentation/AVSystemRouting/AVSystemRouteLaunchMode/player) on the remote device.

## Discussion

Discussion Initialize a session with the media URL and launch mode before adding it to an AVSystemRoute. The URL and mode determine how the remote device handles playback — either by launching your app’s counterpart or using the system’s built-in media player. note: After creating a session, you must add it to an AVSystemRoute using addSession: before calling startWithCompletionHandler:.
