i am getting “Response with status: 200 for URL: null” error when i try to service. but at the same time changes update in DB.But the same code working fine in android i got the issue in ios only.
following are my code snippet
package.json
{
"description": "NativeScript Application",
"license": "SEE LICENSE IN <your-license-filename>",
"readme": "NativeScript Application",
"repository": "<fill-your-repository-here>",
"nativescript": {
"id": "org.nativescript.GrAccess",
"tns-android": {
"version": "2.5.0"
},
"tns-ios": {
"version": "2.4.0"
}
},
"dependencies": {
"@angular/common": "2.3.1",
"@angular/compiler": "2.3.1",
"@angular/core": "2.3.1",
"@angular/forms": "2.3.1",
"@angular/http": "2.3.1",
"@angular/platform-browser": "2.3.1",
"@angular/platform-browser-dynamic": "2.3.1",
"@angular/router": "3.3.1",
"nativescript-angular": "1.3.0",
"nativescript-background-http": "^2.5.1",
"nativescript-drop-down": "^1.4.0",
"nativescript-geolocation": "0.0.19",
"nativescript-google-maps-sdk": "^1.4.3",
"nativescript-imagepicker": "^2.1.7",
"nativescript-ios-uuid": "^1.0.0",
"nativescript-iqkeyboardmanager": "^1.0.1",
"nativescript-permissions": "^1.2.3",
"nativescript-theme-core": "^0.2.1",
"reflect-metadata": "~0.1.8",
"rxjs": "5.0.0-rc.4",
"tns-core-modules": "2.5.2",
"tns-platform-declarations": "^2.2.0"
},
"devDependencies": {
"nativescript-dev-android-snapshot": "^0.*.*",
"nativescript-dev-typescript": "^0.3.2",
"typescript": "~2.0.10",
"zone.js": "~0.7.2"
}
}
component.ts
import { Component, ElementRef, OnInit, ViewChild } from "@angular/core";
import { Router, NavigationStart, NavigationEnd } from '@angular/router';
import { Page } from "ui/page";
import dialogs = require("ui/dialogs"); //dialog box
import { Configuration } from '../../shared/configuration/configuration';
import { UserProfileService } from '../../shared/services/user-profile.service';
import { AlertService,AuthenticationService } from '../../shared/services/index';
import * as ApplicationSettings from "application-settings";
@Component({
templateUrl: "components/device/device.component.html",
providers: [UserProfileService,AuthenticationService],
})
export class DeviceComponent{
userObj: any;
formObj: any = {};
regstdevices: any = [];
blstdevices: any = [];
constructor(private config: Configuration,private page: Page,private router: Router, private userService: UserProfileService) {
if(ApplicationSettings.hasKey('userInfo')){
this.userObj = JSON.parse(ApplicationSettings.getString('userInfo'));
this.deviceList();
}
}
ngOnInit(){
}
deviceList()
{
this.regstdevices = [];
this.blstdevices = [];
let userId = this.userObj.id;
this.userService.getDeviceDetails(userId).subscribe(
data => {
for(let i=0;i<data.length;i++){
if(data[i].deviceType == "Mobile"){
data[i].status = "res://mobileicon";
}else if(data[i].deviceType == "Web"){
data[i].status = "res://desktopicon";
}
if(data[i].blackList == 0){
this.regstdevices.push(data[i]);
}else if(data[i].blackList == 1){
this.blstdevices.push(data[i]);
}
}
},
error => {
console.log(error);
});
}
deleteDeviceDetail(deviceObj,index){
dialogs.confirm({
title: "Delete Device Detail",
message: "Are you sure you want to delete?",
okButtonText: "Yes",
cancelButtonText: "No"
}).then(result => {
if(result){
this.userService.deleteDeviceDetails(deviceObj).subscribe(
data => {
if(data._body == "success"){
if(deviceObj.blackList == 0){
this.regstdevices.splice(index,1);
}else if(deviceObj.blackList == 1){
this.blstdevices.splice(index,1);
}
}
},
error => {
console.log(error);
});
}
});
}
blockDevice(deviceObj){
dialogs.confirm({
title: "Block Device",
message: "Do you want to block this device?",
okButtonText: "Yes",
cancelButtonText: "No"
}).then(result => {
if(result){
this.userService.blockOrUnBlockDevice(deviceObj).subscribe(
data => {
if(data._body == "success"){
dialogs.confirm({
title: "Block Device",
message: "Device Blocked",
okButtonText: "Ok"
}).then(result => {
this.deviceList();
});
}
},
error => {
console.log(error);
});
}
});
}
retrieveDevice(deviceObj){
dialogs.confirm({
title: "Retrieve Device",
message: "Do you want to add this device?",
okButtonText: "Yes",
cancelButtonText: "No"
}).then(result => {
if(result){
this.userService.blockOrUnBlockDevice(deviceObj).subscribe(
data => {
if(data._body == "success"){
dialogs.confirm({
title: "Retrieve Device",
message: "Added to registered device list",
okButtonText: "Ok"
}).then(result => {
this.deviceList();
});
}
},
error => {
console.log(error);
}
});
}
}
component.html
<GridLayout>
<GridLayout #background
scaleX="1.4"
scaleY="1.4"
class="background"
></GridLayout>
<StackLayout #mainContainer class="appo-colorbg" >
<ActionBar title="" class="dash-head">
<NavigationButton text="" icon="res://backbutton" [nsRouterLink]="['/profile']" pageTransition="slideRight" ></NavigationButton>
<Label class="tit-text1" textWrap ="true" text="My Devices" ></Label>
</ActionBar>
<StackLayout height="100%" >
<TabView>
<StackLayout *tabItem="{title: 'Registered'}">
<StackLayout height="100%" class="norecords" visibility="{{regstdevices.length == 0 ? 'visible' : 'collapsed'}}">
<Label text="No Records Found" class="norecords" ></Label>
</StackLayout>
<StackLayout width="100%" height="100%">
<ListView [items]="regstdevices" width="100%" height="100%">
<template let-item="item" let-i="index" let-odd="odd" let-even="even">
<StackLayout [class.odd]="odd" [class.even]="even">
<GridLayout columns="2*,auto" rows="auto,auto" width="100%" class="device-headtxt">
<Label col="0" textWrap ="true" text="{{item.deviceType}}" class="appo-headtxtname" ></Label>
<Image col="1" src="res://meddelete" stretch ="none" class="appo-delete" (tap)="deleteDeviceDetail(item,i)"></Image>
</GridLayout>
<GridLayout columns="auto,auto" rows="auto,auto" width="100%">
<StackLayout col="0">
<Image src="{{item.status}}" width="70" height="70" ></Image>
<Label col="0" textWrap ="true" text="BLOCK" class="device-regbutton" (tap)="blockDevice(item)"></Label>
</StackLayout>
<StackLayout col="1" class="device-regadd" >
<Label textWrap ="true" text="Device Name" class="spe-text" ></Label>
<Label textWrap ="true" text="{{item.deviceName != null ? item.deviceName : '...'}}" class="device-spe" ></Label>
<Label textWrap ="true" text="Model / IP" class="spe-text" ></Label>
<Label textWrap ="true" text="{{item.deviceType == 'Mobile' ? item.model : item.ipAddress}}" class="device-spe" ></Label>
<Label textWrap ="true" text="Device ID" class="spe-text" visibility="{{item.deviceType == 'Mobile' ? 'visible' : 'collapsed'}}"></Label>
<Label textWrap ="true" text="{{item.deviceId}}" visibility="{{item.deviceType == 'Mobile' ? 'visible' : 'collapsed'}}" class="device-spe" ></Label>
</StackLayout>
</GridLayout>
</StackLayout>
</template>
</ListView>
</StackLayout>
</StackLayout>
<StackLayout *tabItem="{title: 'Black Listed'}">
<StackLayout height="100%" class="norecords" visibility="{{blstdevices.length == 0 ? 'visible' : 'collapsed'}}">
<Label text="No Records Found" class="norecords" ></Label>
</StackLayout>
<StackLayout width="100%" height="100%">
<ListView [items]="blstdevices" width="100%" height="100%">
<template let-item="item" let-i="index" let-odd="odd" let-even="even">
<StackLayout [class.odd]="odd" [class.even]="even">
<GridLayout columns="2*,auto" rows="auto,auto" width="100%" class="device-headtxt">
<Label col="0" textWrap ="true" text="{{item.deviceType}}" class="appo-headtxtname" ></Label>
<Image col="1" src="res://meddelete" stretch ="none" class="appo-delete" (tap)="deleteDeviceDetail(item,i)"></Image>
</GridLayout>
<GridLayout columns="auto,auto" rows="auto,auto" width="100%">
<StackLayout col="0">
<Image src="{{item.status}}" width="70" height="70" ></Image>
<Label col="0" textWrap ="true" text="Retrieve" class="device-regbutton1" (tap)="retrieveDevice(item)"></Label>
</StackLayout>
<StackLayout col="1" class="device-regadd" >
<Label textWrap ="true" text="Device Name" class="spe-text" ></Label>
<Label textWrap ="true" text="{{item.deviceName != null ? item.deviceName : '...'}}" class="device-spe" ></Label>
<Label textWrap ="true" text="Model / IP" class="spe-text" ></Label>
<Label textWrap ="true" text="{{item.deviceType == 'Mobile' ? item.model : item.ipAddress}}" class="device-spe" ></Label>
<Label textWrap ="true" text="Device ID" class="spe-text" visibility="{{item.deviceType == 'Mobile' ? 'visible' : 'collapsed'}}"></Label>
<Label textWrap ="true" text="{{item.deviceId}}" visibility="{{item.deviceType == 'Mobile' ? 'visible' : 'collapsed'}}" class="device-spe" ></Label>
</StackLayout>
</GridLayout>
</StackLayout>
</template>
</ListView>
</StackLayout>
</StackLayout>
</TabView>
</StackLayout>
</StackLayout>
<router-outlet></router-outlet>
</GridLayout>
and UserProfile Service is
deleteDeviceDetails(deviceObj){
let headers = new Headers({ 'Content-Type': 'application/json' });
let options = new RequestOptions({ headers: headers });
let dObj:any = [];
dObj.push(deviceObj)
let body = JSON.stringify(dObj);
return this.http.post(this._apiBaseUrl+"deleteDeviceDetail", body, options).map((data: any) => data);
}
blockOrUnBlockDevice(deviceObj){
let headers = new Headers({ 'Content-Type': 'application/json' });
let options = new RequestOptions({ headers: headers });
let body = JSON.stringify(deviceObj);
return this.http.post(this._apiBaseUrl+"blockOrUnBlockDevice", body, options).map((data: any) => data);
}
here when i try delete or block or unblock device it shows the “Response with status: 200 for URL: null” error at time but device is deleted in db when i goto other page and comeback device list i cant found deleted device.
is there anyone knows the solution please let me know