User Meta Data

Registration with MetaData#

    try! ChatManager.registerApiService(for: USER_IDENTIFIER, metaData: [MetaData] ) { isSuccess, flyError, flyData in
    var data = flyData
    if isSuccess {
    // This is your Password
    guard let password = data["password"] as? String else{
    return
    }
    // This is your Username
    guard let username = data["username"] as? String else{
    return
    }
    // This is your JID
    guard let username = data["userJid"] as? String else{
    return
    }
    }else{
    let error = data.getMessage()
    print("#chatSDK \(error)")
    }
    }
    ArgumentTypeDescription
    USER_IDENTIFIERStringUnique Id to Register the User
    APNS_DEVICE_TOKENStringToken to register APNS device (optional)
    VOIP_DEVICE_TOKENStringToken to register VoIP device (optional)
    IS_EXPORTBooltrue for production(apns certificate) builds and false for sandbox(apns certificate)builds
    IS_FORCE_REGISTERBooldefault value true provide true to force the logout of the old session If the registered user has reached the maximum no of multi-sessions or provide false to allow registration till the maximum no of multi-sessions
    USER_TYPEStringType of the user (optional)
    META_DATA[MetaData]list of key - value pair of metadata object. Maximum size is 3 (optional)
    CALLBACKFlyCompletionHandlerFlyCompletionHandler is implemented and expressed as lambda expression

    To know more about FlyCompletionHandler click here

    User List with MetaData#

    To retrive all registered users on MirrorFly SDK use below method. User list can also be retrived based on MetaData.

      ContactManager.shared.getUsersList(metaData: MetaDataUserList){ isSuccess,flyError,flyData in
      if isSuccess{
      var data = flyData
      if let profileArray = data.getData() as? [ProfileDetails]{}
      let totalPages = data["totalPages"] as? Int
      let totalUsers = data["totalRecords"] as? Int
      } else {
      //print error
      }
      });

      Refer this doc to know more about Profile Details Class

      ArgumentTypeDescription
      PAGE_NUMBERintPage number of user list default value 1
      PER_PAGE_RESULT_SIZEintNumber of users per page default value 50
      SEARCH_TERMStringtext characters for which search has to happen default value empty
      META_DATAMetaDataUserListmodel class which filters the results by metadata default value is empty
      CALLBACKFlyCompletionHandlerFlyCompletionHandler used as completion Handler

      Get MetaData of user#

      To get MetaData value of user call the below method.

        ChatManager.getMetaData { (isSuccess, flyError, resultDict) in
        if isSuccess {
        var flydata = resultDict
        print(flydata.getData())
        }else{
        //Getting metaData failed
        }
        }
        ArgumentTypeDescription
        CALLBACKFlyCompletionHandlerFlyCompletionHandler used as completion Handler

        Update MetaData of user#

        To Update MetaData value of user call the below method.

          ChatManager.updateMetaData([MetaData]) { (isSuccess, flyError, resultDict) in
          if isSuccess {
          var flydata = resultDict
          print(flydata.getData())
          }else{
          //Updating metaData failed
          }
          }
          ArgumentTypeDescription
          META_DATAMetaDatalist of key - value pair of metadata object. Maximum size is 3 (optional)
          CALLBACKFlyCompletionHandlerFlyCompletionHandler used as completion Handler