Updating location data into the server is not working using background geo locaion in ionic 3 - ionic2

I am using https://github.com/mauron85/cordova-plugin-background-geolocation. It gives location details in the foreground and gives debug messages when the app is closed but it does not update the location details into the server both foreground and background.
Thanks in advance
const config: BackgroundGeolocationConfig = {
desiredAccuracy: 10,
stationaryRadius: 10,
distanceFilter: 10,
debug: false,
stopOnTerminate: false,
startForeground: true,
notificationTitle: 'location tracking',
notificationText: 'Active',
interval: 60000,
url: localStorage.getItem('api_base_url')+'user/currentlocation',
syncUrl:localStorage.getItem('api_base_url')+'user/currentlocation',
httpHeaders: {
'Content-Type': 'application/json'
},
postTemplate: {
lat: '#latitude',
lon: '#longitude',
user_id: '1',
currentDate: '12-12-2019',
address: 'test',
}
};
this.backgroundGeolocation.configure(config)
.then(() => {
this.backgroundGeolocation.on(BackgroundGeolocationEvents.location).subscribe((location: BackgroundGeolocationResponse) => {
console.log(location);
});
});
this.backgroundGeolocation.start();

Background geo location post template
Keep in mind that all locations (even a single one) will be sent as an array of object(s), when postTemplate is jsonObject and array of array(s) for jsonArray!
In server-side, I changed the JSON object to an array of object.
For example,
{
"user_id": "1",
"lon": "13.2",
"lat": "82.3"
}
I changed the above JSON object to following
[{
"user_id": "1",
"lon": "13.2",
"lat": "82.3"
}]

Related

Google Cloud Tasks not executing tasks randomly

Google Cloud Tasks seems to be unreliable some times. I've added a bunch of tasks and sometimes those are not getting executed.
When I checked the console, it shows '11 Tasks in Queue'. However, those tasks are not listed below (usually it shows correctly).
Here is how I've created the queue (upsert):
const client = require('./client');
module.exports = async (queue_name, concurrent) => {
return client.updateQueue({
queue: {
name: client.queuePath(
process.env.GCP_PROJECT,
process.env.GCP_QUEUE_LOCATION,
queue_name,
),
rateLimits: {
maxConcurrentDispatches: concurrent,
maxDispatchesPerSecond: concurrent,
maxBurstSize: 100,
},
retryConfig: {
maxAttempts: 3,
unlimitedAttempts: false,
maxRetryDuration: {
seconds: 3600,
},
minBackoff: {
seconds: 60,
},
maxBackoff: {
seconds: 300,
},
maxDoublings: 3,
},
},
});
};
and here is how I'm adding tasks:
const client = require('./client');
module.exports = async (queue_name, url, config) => {
return client.createTask({
parent: client.queuePath(
process.env.GCP_PROJECT,
process.env.GCP_QUEUE_LOCATION,
queue_name,
),
task: {
httpRequest: {
httpMethod: 'POST',
headers: {
'Content-Type': 'application/json',
},
url: `${process.env.OPTIMIZER_URL}/optimize-page`,
body: Buffer.from(JSON.stringify({ url, config })).toString(
'base64',
),
},
},
});
};
The same code works sometimes and sometimes it just got stuck at executing!

How can I see my response from server in Ember.js

My code is quite simple (Client Side):
Record.Router.map(function () {
this.resource('main', { path: '/' });
});
Record.MainRoute = Ember.Route.extend({
model: function () {
var response = Record.Rank.find();
console.log(response.get('name'));
console.log(response);
return Record.Rank.find();
}
});
My model:
Record.Rank = DS.Model.extend({
id: DS.attr('integer'),
rank: DS.attr('integer'),
content: DS.attr('string')
});
I use RESTadapter:
Record.Store = DS.Store.extend({
revision: 12,
adapter: DS.RESTAdapter.reopen({
namespace: 'recordApp'
})
});
My Server side code (PHP):
<?php
namespace RecordContainer;
echo '{"rank":
{
"id": "1",
"rank": "2",
"content": "walla"
}
}';
I expect to something after I issue Record.Rank.find() but my console.log(response.get('name')) logs undefined and the second console.log(response) show the following, no information about echo from server inside:
How do I see the response from the server, in Ember?
1st: Calling find on a DS.Model without any parameters, i.e. Record.Rank.find(), is equivalent to sending a findAll() request to your server. In other words, it should fetch all Record.Rank. Therefore ember-data expects an array in the response of the format:
{
"ranks":[
{
"id": "1",
"rank": "2",
"content": "walla"
},
{
"id": "2",
"rank": "5",
"content": "foo"
}
]
}
2nd: Even if the response from the PHP was correct (as described above), console.log(response.get('name')); would probably return undefined since the request is not yet completed and the record(s) are not available. If you really want to access the records loaded into the store you need to place your code into a Promise resolve callback:
Record.MainRoute = Ember.Route.extend({
model: function () {
var response = Record.Rank.find();
response.then(function(ranks) {
console.log(ranks.getEach('name'));
});
return response;
}
});

extjs 4.1 pagingtoolbar displays correctly but grid loads all records

Okay, so I've been at this all day and can't figure out why the grid is loading all records instead of the pageSize: 25 limit I configured on the store. The paging toolbar is rendering the correct pages, but the grid is what is autoloading all records. I'm thinking it is because of the way my controller is loading the view. I have my .cfc server side processing setup correctly using the paging_on, start, limit, sort and dir in my arguments. If anyone can help me out, it would be greatly appreciated.
Here is my controller:
onAccountActivityListAfterrender: function(pnl, eOpts) {
var store = this.getStore("AccountSessions");
store.load({
params : {
start : 0,
limit : 25
},
callback: function (recs, op, success) {
if (!success) {
Ext.Msg.alert("Error!", op.error[0].ERROR);
}
var grid = Ext.getCmp('pnl-accountactivity-list');
grid.getStore().add(store.getRange());
this.showApp(pnl);
},
scope: this
});
},
and here is my store:
Ext.define("EXAMPLE.store.AccountSessions", {
alias: "store.AccountSessions",
extend: "Ext.data.Store",
model: "EXAMPLE.model.AccountSession",
pageSize: 25,
proxy: {
api: {
create : undefined,
read : "ajax/account.cfc?method=account_sessions",
update : undefined,
destroy : undefined
},
extraParams: {
account_id: account
},
reader: {
messageProperty: "ERRORS",
root: "DATA",
successProperty: "SUCCESS",
totalProperty: "TOTAL",
type: "json"
},
type: "ajax"
}
});
You'd better to show the server-side codes.
Make sure the values that returned correctly~

how to reset cookie when click function works in extjs4

I have a grid which includes a store. In order to pass variable to store. I used cookies but Everytime I click the one data of the grid. the value of cookie equals to first clicked value so it does not change after setting firstly.
gridside in there: I try to set cookie when data is clicked.(by using setcookie). I tried to deleteCookie then declaring the rec_dosya as Global value but they don't work.How can i solve it thanks
var fileGrid_yp_is = new Ext.grid.GridPanel({
contextMenu: new Ext.menu.Menu({
items: [
{
id: 'Kullanici_yetki_id',
text: 'Izin verilen Kullanici Listelesi',
iconCls:'icon-grid-del',
listeners : {
click : function(){
rec_dosya = fileGrid_yp_is.getSelectionModel().getSelected();
rec_dosya=rec_dosya.data.id;
alert(rec_dosya);
deleteCookie('icerik_id');
setCookie('icerik_id',rec_dosya,365);
// alert(rec_dosya);
//usersListWin.extraP = { a:11231231, b: 1, c: 2}; // Add additional stuff
user_store.reload();
usersListWin.show();
}
}
},
]
}),
listeners: {
celldblclick : function(gridim,rIndex,cIndex,e) {
rec_dosya = fileGrid_yp_is.getSelectionModel().getSelected();
deleteCookie('icerik_id');
setCookie('icerik_id',rec_dosya,365);
this.contextMenu.showAt(e.getXY());
}
},
store: fileStore_yp_is,
sm: new Ext.grid.RowSelectionModel({
singleSelect:true
}),
trackMouseOver: true,
frame:false,
width:'auto',
height:'auto',
autoScroll : true,
tbar:tbarim
});
In store side,
I try to get data by using getcookie in baseparams(icerik_id)
var user_store = new Ext.data.JsonStore({
root: 'rows',
autoLoad: true,
model: 'users',
totalProperty: 'results',
remoteSort: true,
proxy: new Ext.data.HttpProxy({
url: 'phps/kullanici_islemleri.php',
method:'POST'
}),
baseParams:{
action:'yetki',
icerik_id:getCookie('icerik_id')
},
fields: [{
name :'id'
},{
name :'icerik_id'
},{
name:'username'
},{
name:'rol'
},{
name:'gorme'
},{
name:'olusturma'
},{
name:'silme'
}
]
});
Use state manager with cookie provider

ExtJS 4.1.0 proxy returns update api instead of create

I was working on a code which was about integrating ExtJS 4 and Django. The link is:
https://github.com/diegocmsantos/extjs4-tdc2011-django
It works fine on ExtJS 4.0.0. But when I upgrade to 4.1.0 it's proxy returns update api instead of create.
I have added the 'idProperty' parameter to the Model, but still gives me the same result.
Model class:
Ext.define('TDC2011.model.Contact', {
extend: 'Ext.data.Model',
idProperty: 'id',
fields : [
{ name : "id", type : "int", mapping : "#id" },
{ name : "name", type : "string"},
{ name : "phone", type : "string"},
{ name : "email", type : "string"}]
});
Store Class:
Ext.define('TDC2011.store.Contacts', {
extend: 'Ext.data.Store',
model: 'TDC2011.model.Contact',
autoLoad: true,
pageSize: 35,
autoLoad: {start: 0, limit: 35},
proxy: {
type: 'ajax',
api: {
read : 'contact/view.action',
create : 'contact/create.action/',
update: 'contact/update.action/',
destroy: 'contact/delete.action/'
},
reader: {
type: 'json',
root: 'data',
successProperty: 'success'
},
writer: {
type: 'json',
writeAllFields: true,
encode: false,
root: 'data'
},
listeners: {
exception: function(proxy, response, operation){
Ext.MessageBox.show({
title: 'REMOTE EXCEPTION',
msg: operation.getError(),
icon: Ext.MessageBox.ERROR,
buttons: Ext.Msg.OK
});
}
}
}
});
Is there anyone who knows the main cause of problem?