Standalone Player
This option allows you to trigger at will our stories player, from a button click for example.
Layout
- Create you own
ViewController
and import JoinStories library
import JoinStoriesSDK
For easy readable layout and constraints, you can use SnapKit
.
If you want to style the layout the same way, just import SnapKit library
import SnapKit
or set your constraints programmatically with anchors.
- Create any
UIControl
(for example aUIButton
) with its target action
button.addTarget(self, action: #selector(_your_method_name_), for: .touchUpInside)
Trigger
To start the player, you need to call the startPlayer method:
JoinStories.startPlayer(config: "your_standalone_config", completion: {
// your_completion_block_for_stories_fetch
...
})
Parameter | Type | Required | Description |
---|---|---|---|
config | JoinStoriesStandaloneConfig | YES | The configuration object, that requires at least the JOIN Stories alias you were given |
completion | StoriesCompletionHandler | YES | Completion block called to handle stories API fetch. Can result in success or error . |
onDismiss | ((StoryPlayer.DismissPlayer) -> Void)? | NO | Completion block called when the StoryPlayer view is dismissed. Default value is nil |
StoryPlayer.DismissPlayer
has two possible states:
- manual : triggered when the cross is clicked or swiped down. Default value
- auto : triggered when the story is finished or when you go back to the first story
Configuration
You can fine tune SDK behavior and UI, by specifying optional values on JoinStoriesStandaloneConfig.
Available configuration parameters:
Name | Type | Default Value | Description |
---|---|---|---|
alias | String | YES | The Join Stories alias you were given to configure your integration |
requestTimeoutInterval | TimeInterval | 60 | Timeout used for the stories fetching network requests (call and read) |
playerBackgroundColor | UIColor | UIColor.black | Color of the player's background, if the player height is smaller than screen dimensions |
playerStandaloneAnimationOrigin | PlayerStandaloneAnimationOrigin | .bottom | Direction from where the custom transition comes from in standonlone mode for StoryPlayer. Enum cases are: default , top , topLeft , topRight , bottom , bottomLeft , bottomRight |
playerVerticalAnchor | PlayerVerticalAnchor | .bottom | If the player's height is smaller than screen height, anchor it to the top or bottom of the screen |
playerShowShareButton | Boolean | true | Change the visibility of the share button displayed on the Player view |
playerClosingButton | Boolean | true | Change the visibility of the close button displayed on the Player view |
playerHorizontalMargins | Int | 0 | Apply the margin to the left and right of the player view. To maintain ratio, it also changes the height of the player view. |
playerCornerRadius | Int | 0 | Apply radius to the 4 corners of the player view |
playerProgressBarDefaultColor | String? | nil | Change the background color of the progress bar in the player view. If no value or nil is filled, the default color will be used. Format is ##RRGGBB or #RRGGBBAA |
playerProgressBarFillColor | String? | nil | Change the fill color of the progress bar in the player view. If no value or nil is filled, the default color will be used. Format is ##RRGGBB or #RRGGBBAA |
playerProgressBarThickness | Int? | nil | Change the thickness of the progress bar in the player view. If no value or nil is filled, the default thickness will be used. |
playerProgressBarRadius | Int? | nil | Change the radius of the progress bar in the player view. If no value or nil is filled, the default thickness will be used. Radius will be applied to the 4 corners. |
Dismiss player
To dismiss the player programmatically, you just need to call
JoinStories.dismissPlayer()