# Deeplinks for Stories

This guide shows you how to handle deep links in your application and show a story.

The Storyly Dashboard generates a deep link with the application's predefined custom scheme. The application needs to handle the setup of intent handling and route the related URI to Storyly SDK to open the related story.

# Open Story

The first way to open the related story is to use the URI which is received from the dashboard:

self.storylyView.openStory(payload:URL)
[self.storylyView openStoryWithPayload:NSURL];

The second way to open a story is to use story group id, story id and play mode as in the function signature:

self.storylyView.openStory(storyGroupId:Int, 
                           storyId:Int?, 
                           play:PlayMode)
[self.storylyView openStoryWithId:NSNumber
                          storyId:NSNumber
                          play:PlayMode];

# Play Modes

# Playing to the End

If the PlayMode parameter is not defined or passed as Default , Storyly opens the Story Group and a specific Story (if storyId is provided) and all active Story Groups will be shown to the user. This is the default behaviour.

# Playing a Single Story Group

This mode plays only the specific Story Group. If the PlayMode parameter is defined as sg/StoryGroup, Storyly opens the Story Group and a specific Story (if storyId is provided) and shows only that Story Group whose storyGroupId is sent to the Storyly SDK.

# Playing a Single Story

This mode plays only the specific Story. If the PlayMode parameter is defined as s/Story, Storyly opens the Story Group and the specific Story (storyId is required) and shows only that Story whose storyId is sent to the Storyly SDK.

# StorylyStoryPresentFailed Event

This event will let you know that Storyly could not open Story programmatically and had a problem about parameters (Story Groupd ID, Story ID or Play Mode). In this case, users will still able to see story group icons with data. In order to get notification about this event, you should override the following function in StorylyDelegate, which you have registered in Initial SDK Setup.

In order to notified about this event, use the following example:

func storylyStoryPresentFailed?(_ storylyView: Storyly.StorylyView,
                                errorMessage: String) {}
- (void)storylyStoryPresentFailed?:(StorylyView *)storylyView
                      errorMessage:(NSString *)errorMessage {}

WARNING

Application can determine from URL's host if it's related with Storyly, host will be storyly for Storyly Dashboard generated deep link URLs.

WARNING

You need to set the URL Scheme for Deep Links field in the Storyly Dashboard -> Settings -> App Settings (opens new window) in order to get the deep links properly from the dashboard.

WARNING

Make sure that the application schema is defined in your application's Info.plist file.