How to get coordinates in every 1 minute - react-native

I want to get my coordinates in every 1 minute even app close or background. But what ever I did, I couldnt do that. I used background-task but it works minimum in every 7m30s so it doesn't help me.
I used 'react-native-geolocation-service' like this :
this.watchID = Geolocation.watchPosition((lastPosition) => {
this.setState({ initialPosition: lastPosition });
Latitude = lastPosition.coords.latitude;
Longitude = lastPosition.coords.longitude;
var lat = parseFloat(lastPosition.coords.latitude);
var lng = parseFloat(lastPosition.coords.longitude);
console.log("lat2 :",lat);
console.log("lng2 :",lng);
},
(error) => alert(JSON.stringify(error)),
{enableHighAccuracy: true, maximumAge: 0, distanceFilter: 1, useSignificantChanges: true});
to get coordinates when I move in every 1 meter but it keeps continue to give coordinates and never stop. And also it doesnt work when app closed.

Expo SDK v32.0.0 release includes initial support for background location.

Related

rightnow-crm and unavailable hours

we have recently implemented rightnow proactive chat on our website, we have the chat widget set up by our central IT department to work off hours of availability for chat. I've got the widget working to an OK standard using this example
http://cxdeveloper.com/article/proactive-chat-intercepting-chat-events
However, coming from Zendesk I was hoping to replicate the 'out of hours' or 'offline' modes of the Zendesk widget where it changes its behaviour when chat is offline.
After looking around I notice the widget can take a value for 'label_unavailable_hours:' however I cannot work out if this is available to the both the ConditionalChatLink and ProactiveChat modules. Does anyone have any experience with creating such functionality? I've also had a look at trying to pull data using chatAvailability but I am not doing that right either.
If anyone has an insight on how to get some kind of out of hours smarts working or if I am wasting my time try Id love to hear. My code is as below
$(document).ready(function() {
RightNow.Client.Controller.addComponent({
instance_id: "spac_0",
avatar_image: "",
label_question: "A team member is available to help, would you like to start a chat?",
label_avatar_image: "",
label_dialog_header: "",
logo_image: "",
seconds: 2,
enable_polling: "yes",
div_id: "proactiveChatDiv",
module: "ProactiveChat",
//module: "ConditionalChatLink",
min_agents_avail: 0, //remove this when live (when set to 0, no agents have to be free)
min_sessions_avail: 1,
label_unavailable_busy_template: "'All team members are busy. please email is us' + <a href='urlForEmail'>' + 'this place' + '</a>'", //out of hours
label_unavailable_hours: "'Outside of hours' + <a href='urlForEmail'>' + 'this place' + '</a>'",
type: 2
},
"https://ourWidgetCode"
);
//Widget loaded callback - this doesn't seem to work correctly hence the code below
RightNow.Client.Event.evt_widgetLoaded.subscribe(function(event_name, data) {
if (data[0].id == "spac_0") {
//Initialization
console.log('widget loaded');
}
/* this wont work
spac_0.prototype.chatAvailability = spac_0.chatAvailability;
spac_0.chatAvailability = function()
{
console.log(spac_0.chatAvailability);
{}
};*/
//Reset prototype
spac_0.prototype = {};
//Handle Chat Offered
spac_0.prototype.chatOffered = spac_0.chatOffered;
spac_0.chatOffered = function() {
console.log("Chat Offered Handled");
spac_0.prototype.chatOffered.call(this);
//animate the widget to popup from bottom
setTimeout(function() {
$('div.yui-panel-container').addClass('animate');
}, 2000)
//delete the annoying session cookie that only allows the chat to appear once per session by default
RightNow.Client.Util.setCookie("noChat", '', -10, '/', '', '');
};
//if the 'Do not ask again' is selected
spac_0.prototype.chatRefused = spac_0.chatRefused;
spac_0.chatRefused = function () {
console.log("Do not ask again Selected");
spac_0.prototype.chatRefused.call(this);
//Reset the Cookie to be valid only for the session
RightNow.Client.Util.setCookie("noChat",'RNTLIVE',0,'/',true,'');
};
});
});

Forge Data Visualization not working on Revit rooms [ITA]

I followed the tutorials from the Forge Data Visualization extension documentation: https://forge.autodesk.com/en/docs/dataviz/v1/developers_guide/quickstart/ on a Revit file. I used the generateMasterViews option to translate the model and I can see the Rooms on the viewer, however I have problems coloring the surfaces of the floors: it seems that the ModelStructureInfo has no rooms.
The result of the ModelStructureInfo on the viewer.model is:
t {model: d, rooms: null}
Here is my code, I added the ITA localized versions of Rooms as 3rd parameter ("Locali"):
const dataVizExtn = await this.viewer.loadExtension("Autodesk.DataVisualization");
// Model Structure Info
let viewerDocument = this.viewer.model.getDocumentNode().getDocument();
const aecModelData = await viewerDocument.downloadAecModelData();
let levelsExt;
if (aecModelData) {
levelsExt = await viewer.loadExtension("Autodesk.AEC.LevelsExtension", {
doNotCreateUI: true
});
}
// get FloorInfo
const floorData = levelsExt.floorSelector.floorData;
const floor = floorData[2];
levelsExt.floorSelector.selectFloor(floor.index, true);
const model = this.viewer.model;
const structureInfo = new Autodesk.DataVisualization.Core.ModelStructureInfo(model);
let levelRoomsMap = await structureInfo.getLevelRoomsMap();
let rooms = levelRoomsMap.getRoomsOnLevel("2 - P2", false);
// Generates `SurfaceShadingData` after assigning each device to a room (Rooms--> Locali).
const shadingData = await structureInfo.generateSurfaceShadingData(devices, undefined, "Locali");
// Use the resulting shading data to generate heatmap from.
await dataVizExtn.setupSurfaceShading(model, shadingData, {
type: "PlanarHeatmap",
placePosition: "min",
usingSlicing: true,
});
// Register a few color stops for sensor values in range [0.0, 1.0]
const sensorType = "Temperature";
const sensorColors = [0x0000ff, 0x00ff00, 0xffff00, 0xff0000];
dataVizExtn.registerSurfaceShadingColors(sensorType, sensorColors);
// Function that provides a [0,1] value for the planar heatmap
function getSensorValue(surfaceShadingPoint, sensorType, pointData) {
const { x, y } = pointData;
const sensorValue = computeSensorValue(x, y);
return clamp(sensorValue, 0.0, 1.0);
}
const sensorType = "Temperature";
dataVizExtn.renderSurfaceShading(floor.name, sensorType, getSensorValue);
How can I solve this issue? Is there something else to do when using a different localization?
Here is a snapshot of what I get from the console:
Which viewer version you're using? There was an issue causing ModelStructureInfo cannot produce the correct LevelRoomsMap, but it gets fixed now. Please use v7.43.0 and try again. Here is the snapshot of my test:
BTW, if you see t {model: d, rooms: null} while constructing the ModelStructureInfo, it's alright, since the room data will be produced after you called ModelStructureInfo#getLevelRoomsMap or ModelStructureInfo#getRoomList.

Vue.js Nuxt - cannot access Array (value evaluated upon first expanding error)

I have the following function which gives me an array called URLs
const storageRef = this.$fire.storage.ref().child(fileName)
try {
const snapshot = storageRef.put(element).then((snapshot) => {
snapshot.ref.getDownloadURL().then((url) => {
urls.push(url)
})
})
console.log('File uploaded.')
} catch (e) {
console.log(e.message)
}
});
console.log(urls)
console.log("about to run enter time with imageurls length " + urls.length)
When I run console.log(URLs) initially I do see the array like the following
[]
0: "testvalue"
length: 1
__proto__: Array(0)
However, there is a small information icon stating
This value was evaluated upon first expanding. The value may have changed since.
Because of this, when I try to get the length of URLs, I get zero, meaning the value is being updated.
Does anyone know what's happening? I am using Vue.JS/Nuxt.

Cannot get Core Motion Updates using watchOS 5: "[Gyro] Manually set gyro-interrupt-calibration to 800"

I am trying to get Core Motion data from an Apple Watch 3 (WatchOS 5.1) but although the DeviceMotion is available (isDeviceMotionAvailable property is true), the handler is never triggered. I get the following message in the console right after parsing super.willActivate():
[Gyro] Manually set gyro-interrupt-calibration to 800
I am using the following function to get Device Motion updates:
func startQueuedUpdates() {
if motion.isDeviceMotionAvailable {
self.motion.deviceMotionUpdateInterval = 1.0 / 100.0
self.motion.showsDeviceMovementDisplay = true
self.motion.startDeviceMotionUpdates(using: .xMagneticNorthZVertical, to: self.queue, withHandler:{
(data, error) in
// Make sure the data is valid before accessing it.
if let validData = data {
print(String(validData.userAcceleration.x))
}
})
}
}
In the InterfaceController I have declared
let motion = CMMotionManager()
let queue : OperationQueue = OperationQueue.main
Has anyone met this message before and managed to resolve it?
Note: I have checked the isGyroAvailable property and it is false.
The trick here is to match the startDeviceMotionUpdates(using: CMAttitudeReferenceFrame parameter to your device's capabilities. If it has no magnetometer, it cannot relate to magnetic north, and even if it has a magnetometer, it cannot relate to true north unless it knows where you are (i.e. has latitude & longitude). If it hasn't got the capabilities to comply with the parameter you select, the update will be called, but the data will be nil.
If you start it up with the minimum .xArbitraryZVertical you will get updates from the accelerometer, but you won't get a meaningful heading, just a relative one, through the CMDeviceMotion.attitude property ...
if motion.isDeviceMotionAvailable {
print("Motion available")
print(motion.isGyroAvailable ? "Gyro available" : "Gyro NOT available")
print(motion.isAccelerometerAvailable ? "Accel available" : "Accel NOT available")
print(motion.isMagnetometerAvailable ? "Mag available" : "Mag NOT available")
motion.deviceMotionUpdateInterval = 1.0 / 60.0
motion.showsDeviceMovementDisplay = true
motion.startDeviceMotionUpdates(using: .xArbitraryZVertical) // *******
// Configure a timer to fetch the motion data.
self.timer = Timer.scheduledTimer(withTimeInterval: 1, repeats: true) { _ in
if let data = self.motion.deviceMotion {
print(data.attitude.yaw)
}
}
}

Corona SDK error on lines 172 and 218, no filename, only question marks

Corona SDK simulator, version 2013.1137 (2013.6.7) is displaying the following error:
Corona Simulator Runtime error
File: ?
Attempt to perform arithmetic on field '?' (a function value)
stack traceback:
[C]: ?
?: in function <?:172>
?: in function <?:218>
The error is caused by the following code (main.lua):
local d1 = display.newCircle(0, 40, 10)
local gNonEmpty1 = display.newGroup()
gNonEmpty1:insert(display.newCircle(0, 70, 10))
local gEmpty1 = display.newGroup()
transition.to(d1, { time = 1000, x = 100 })
transition.to(gNonEmpty1, { time = 1000, x = 100 })
transition.to(gEmpty1, { time = 1000, x = 100 })
local d2 = display.newCircle(0, 150, 10)
local gNonEmpty2 = display.newGroup()
gNonEmpty2:insert(display.newCircle(0, 180, 10))
local gEmpty2 = display.newGroup()
transition.to(d2, { time = 1000, x = 100, transition = easing.outExpo })
transition.to(gNonEmpty2, { time = 1000, x = 100, transition = easing.outExpo })
transition.to(gEmpty2, { time = 1000, x = 100, transition = easing.outExpo })
local d3 = display.newCircle(0, 260, 10)
local gNonEmpty3 = display.newGroup()
gNonEmpty3:insert(display.newCircle(0, 290, 10))
local gEmpty3 = display.newGroup()
transition.to(d3, { time = 1000, x = 100, easing.outExpo })
transition.to(gNonEmpty3, { time = 1000, x = 100, easing.outExpo })
transition.to(gEmpty3, { time = 1000, x = 100, easing.outExpo })
The actual line causing the error is the second to last one:
transition.to(gNonEmpty3, { time = 1000, x = 100, easing.outExpo })
You can check it out by commenting it.
Corona documentation states that:
You should have at least one DisplayObject inserted into a
Display Group before you change or read any of the properties
of the group (e.g., x, y, setReferencePoint(), etc.).
Hence, it would be legit to expect some weird behavior when using transition.to
on gEmpty1, gEmpty2 or gEmpty3. As expected, the first two blocks of transition.to, for a total of six calls, behave the same, except for the easing
which is the default, easing.linear, for the first three calls, and easing.outExpo for the other three calls.
If you make a mistake in writing the transition.to calls, and you write something similar to the last three transition.to calls, where the transition = part is missing in the specification of the easing function, the surprising thing is that only the one that targets the non-empty group, gNonEmpty3 is responsible for the incomprehensible error message.
Questions
What should you do in Corona SDK when you get an error with no line numbers and no file names, but only question marks?
Why Corona SDK is not able to provide meaningful reporting beside two line numbers, 172 and 218?
Why this error is occurring? My theory is that the transition.to doesn't perform much error checking; if you target an empty group the error in specifying the easing function will go unnoticed; probably this is related with the fact empty groups properties should not be used, so maybe transition.to or its internal update callback finds out that the group is empty and simply returns without doing anything. Instead, for the non-empty group, the missing transition = causes some code to be triggered not necessarily the easing code, and in that code the actual error occurs.
config.lua
application = {
content = {
width = 320,
height = 480,
scale = "letterBox",
fps = 30
}
}
Original Post (obsolete)
I'm having a hard time at tracking down an error in Corona SDK.
The error causes the simulator to show the following message:
Corona Simulator Runtime error
File: ?
Attempt to perform arithmetic on field '?' (a function value)
stack traceback:
[C]: ?
?: in function <?:172>
?: in function <?:218>
How shall I interpret such message? I have no source files with
that many lines, by the way.
I have a file named Button.lua and line 41 seems to be involved
in raising an exception, although it is not raised from that
line. The line is:
button:insert(b1)
I wrapped that line between two prints:
print("Before", button, b1)
button:insert(b1)
print("After")
The following messages are printed in the simulator console:
Corona Simulator[9801:f03] Before table: 0x11daf4aa0 table: 0x1152363a0
Corona Simulator[9801:f03] After
Instead of your line:
transition.to(gNonEmpty3, { time = 1000, x = 100, easing.outExpo })
use :
transition.to(gNonEmpty3, { time = 1000, x = 100, transition = easing.outExpo })
In corona, such error message will occur when you have some wrong syntax or wrong logic. So, check for those issues first. Inserting print between the lines (that you used) is the best solution to find such error lines.
Keep Coding............. :)