Please Wait

Loading..

Presence

Identify when user enter or leave your Application.

Easily Learn in 4 steps

1. Connect To YALGAAR with User Id

The first step is to sign up to Yalgaar using our get started form. You can get in your dashboard in under few seconds. In your dashboard there is a demo app created, click on it and go to App Information page. You can see your client key. To Connect to a Yalgaar use your client key with UUID. UUID is any unique user name or user id for user to enable presence feature for client.


<!-- Include the Yalgaar Library -->
<script src="yalgaar.js" type="text/javascript"> </script>

<!-- Connect to Yalgaar with your client key --> <script type="text/javascript"> ConnectToYalgaar({ ClientKey: 'YourClientKey', SSL: false, UUID:'YourUUID', Callback: function (acknowledgement) { }, Error: function (err) { } }); </script>

//Required .Net Framework 4.5 or above

//Using Yalgaar library using YalgaarNet;
//Connect to Yalgaar with your client key YalgaarClient yalgaar = new YalgaarClient("YourClientKey", false, "YourUUID", ConnectionCallback);
//Create object of Yalgaar client with context of application
YalgaarApiClient objYalgaarClient = new YalgaarApiClient.Builder(context).build();
                            
//Connect to a Yalgaar client with your client key yalgaar.connect("YourClientKey", false, "YourUUID", ConnectionCallback);

//iOS device with version 7.1 or above. 

//create an object of YalgaarClient class. YalgaarClient *objYalgaarClient = [[YalgaarClient alloc] init];
//Connect to Yalgaar with your client key [objYalgaarClient connectWithClientKey:@"YourClientKey" IsSecure: YES WithUUID:@"YourUUID" Error:&error]; //called when connection done successfully (void) didConnected{ }

For more languages, 
check out Yalgaar SDK & Documentation page
SDK & Documentation
                                                          


<!-- Subscribe to YourChannel -->
<script type="text/javascript">
SubscribeMessage({
    ChannelName: 'YourChannel',
    Callback: function (message, channel, acknowledgement) {
        // Shows alert when message receive
        alert(message);
    },
    CallbackPresence: function (message, channel, acknowledgment) {
        // Shows alert when user bind or unbind on channel
        alert(message);
    }
});
</script>
                            

//Subscribe to YourChannel
yalgaar.Subscribe("YourChannel", SubscribeReturnMessage, PresenceMessage, SubErrorMessage);
                            
//shows message box when message subscribe public void SubscribeReturnMessage(string Channel, string message) { MessageBox.Show(Message); } // Shows message box when user bind or unbind on channel public void PresenceMessage(string Channel, string message) { MessageBox.Show(Message); } //shows message box when Error occur private void SubErrorMessage(string Message) { MessageBox.Show(Message); }

//Subscribe to YourChannel
yalgaar.subscribe("YourChannel", subscriptionCallback, presenceCallback);
                            
//print when message subscribe public void subscriptionCallback(string message) { System.out.println(message); } //print when user bind or unbind on channel public void presenceCallback(string message) { System.out.println(message); }

//Subscribe to Channel
[objYalgaarClient unsubscribeWithChannel:@"YourChannel" Error:&error];

//called when receive data 
(void) dataReceivedForSubscription:(NSString *)data OnChannels:(NSArray *)Channels{
    NSLog(@"Data received: %@", data);
}

//function called when someone subscribe to Channel
(void) dataReceivedOfPresenceForAction:(PresenceAction)action OnChannel:(NSString *)Channel UUID:(NSString*)uuid DateTime:(NSDate*)dateTime{
    NSString* combineChannelAndData = [NSString stringWithFormat:@"Action:%@ - Channel:%@ - UUID:%@ - Time:%@", action, channel, uuid, [NSDateFormatter localizedStringFromDate:dateTime dateStyle:NSDateFormatterShortStyle timeStyle:NSDateFormatterShortStyle]];
    NSLog(@"Data received: %@", combineChannelAndData);
}
                            

For more languages, 
check out Yalgaar SDK & Documentation page
SDK & Documentation
                                                          

2. Subscribe message with presence

To subscribe message with presence use presence callback. The YALGAAR SDKs automatically subscribe channel for Presence event to show User Bind or Unbind on that channel.


3. Get user list

At any given point of time, you can get a list of all users currently subscribed to a specific channel by calling a function in your app.


<!-- Get user list currently subscribe YourChannel -->
<script type="text/javascript">
GetUUIDList({
    ChannelName: 'YourChannel',
    Callback: function (list, err) {
    }
});
</script>
                            

//Get user list currently subscribe YourChannel
yalgaar.GetUUIDList("YourChannel", UserListCallback, ErrorMsgCallback);
                            
//Note: UserListCallback and ErrorMsgCallback are callback methods

//Get user list currently subscribe YourChannel
yalgaar.getUUIDList("YourChannel", UserListCallback);

//Note: UserListCallback is callback method.
                                                          

//Get user list currently subscribe YourChannel
[objYalgaarClient getUUIDListForChannel:@"YourChannel" Error:&error];

//Note: In response of above function call, below delegate will be called.
// (void) dataReceivedWithUUID:(NSArray*)arrUUID ForChannel:(NSString*)channel; 
                            

For more languages, 
check out Yalgaar SDK & Documentation page
SDK & Documentation
                                                          


<!-- Get Channel list subscribed by YourUUID -->
<script type="text/javascript">
GetChannelList({
    UUID: 'YourUUID',
    Callback: function (list, err) {
    }
});
</script>
                            

//Get Channel list subscribed by YourUUID
yalgaar.GetChannelList("YourUUID", ChannelListCallback, ErrorMsgCallback);
                            
//Note: ChannelListCallback and ErrorMsgCallback are callback methods

//Get Channel list subscribed by YourUUID
yalgaar.getChannelList("YourUUID", ChannelListCallback);

//Note: ChannelListCallback is callback method.
                            

//Get Channel list subscribed by User
[objYalgaarClient getChannelListForUUID:@”YourUUID” Error:&error];

//Note: In response of above function call, below delegate will be called.
// (void) dataReceivedWithChannels:(NSArray*)arrChannels ForUUID:(NSString*)uuid;
                            

For more languages, 
check out Yalgaar SDK & Documentation page
SDK & Documentation
                                                          

4. Get channels list

As user list, you can also get a list of all channels subscribed by a specific user by calling a function in your app.


Try another tutorials