You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The QuickBlox JavaScript SDK provides a JavaScript library making it even
5
-
easier to access the QuickBlox cloud backend platform.
4
+
easier to access the QuickBlox cloud communication backend platform.
6
5
7
-
For use inside browsers, a window scoped variable called `QB` is created.
6
+
[QuickBlox](https://quickblox.com) 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 communication functionality to smartphone applications like in Skype, WhatsApp, Viber.
8
7
9
-
Most functions, with the notable exception of init, take a callback
10
-
parameter which gets called with an error and result parameter (ala node.js).
11
8
12
-
If the call was sucessful then result will contain the reply from the
13
-
QuickBlox platform. Similarly, if something went wrong then the error
14
-
parameter will give you a description of what the problem was.
9
+
# Install
15
10
16
-
Install
17
-
----------------
18
-
**Dependencies for browser**
11
+
## Dependencies for browser
19
12
20
-
For correct work of JS SDK you must include the [jQuery](http://jquery.com/) library in your html before `quickblox.js`, like so:
13
+
For the library to work, you need to include either [jQuery](http://jquery.com/) or [Zepto](http://zeptojs.com/) in your html before `quickblox.min.js`, like so:
14
+
15
+
For correct work of JS SDK you must include the library in your html before `quickblox.js`, like so:
If you use bower package manager for your project, you can install JS SDK through bower:
28
25
29
26
```
30
27
bower install quickblox --save
31
28
```
32
29
33
-
**Node.js and NPM**
30
+
When you use **RequireJS**, you are able to use quickblox as AMD module. SDK supports [UMD (Universal Module Definition)](https://github.com/umdjs/umd) pattern for JavaScript modules. So it is possible to use SDK everywhere (as browser global variable, with AMD module loader like RequireJS or as CommonJS module for Node.js environment).
31
+
32
+
## Node.js and NPM integration
33
+
34
+
Also you can use QuickBlox JavaScript SDK with server-side applications on NodeJS through the native node package. Just install the package in your application project like that:
34
35
35
36
```
36
37
npm install quickblox --save
37
38
```
38
39
40
+
And you're ready to go:
41
+
39
42
```javascript
40
43
varQB=require('quickblox');
41
44
@@ -45,113 +48,28 @@ var QB1 = new QuickBlox();
45
48
varQB2=newQuickBlox();
46
49
```
47
50
48
-
A simple example
49
-
----------------
50
-
51
-
```javascript
52
-
// initalise the environmenet with my application id, authentication key and authentication secret
// create an API session (user is not authenticated)
56
-
QB.createSession(function(err, result) {
57
-
if (err) {
58
-
console.log('Something went wrong: '+ err);
59
-
} else {
60
-
console.log('Session created with id '+result.id);
61
-
}
62
-
});
63
-
64
-
// list the users currently enrolled
65
-
QB.users.listUsers(function(err, result) {
66
-
for (var i=0; i <result.items.length; i++) {
67
-
console.log('User '+result.items[i].login+' is registered');
68
-
}
69
-
});
70
-
```
71
-
72
-
Alternative initialisation
73
-
--------------------------
74
-
75
-
Based on user feedback it is now also possible to initialise the SDK using an existing token. This means you can generate a token elsewhere, for example serverside, and then use this token instead of initialising the SDK with your application key and secret.
76
-
77
-
The above simple example can then be coded as shown bellow:
console.log('User '+result.items[i].login+' is registered');
87
-
}
88
-
});
89
-
````
90
-
91
-
Passing configuration options
92
-
----------------------
51
+
## Download ZIP archive
93
52
94
-
Sometimes you will want to pass some configuration options such as a different enterprise endpoint, to enable/disable SSL, setting a timeout for your requests, or turn on debugging. You can dothis by passing an `object` as a fourth parameter to `QB.init()`, like so:
53
+
[QuickBlox JavaScript SDK, zip archive](https://github.com/QuickBlox/quickblox-javascript-sdk/archive/gh-pages.zip)
The code above would then make `QB` make API requests to `http://api.differenthost.com/` rather than `https://api.quickblox.com` and would give you full debugging to the console. It would also set a 5 second timeout for all your requests, triggering the `error` callback.
57
+
| IE | Firefox | Chrome | Safari | Opera | Android Browser | Blackberry Browser | Opera Mobile | Chrome for Android | Firefox for Android |
You can look at it here http://quickblox.com/developers/Javascript
122
64
123
-
Questions and feedback
124
-
----------------------
65
+
# Questions and feedback
125
66
126
67
Please raise questions, requests for help etc. via http://stackoverflow.com/questions/tagged/quickblox
127
68
128
69
Feedback and suggestions for improvement always welcome :)
129
70
71
+
# Modifying and building the library
130
72
131
-
Creating sessions in more detail
132
-
--------------------------------
133
-
```
134
-
QB.createSession(options, callback)
135
-
136
-
options: A map of additional options to pass to the method
137
-
appId - your application's id (overrides the value passed to QB.init)
138
-
authKey - your application's authorization key (overrides the value passed to QB.init)
139
-
authSecret - your application's authorization secret (overrides the value passed to QB.init)
140
-
login - the QuickBlox username of the person to login
141
-
password - the QuickBlox user's password
142
-
email - the email address of the QuickBlox user
143
-
provider - the name of the social network provider for authenticating via Twitter of Facebook
144
-
scope - a list of permisions required by the facebook app
145
-
keys - a map of :
146
-
token - social network access token
147
-
secret - social network access token secret (only required for twitter)
148
-
```
149
-
150
-
Please take a look at the specs for examples of how to use the APIs. In essence the JavaScript SDK is a thin facade to the REST API, so reading the docs [http://quickblox.com/developers/Overview] is strongly recommended :)
151
-
152
-
153
-
Modifying and building the library
154
-
----------------------------------
155
73
The quickblox.js library is build from a number of **CommonJS modules** contained in the `js` folder. For example the `js/modules/qbUsers.js` module contains the code that deals with the [Users API](http://quickblox.com/developers/Users).
156
74
157
75
These modules are combined through [browserify](http://browserify.org/) into a single `quickblox.js` file in the root and so this is the only file that needs to be included in a `<script>` tag OR in a RequireJS application OR in Node.js environment (everywhere). To build the library, use the [Grunt](http://gruntjs.com/) task runner:
@@ -166,4 +84,5 @@ These modules are combined through [browserify](http://browserify.org/) into a s
166
84
*`npm publish`. This action updates SDK for node package manager, but maybe you will be needed some author credentials for it (you should be in owner list)
0 commit comments