连接到 Pusher ChatKit [Swift]
Connect to Pusher ChatKit [Swift]
我正在尝试连接到 pusher chatkit;但是,每次我尝试连接时都会收到此响应:
"Making attempt 5 of 6 in 16.0s. Error was: Bad response status code received: 401 with error message: services/chatkit_authorizer/authorization/missing_permission: User does not have access to requested resource"
尝试 6 次后,它会连接,所以我不确定缺少的权限是什么。
下面是我用来连接的代码。
self.chatManagerDelegate = MyChatManagerDelegate()
chatManager = ChatManager(instanceLocator: Pusher_Chatkit.instanceLocator,
tokenProvider: PCTokenProvider(url: Pusher_Chatkit.tokenProvider),
userID: "user-id")
chatManager.connect(delegate: chatManagerDelegate!) { currentUser, error in
guard error == nil else {
print("Error connecting: \(error!.localizedDescription)")
return
}
print("Successfully connected")
确保您为用户尝试连接的角色启用了 cursors:read:get
权限。您可以使用 dashboard, one of our server SDKs, or the API directly.
如果不启用此权限,连接尝试当前将失败,因为所有客户端都会尝试建立订阅以接收读取游标更新,即使您没有在应用的其他任何地方使用读取游标功能也是如此。
我正在尝试连接到 pusher chatkit;但是,每次我尝试连接时都会收到此响应:
"Making attempt 5 of 6 in 16.0s. Error was: Bad response status code received: 401 with error message: services/chatkit_authorizer/authorization/missing_permission: User does not have access to requested resource"
尝试 6 次后,它会连接,所以我不确定缺少的权限是什么。
下面是我用来连接的代码。
self.chatManagerDelegate = MyChatManagerDelegate()
chatManager = ChatManager(instanceLocator: Pusher_Chatkit.instanceLocator,
tokenProvider: PCTokenProvider(url: Pusher_Chatkit.tokenProvider),
userID: "user-id")
chatManager.connect(delegate: chatManagerDelegate!) { currentUser, error in
guard error == nil else {
print("Error connecting: \(error!.localizedDescription)")
return
}
print("Successfully connected")
确保您为用户尝试连接的角色启用了 cursors:read:get
权限。您可以使用 dashboard, one of our server SDKs, or the API directly.
如果不启用此权限,连接尝试当前将失败,因为所有客户端都会尝试建立订阅以接收读取游标更新,即使您没有在应用的其他任何地方使用读取游标功能也是如此。