代码之家  ›  专栏  ›  技术社区  ›  Rajeev Singh

Twilio-通过inviteByIdentity使用swift客户端代码在专用频道上邀请用户

  •  0
  • Rajeev Singh  · 技术社区  · 7 年前

    如果通道不存在,则创建新的专用通道

    let options: [NSObject:AnyObject] = [
    TWMChannelOptionFriendlyName: defaultChannel,
    TWMChannelOptionUniqueName: defaultChannel,
    TWMChannelOptionType: TWMChannelType.Private.rawValue
    ]  
    
    channels?.createChannelWithOptions(options, completion: { (result, 
    channel) in
        if result.isSuccessful(){
            channel.joinWithCompletion({ (result) in
                if result.isSuccessful(){ ... }})
    

    一旦用户成功加入频道,我们将向其他用户发送邀请,邀请其加入同一频道。

    availableChannel.members.inviteByIdentity(other_user_name, completion: 
    { 
    (result) in
        if result.isSuccessful(){ ... })
    

    但对于其他用户,当其他用户向他发送聊天邀请时,他如何得到通知,在twilio聊天的示例应用程序中,我没有收到任何邀请接受的响应。

    2 回复  |  直到 7 年前
        1
  •  1
  •   Rajeev Singh    7 年前

    当用户创建新频道时,在同一应用程序中注册的所有其他用户都会通过委托方法得到新频道创建的通知。

    因此,简单的解决方案是使用sender\u receiver name创建通道名称,因此当receiver调用委托方法时,他将检查其名称是否存在于通道中,如果通道名称包含其名称,则它将加入通道,否则将离开通道。

        2
  •  0
  •   DURGESH    7 年前

    当有人邀请您加入某个频道时,您会收到委托方法的调用

    - (void)chatClient:(TwilioChatClient *)client notificationInvitedToChannelWithSid:(NSString *)channelSid { [self displayNotificationForChannelSid:channelSid messagePlaceholder:@"You were invited to channel '%@'."]; }