Skip to content

amigo2/quickblox-ios-sdk

 
 

Repository files navigation

QuickBlox

QuickBlox - Communication & cloud backend (BaaS) platform which brings superpowers to mobile apps.

QuickBlox is a suite of communication features & data services (APIs, SDKs, code samples, admin panel, tutorials) which help digital agencies, mobile developers and publishers to add great functionality to smartphone applications.

Please read full iOS SDK documentation on the QuickBlox website, iOS section

QuickBlox iOS SDK

This project contains QuickBlox iOS SDK, that includes

How to start

To start work you should just put framework into your project and call desired methods.

Latest framework file you can download from GitHub.

Documentation

Oh, please, please show me the code

iOS SDK is really simple to use. Just in few minutes you can power your mobile app with huge amount of awesome communication features & data services.

1. Get app credentials

2. Create new iOS project

3. Add framework to project, see this tutorial

4. Make QuickBlox API calls

The common way to interact with QuickBlox can be presented with following sequence of actions:

  1. Initialize framework with application credentials
  2. Create session
  3. Login with existing user or register new one
  4. Perform actions with QuickBlox communication services and any data entities (users, locations, files, custom objects, pushes etc.)

4.1 Initialize framework with application credentials

[QBApplication sharedApplication].applicationId = 92;
[QBConnection registerServiceKey:@"wJHdOcQSxXQGWx5"];
[QBConnection registerServiceSecret:@"BTFsj7Rtt27DAmT"];
[QBSettings setAccountKey:@"7yvNe17TnjNUqDoPwfqp"];

4.2. Create session

[QBRequest createSessionWithSuccessBlock:^(QBResponse *response, QBASession *session) {
    //Your Quickblox session was created successfully
} errorBlock:^(QBResponse *response) {
    //Handle error here
}];

4.3. Register/login

First create (register) new user

QBUUser *user = [QBUUser user];
user.login = @"garry";
user.password = @"garry5santos";

[QBRequest signUp:user successBlock:^(QBResponse *response, QBUUser *user) {
    // Success, do something
} errorBlock:^(QBResponse *response) {
    // error handling
}];

then authorize user

[QBRequest logInWithUserLogin:@"garry" password:@"garry5santos" successBlock:^(QBResponse *response, QBUUser *user){
    // Request succeded
} errorBlock:^(QBResponse *response) {
    // error handling
    NSLog(@"error: %@", response.error);
}];

to authorise user in Chat

QBUUser *currentUser = [QBUUser user];
currentUser.ID = 2569; // your current user's ID
currentUser.password = @"garrySant88"; // your current user's password   
 
// set Chat delegate
[QBChat instance].delegate = self;
 
// login to Chat
[[QBChat instance] loginWithUser:currentUser];
 
#pragma mark -
#pragma mark QBChatDelegate
 
// Chat delegate
-(void) chatDidLogin{
    // You have successfully signed in to QuickBlox Chat
}

4.4. Perform actions

Send Chat message

// send message
QBChatMessage *message = [QBChatMessage message];
message.recipientID = 546; // opponent's id
message.text = @"Hi mate!";
 
[[QBChat instance] sendMessage:message];
 
 
#pragma mark -
#pragma mark QBChatDelegate
 
- (void)chatDidReceiveMessage:(QBChatMessage *)message{
    NSLog(@"New message: %@", message);
}

Create new location for Indiana Jones

QBLGeoData *location = [QBLGeoData geoData];
location.latitude = 23.2344;
location.longitude = -12.23523;
location.status = @"Hello, world, I'm Indiana Jones, I'm at London right now!";
 
[QBRequest createGeoData:location successBlock:^(QBResponse *response, QBLGeoData *geoData) {
    // Request succeded
} errorBlock:^(QBResponse *response) {
    // error handling
}];

or put Image into storage

NSData *file = [NSData dataWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"YellowStar" ofType:@"png"]];

[QBRequest TUploadFile:file fileName:@"Great Image" contentType:@"image/png" isPublic:NO successBlock:^(QBResponse *response, QBCBlob *blob) {
    // File uploaded
} statusBlock:^(QBRequest *request, QBRequestStatus *status) {
    // Progress
    NSLog(@"%f", status.percentOfCompletion);
} errorBlock:nil];

iOS Framework provides following classes to interact with QuickBlox API (each class has suite of static methods):

  • QBAuth
  • QBUsers
  • QBChat
  • QBVideoChat
  • QBCustomObjects
  • QBLocation
  • QBContent
  • QBRatings
  • QBMessages

See also

About

quickblox-ios-sdk

Resources

Stars

Watchers

Forks

Packages

No packages published