To run the example project, clone the repo, and run pod install
from the Example directory first.
XBPushChat is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod "XBPushChat"
- Install XBPushChat & PushChat + (a module of PlusIgniter)
- 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];
}
- 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
- Setup your presence
[[XBPushChat sharedInstance] setPresence:1]; //1 is online. 0 is offline
- And show the chat view anytime you need
eugenenguyen, [email protected]
Any question, request, suggest, please feel free to send to us. You're always welcome.
XBMobile is available under the MIT license. See the LICENSE file for more info.
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.
XBPushChat is available under the MIT license. See the LICENSE file for more info.