Connection

Connect to TapTalk.io server

You can manually connect to TapTalk.io by calling this method.
Note: Please make sure that you have finished authentication by calling authenticateWithAuthTicket:connectWhenSuccess:method, otherwise, it will return an error
Objective-C
1
#import <TapTalk/TapTalk.h>
2
3
[[TapTalk sharedInstance] connectWithCompletionHandler:^{
4
//Success connect to TapTalk.io server
5
}];
Copied!

Disconnect from TapTalk.io server

You can disconnect from TapTalk.io when the user no longer needs to receive messages from an online state. But the user can still receive push notifications for new messages when the app is closed.
When the user is disconnected from the server, all event delegates will stop receiving event callbacks from the server.
Objective-C
1
#import <TapTalk/TapTalk.h>
2
3
[[TapTalk sharedInstance] disconnectWithCompletionHandler:^{
4
// Success disconnected from TapTalk.io server.
5
}];
Copied!

Check Connection Status

You can check whether you are connected to TapTalk.io server by calling isConnected method.
Objective-C
1
#import <TapTalk/TapTalk.h>
2
3
BOOL isConnected = [[TapTalk sharedInstance] isConnected];
Copied!

Enable / Disable Auto Connect

You can choose to enable or disable auto connect by calling these methods. TapTalk.io will automatically connect to the server every time the user opens the app from the background when auto connect is enabled. Please note that the default value is enabled.
Objective-C
AppDelegate.m
1
#import <TapTalk/TapTalk.h>
2
3
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
4
5
//Other Code
6
...
7
...
8
...
9
10
//Call this method to enable or disable auto connect to socket
11
//The default is enabled if you do not set this method
12
[[TapTalk sharedInstance] enableAutoConnect:IS_ENABLED];
13
}
Copied!

Parameters

IS_ENABLED: (BOOL) set to TRUE/YES to enable auto connect to TapTalk server

Get Auto Connect Status

Use this method to obtain auto connect status. This method will return TRUE if auto connect is enabled
Objective-C
1
#import <TapTalk/TapTalk.h>
2
3
//Call this method obtain auto connect status
4
//isAutoConnectEnabled will return TRUE if auto connect is enabled
5
BOOL isAutoConnectEnabled = [[TapTalk sharedInstance] isAutoConnectEnabled];
Copied!
Last modified 1yr ago