What can make a functionality run a simulator and not on the device? - react-native

I'm building an app using React Native.
I'm fetching an array of values fetched from a database in order to provide users a line chart which refresh every X seconds ( 3s atm ).
This works fine on iOS simulator but when it comes to deploy to TestFlight, and run the app on a device, the curves are not displayed, nothing happens.
Since I can use some other feature that requires to fetch data from the DB, I figured out that the issue was not from the API requests.
I currently use react-native-chart-kit, but I tried with react-native-svg-charts as well, the issue remains the same.
Any hint ?
The issue is the same when I display the array of the fetched values, a new value appears on the simulator every 3 seconds but it does not show anything on the device.

I finally found the issue.
The issue were spotted at the API request.
My request takes 2 timestamp params : start time / end time
I always debug the app using the browser and launch ios sim from the RN project.
This time I tried to Run a the project from Xcode and edit the Scheme as release instead of debug .
When I checked the console from Xcode I noticed that my Start time timestamp when considered as 'NaN'.. Not the End time timestamp.
Back to the RN project and to the browser console, the timestamp is alright.
I made some random changes and now it works fine .
Here's what I had before solving the issue:
function formatDate(rawStamp) {
const now = new Date(rawStamp);
var convertToStr =
now.getFullYear() +
"-" +
("00" + (now.getMonth() + 1)).slice(-2) +
"-" +
("00" + now.getDate()).slice(-2) +
" " +
("00" + now.getHours()).slice(-2) +
":" +
("00" + now.getMinutes()).slice(-2) +
":" +
("00" + now.getSeconds()).slice(-2);
return convertToStr
}
const nowStr = formatDate(Date.now() - 7200000)
const gameStampMinusX = Date.parse(nowStr) - (300000)
const gameStampMinusXToStr = formatDate(gameStampMinusX)
Here's what solved the issue:
const nowStr = formatDate(Date.now() - 7200000)
const gameStampMinusX = Date.now() - 7200000 - 300000
const gameStampMinusXToStr = formatDate(gameStampMinusX)
I'm a newbie so I cannot explain this behavior, but seems that this little change makes Xcode recognize the timestamp, and proceed the the API request correctly.
If anyone can explain, feel free !

Related

Optimised Math functions for React Native

The execution time of this function is in milliseconds and sometimes in even seconds. It goes upto 3 seconds on my watch. I was wondering for optimised library to address this issue.
export function calculate_angle(v1, v0, v2){
var x1 = v1[0] - v0[0];
var x2 = v2[0] - v0[0];
var y1 = v1[1] - v0[1];
var y2 = v2[1] - v0[1];
var dot_product = x1*x2 + y1*y2;
var cross_product = Math.sqrt((x1*x1+ y1*y1) * (x2*x2 + y2*y2));
return Math.acos(dot_product/cross_product);
}
It looks like you're trying to do some heavy calculations client side. If you have a server your application communicates with I would recommend sending those calculations to the server.
React Native is not optimised to carry out such compute heavy tasks. If you can't run those calculations on a server I would look to try and get "closer to the metal", i.e. create a native module that you can run those queries in, and only use React Native for the UI.
Or if it's an option you could consider Flutter. Flutter is compiled into the native ARM code for both Android and iOS, unlike React Native which runs a lot of it's "logic" in the Javascript engine.

Youtrack Workflow - Notify a group in a workflow

I am trying to create a workflow for my project in Youtrack that will notify all members of a UserGroup when the state is set to an appropriate value - for example notify all members of the QA group when a task is set to Ready For QA.
Here is the code I have, taken from a larger state machine workflow:
on Approve do {
{group: Quality Assurance}.notifyAllUsers("Task Ready for QA", "A task has been marked as Ready For QA: " + getId());
Alpha Tested By = loggedInUser;
} transit to Ready For QA
Setting the Alpha Tested By values works, everything else works but the group notify. In the editor, the group notify line is highlighted in red, but there is no information about what the problem is. The group name is correct. I copied the syntax directly from the documentation here: https://www.jetbrains.com/help/youtrack/incloud/7.0/Workflow-Language-Grammar.html#literals
I am using the v7.0 InCloud hosted version of YouTrack.
I guess you use the "YouTrack Workflow Editor". Inserting is a bit nasty, copy-paste usually won't work.
Just navigate your mouse to the position you want to insert and hit ctrl + space (autocomplete). Start typing "{group" and you'll get the suggestion for {group: }.
Use again ctrl + space to get the right group-name. After group add the dot "." and once again ctrl + space to add the notifyAllUsers function.
This is my workflow which added issues moved to state "QA" onto a agile board for QA and sends notification to all users in group QA:
whenState.becomes({QA}) {
sprints.add({QA Board.First sprint});
{group:QA}.notifyAllUsers("New Task in QA: " + getId( ) + " " + summary, "Please check your QA board or open this task: " + getUrl( ));
}

Automatic download of created file in Sencha Touch 2

My Sencha Touch 2 application has an 'Export' button, which creates an Excel file with the data of the selected offer.
After the user clicks the button, i want the (server side) export process to be started, and, once completed, the user to be prompted to select a filename and location, OR that the file is automatically downloaded. How do i do that? Does anyone have an example?
For Excel specifically I'm not 100% sure, but this might help you get started or if a CSV is acceptable...
I'm sure you could pass the file reference to a var instead of the string but I have yet to try it.
If you paste the js below into the console you can see how this works. Pretty basic. Maybe try the returned value from the server to see if that works then if it does you can build a function around it to happen when needed.
csvHeading = 'HA, HB, HC, HD \n';
csvData = 'r3a, r3b, r3c, r3d \n' +
'r2a, r2b, r2c, r2d';
CSVFile = csvHeading + csvData;
window.location = 'data:text/csv;charset=utf8,' + encodeURIComponent(CSVFile);

Application name is not set. Call Builder#setApplicationName. error

Application: Connecting to BigQuery using BigQuery APIs for Java
Environment: Eclipse, Windows 7
My application was running fine until last night. I've made no changes (except for restarting my computer) and my code is suddenly giving me this error:
Application name is not set. Call Builder#setApplicationName.
Thankfully I had a tar'd version of my workspace from last night. I ran a folder compare and found the local_db.bin file was different. I deleted the existing local_db.bin file and tried to run the program again. And it worked fine!
Any idea why this might have happened?
Hopefully this will help anyone else who stumbles upon this issue.
Try this to set your application name
Drive service = new Drive.Builder(httpTransport, jsonFactory, null)
.setHttpRequestInitializer(credential)
.setApplicationName("Your app name")
.build();
If you are working with only Firebase Dynamic Links without Android or iOS app
Try this.
builder.setApplicationName(firebaseUtil.getApplicationName());
FirebaseUtil is custom class add keys and application name to this class
FirebaseDynamicLinks.Builder builder = new FirebaseDynamicLinks.Builder(
GoogleNetHttpTransport.newTrustedTransport(), JacksonFactory.getDefaultInstance(), null);
// initialize with api key
FirebaseDynamicLinksRequestInitializer firebaseDynamicLinksRequestInitializer = new FirebaseDynamicLinksRequestInitializer(
firebaseUtil.getFirebaseApiKey());
builder.setFirebaseDynamicLinksRequestInitializer(firebaseDynamicLinksRequestInitializer);
builder.setApplicationName(firebaseUtil.getApplicationName());
// build dynamic links
FirebaseDynamicLinks firebasedynamiclinks = builder.build();
// create Firebase Dynamic Links request
CreateShortDynamicLinkRequest createShortLinkRequest = new CreateShortDynamicLinkRequest();
createShortLinkRequest.setLongDynamicLink(firebaseUtil.getFirebaseUrlPrefix() + "?link=" + urlToShorten);
Suffix suffix = new Suffix();
suffix.setOption(firebaseUtil.getShortSuffixOption());
createShortLinkRequest.setSuffix(suffix);
// request short url
FirebaseDynamicLinks.ShortLinks.Create request = firebasedynamiclinks.shortLinks()
.create(createShortLinkRequest);
CreateShortDynamicLinkResponse createShortDynamicLinkResponse = request.execute();

Live Tile Notification Not Showing

Hi I've been working at this for a while without success. I'm trying to send a simple notification to the live tile for my Native Windows 8 game. To get used to it I tried to use the example mentioned in the docs:
var expiryTime;
expiryTime = date_current_datetime();
expiryTime = date_inc_minute(expiryTime, 5);
win8_livetile_notification_begin("TileSquarePeekImageAndText01");
win8_livetile_notification_expiry(expiryTime);
win8_livetile_notification_tag("tag0");
win8_livetile_notification_text_add("Current Score = " + score);
win8_livetile_notification_image_add("ms-appx:///" + working_directory + "ScoreTile.png");
win8_livetile_notification_end();
Now this code crashes my app. Can someone tell me how to post a tile notification and where we should put the images. Right now I have the images inside of the Included Files folder.
score is a real value, not a string, so you must write:
win8_livetile_notification_text_add("Current Score = " + string(score));
There's no typecasting in GameMaker and never was.