Skip to content

Commit 19d011d

Browse files
committed
Add initializer just for tvOS
1 parent 53ec203 commit 19d011d

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

Source/PusherSwift.swift

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ let CLIENT_NAME = "pusher-websocket-swift"
2525

2626
#if os(iOS) || os(OSX)
2727
public let nativePusher: NativePusher
28-
#endif
2928

3029
/**
3130
Initializes the Pusher client with an app key and any appropriate options.
@@ -46,6 +45,26 @@ let CLIENT_NAME = "pusher-websocket-swift"
4645
self.nativePusher = nativePusher
4746
nativePusher.setPusherAppKey(pusherAppKey: key)
4847
}
48+
#endif
49+
50+
#if os(tvOS)
51+
/**
52+
Initializes the Pusher client with an app key and any appropriate options.
53+
54+
- parameter key: The Pusher app key
55+
- parameter options: An optional collection of options
56+
57+
- returns: A new Pusher client instance
58+
*/
59+
public init(key: String, options: PusherClientOptions = PusherClientOptions()) {
60+
self.key = key
61+
let urlString = constructUrl(key: key, options: options)
62+
let ws = WebSocket(url: URL(string: urlString)!)
63+
connection = PusherConnection(key: key, socket: ws, url: urlString, options: options)
64+
connection.createGlobalChannel()
65+
}
66+
#endif
67+
4968

5069
/**
5170
Subscribes the client to a new channel

0 commit comments

Comments
 (0)