Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
derived from backand-ionic2-starter
- Loading branch information
Showing
6 changed files
with
683 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,89 @@ | ||
# angular2bknd-sdk | ||
Backand SDK for Angular 2 (WIP) | ||
|
||
run `npm start` and visit localhost:8080 | ||
Backand SDK for Angular 2 | ||
|
||
## Customize for Your App | ||
|
||
In file, `app/services/backandService.ts`, in `BackandService`, set this local variables: | ||
|
||
|
||
app_name:string = 'your app name'; | ||
signUpToken: string = 'your signup token'; | ||
anonymousToken: string = 'your anonymousToken token'; | ||
|
||
## Setup of Platform | ||
|
||
This is done in `app.ts`, within `platform.ready()`, | ||
|
||
* Are we on a mobile or desktop browser? | ||
|
||
let isMobile = platform.is('mobile'); | ||
backandService.setIsMobile(isMobile); | ||
|
||
* Do we call signup if we tried to sign in via a social networkm and | ||
the user is not signed up for the app? | ||
|
||
backandService.setRunSignupAfterErrorInSigninSocial(true); | ||
|
||
## CRUD | ||
|
||
To fetch, create, and filter rows, from an object, say `stuff`, modify | ||
the `url` used in these functions: | ||
|
||
getItems | ||
filterItems | ||
postItem | ||
|
||
replacing `todo` with the name of your object, `stuff` | ||
|
||
## Social Signup | ||
|
||
The app opens a dialog supplied by the social network. | ||
|
||
## In App | ||
|
||
|
||
Use the Facebook Connect plugin to obtain access to the native FB application on iOS and Android. | ||
|
||
Install it with: | ||
|
||
ionic plugin add cordova-plugin-facebook4 --save --variable APP_ID="<Facebook APP ID>" --variable APP_NAME="<Facebook APP NAME>" | ||
|
||
Use `BackandService` function `inappSocial` | ||
|
||
## Socket Service | ||
|
||
1. Add to `package.json` the dependency, | ||
|
||
"socket.io-client": "^1.4.8" | ||
|
||
Add to `typings.json` the global dependencies: | ||
|
||
"node": "registry:dt/node#6.0.0+20160514165920", | ||
"socket.io-client": "registry:dt/socket.io-client#1.4.4+20160317120654" | ||
|
||
2. Install dependencies | ||
|
||
npm install | ||
typings install | ||
|
||
3. To login via socket call `BackandService.loginSocket` | ||
|
||
4. To logout from socket call `BackandService.logoutSocket` | ||
|
||
5. To subscribe to event `items_updated` from server side via sockets, | ||
call `BackandService.susbcribeSocket` and in your controller, subscribe with, | ||
|
||
this.backandService.subscribeSocket('items_updated') | ||
.subscribe( | ||
data => { | ||
}, | ||
err => { | ||
console.log(err); | ||
}, | ||
() => console.log('received update from socket') | ||
); | ||
|
||
|
Oops, something went wrong.