File tree 1 file changed +15
-11
lines changed
android/src/main/java/com/pusherwebsocketreactnative
1 file changed +15
-11
lines changed Original file line number Diff line number Diff line change @@ -93,18 +93,22 @@ class PusherWebsocketReactNativeModule(reactContext: ReactApplicationContext) :
93
93
94
94
@ReactMethod
95
95
fun subscribe (channelName : String , promise : Promise ) {
96
- val channel = when {
97
- channelName.startsWith(" private-encrypted-" ) -> pusher!! .subscribePrivateEncrypted(
98
- channelName, this
99
- )
100
- channelName.startsWith(" private-" ) -> pusher!! .subscribePrivate(channelName, this )
101
- channelName.startsWith(" presence-" ) -> pusher!! .subscribePresence(
102
- channelName, this
103
- )
104
- else -> pusher!! .subscribe(channelName, this )
96
+ try {
97
+ val channel = when {
98
+ channelName.startsWith(" private-encrypted-" ) -> pusher!! .subscribePrivateEncrypted(
99
+ channelName, this
100
+ )
101
+ channelName.startsWith(" private-" ) -> pusher!! .subscribePrivate(channelName, this )
102
+ channelName.startsWith(" presence-" ) -> pusher!! .subscribePresence(
103
+ channelName, this
104
+ )
105
+ else -> pusher!! .subscribe(channelName, this )
106
+ }
107
+ channel.bindGlobal(this )
108
+ promise.resolve(null )
109
+ } catch (e: Exception ) {
110
+ promise.reject(" Error" , " Failed to subscribe to channel: $channelName " , e)
105
111
}
106
- channel.bindGlobal(this )
107
- promise.resolve(null )
108
112
}
109
113
110
114
@ReactMethod
You can’t perform that action at this time.
0 commit comments