0

I am using twilio chat sdk in my iPhone application, on twilio website I have settled role permission editChannelAttributes is true for creator. and trying to set attribute like

        TwilioChatHelper.sharedInstance.selectedChannel?.setAttributes(attr, completion: { (result) in
        print(result?.isSuccessful() ?? "Not able to set attributes")
    })

but getting error in result

The operation couldn’t be completed. (signal.sdk.domain.error error 102.)

Please suggest me what I am missing.

Shubham bairagi
  • 913
  • 7
  • 25
  • check app name and other parameters should match with app plist. – MAhipal Singh Jan 10 '18 at 06:33
  • Thanks @MAhipalSingh, but I think If those details are not proper then chat also won't work, creating channel, Chat are working fine, only issue while setting the channel attributes. – Shubham bairagi Jan 10 '18 at 06:40
  • then you need to check "role permission" https://www.twilio.com/docs/api/chat/rest/roles#action-update and https://www.twilio.com/docs/api/chat/guides/permissions – MAhipal Singh Jan 10 '18 at 07:52

1 Answers1

1

Twilio developer evangelist here.

Mahipal Singh is definitely on the right track here, this is down to roles and permissions in Twilio Chat.

A regular channel user role, by default, has the following permissions:

  • deleteOwnMessage
  • editOwnMessage
  • editOwnMessageAttributes
  • leaveChannel
  • sendMediaMessage
  • sendMessage

If you want all channel users to be able to update a channel's attributes, then you will need to use the Roles REST API to either add the editChannelAttributes permission to the default channel role or create a new role with that permission that you then assign to your channel members.

Let me know if that helps at all.

philnash
  • 53,704
  • 10
  • 46
  • 69
  • Thanks philnash, but that was not an issue I have done that setup properly it seems the issue Is different, I am setting the last message Date, as a Date object so issue is coming, if I do with converting it into string it will work. – Shubham bairagi Jan 11 '18 at 05:28
  • Ah, ok, glad you found the solution. I just took a look at [the documentation](https://media.twiliocdn.com/sdk/ios/chat/releases/2.2.0/docs/Classes/TCHChannel.html#//api/name/setAttributes:completion:) and sounds like that's definitely the case, it says that the supported types for the attributes dictionary are `NSString`, `NSNumber`, `NSArray`, `NSDictionary` and `NSNull`. – philnash Jan 11 '18 at 05:34