You are here: MessengerYouLike.IMSDK > IMSDK Reference > IMSDK Namespace > Classes > IMClient Class > IMClient Methods > IMClient.BeginAddFriend Method
MessengerYouLike
IMClient.BeginAddFriend Method

This Method Allows Users to add a friend to there contacts List

C#
public BeginAddFriend(String Username, String GroupUID, String Message);
Visual Basic
Public Sub BeginAddFriend(ByVal Username As String, ByVal GroupUID As String, Optional ByVal Message As String = "")
Parameters 
Description 
ByVal Username As String 
Username of friend being Added 
ByVal GroupUID As String 
ID of the Group Where Friends Needs to be added 
Optional ByVal Message As String = "" 
Specify a message that will be made available in IMSDK.IMClient.OnFriendAskingPrimssion 

Friend is added to users Contacts,if GroupUID is Sepcifed it is added under that group else no group is assigned to this Contact ,Message is optional if specified will be shown to user when event IMSDK.IMClient.OnFriendAskingPrimssion is fired in IMClient 

 

if Friend being added is online then a event IMSDK.IMClient.OnFriendAskingPrimssion will be fired on the friends IMClient

if the Friends IMClient Accepts the request [ IMSDK.IMClient.BeginFriendAuthorizationAccepted ] then the Friend is added and then the event IMSDK.IMClient.OnFriendAuthorizationCompleteOfOnlineFriend is fired and 

 

if the friend is offline the friend will still be added but the AuthorizationStatus of the friend will be IMSDK.IMClient.AuthorizationStatus.Unauthorized after the friends comes online and accepts the invitation then IMSDK.IMClient.OnFriendAuthorizationComplete event is fired 

 

once the user accepts the friend added request the AuthorizationStatus will be changed to IMSDK.IMClient.AuthorizationStatus.Authorized and if Friends IMClient Denies [ IMSDK.IMClient.BeginFriendAuthorizationDenied ]the invitation then Friend will be deleted from the Users Contacts list and event will be fired IMSDK.IMClient.OnFriendAuthorizationDeniedMessage 

 

Total Friends Should Not Exceed the Value Set by property IMSDK.IMClient.MAXFriends

[Visual Basic]
 
'Create a new IMClient
Dim MC as new IMSDK.IMClient
 
 
 
'Call the Listen Sub
MC.Listen()
 
 
 
'Now Try to login
MC.BeginLogin(TxtUsername.Text,TxtPassword.Text)
 
 
 
'if username and password is valid then
Private Sub MC_OnLoggedin(ByVal UserObject As IMSDK.User) Handles MC.OnLoggedin
    Debug.WriteLine("Username logged in : " & MCUser.Username & " , " & MCUser.Password)
End Sub
 
 
 
'if username or password is invalid then
Private Sub MC_OnUsernameOrPasswordInvalid(ByVal Username As String, ByVal Password As String) Handles MC.OnUsernameOrPasswordInvalid
  Debug.WriteLine("Username password invalid : " & Username & " , " & Password)
End Sub
 
 
 
 
'Now Add a Friend
 MC.BeginAddFriend(TxtFriendusername.text, TxtGroupUID.Text, txtMessage.text)
 
 
 
'If Friend Invitation Accepted then
  Private Sub MC_OnFriendAuthorizationComplete(ByVal Username As String) Handles MC.OnFriendAuthorizationComplete
    Debug.WriteLine("FriendAuthorization Complete of user " & username)
  End Sub
 
 
 
'If Friend Invitation Denied then
Private Sub MC_OnFriendAuthorizationDeniedMessage(ByVal FriendUsername As String, ByVal message As String) Handles MC.OnFriendAuthorizationDeniedMessage
      Debug.WriteLine("Username : " & FriendUsername & " has denied your invitaion with a message : " & message)
 End Sub
Copyright (c) 2007. All rights reserved.