Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ionViewDidLoad() {
- this.showLoading();
- this.auth.deviceExists().then(result => {
- if(result == 'ok') {
- console.log('status = ok');
- setTimeout(() => {
- this.loading.dismiss();
- });
- } else {
- console.log('status = error');
- setTimeout(() => {
- this.loading.dismiss();
- this.nav.setRoot(RegisterPage);
- });
- }
- }, err => {
- console.log('status = problem');
- setTimeout(() => {
- this.loading.dismiss();
- this.nav.setRoot(RegisterPage);
- });
- }).catch((err) => {
- this.loading.dismiss();
- // this.nav.setRoot(RegisterPage);
- this.showError(err);
- });
- }
- deviceExists()
- {
- console.log(this.deviceID);
- return new Promise((resolve, reject) => {
- if (this.deviceID === null) {
- reject("Device ID is null");
- } else {
- this.isLoggedIn().subscribe(result => {
- resolve(result['status']);
- }, (err) => {
- reject(err);
- });
- }
- }).catch(err => {
- return "error";
- });
- }
- isLoggedIn()
- {
- let url = `${this.apiURL}getdevice`;
- let params = `deviceid=${this.deviceID}`;
- let headers = new Headers({ 'Content-Type': 'application/x-www-form-urlencoded'});
- let options = new RequestOptions({ headers: headers });
- return this.http.post(url, params, options)
- .map(res => { return res.json(); })
- .catch(res => { return res.json(); });
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement