Skip to content

EugeneNguyen/XBPushChat

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

85 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

XBPushChat

CI Status Version License Platform PayPayl donate button

Usage

To run the example project, clone the repo, and run pod install from the Example directory first.

Requirements

Installation

XBPushChat is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod "XBPushChat"

How to use

  1. Install XBPushChat & PushChat + (a module of PlusIgniter)
  2. Config XBPushChat when app start:
[[XBPushChat sharedInstance] registerPush]; // register push notification, support all iOS
[[XBPushChat sharedInstance] setHost:@"http://ciplustest.libre.com.vn"]; // setup host of PushChat+

and some bootstrap

- (void)applicationWillResignActive:(UIApplication *)application
{
    [[XBPushChat sharedInstance] setPresence:0];
}

- (void)applicationDidEnterBackground:(UIApplication *)application
{
    [[XBPushChat sharedInstance] setPresence:0];
}

- (void)applicationWillEnterForeground:(UIApplication *)application
{
    [[XBPushChat sharedInstance] setPresence:1];
}

- (void)applicationDidBecomeActive:(UIApplication *)application
{
    [[XBPushChat sharedInstance] setPresence:1];
}

- (void)applicationWillTerminate:(UIApplication *)application
{
    [[XBPushChat sharedInstance] setPresence:0 synchronous:YES];
}

#pragma mark - Push Delegate

- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken
{
    [[XBPushChat sharedInstance] didReceiveToken:deviceToken];
}

- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo
{
    [[XBPushChat sharedInstance] didReceiveRemoteNotification:userInfo];
}

- (void)application:(UIApplication *)application didFailToRegisterForRemoteNotificationsWithError:(NSError *)error
{
    [[XBPushChat sharedInstance] didFailToRegisterForRemoteNotification:error];
}
  1. After get your userid (after login / register), you can start to chat:
[[XBPushChat sharedInstance] setSender_id:99]; // 99 is your userid
```objc

4. Fetch your history
```objc
[[XBPushChat sharedInstance] fetchAllRequest]; //get all history
//or 
[[XBPushChat sharedInstance] fetchRequestWith:100]; //get all message between you and user 100
  1. Setup your presence
[[XBPushChat sharedInstance] setPresence:1]; //1 is online. 0 is offline
  1. And show the chat view anytime you need

Author

eugenenguyen, [email protected]

Contact

Any question, request, suggest, please feel free to send to us. You're always welcome.

LIBRETeamStudio

License

XBMobile is available under the MIT license. See the LICENSE file for more info.

Donation

This is open-source project. If you want to support us to keep develop this, or just give me a beer, don't be shy :) i will always appreciate that.

PayPayl donate button

License

XBPushChat is available under the MIT license. See the LICENSE file for more info.