Titanium SDK version: 1.6.2
iPhone SDK version: 4.2
I am developing an iOS app in Appcelerator. In this app I am getting all the users facebook friends and send them (all) to my API (built in Rails3). If a user got alot of friends this requests takes a long time and time out sometimes.
How can I alter my code so that I can send the facebook friend ids in "batches"?
This is my code: http://pastie.org/2043126
Thankful for all input!
When you get the response from Facebook, parse it and store the ids in an array.
Loop through the array, pop X ids, and ApiPOST them.
At the end of the onload function for this request, get the next X items until the array is empty.
When the array is empty do the table.setData().
You can also launch multiple xhr requests at the same time using different xhr objects. In one of my Appcelerator apps, I have a pool of 10 xhr requests caching images at the same time.
Related
I'm doing a request on an API that takes a very long time to execute (about 30 seconds to 4 minutes). Getting the user to wait is of course not a good idea, but I'm not sure about the web technologies that could allow to recontact the browser (subscribe) automatically after the request executed.
Any example of code, and pointers to the right techs would be really appreciated. I'm using aws APIs on the backend, and nextjs / redux on the frontend
Thanks
I have come so many articles and videos on integrating expo push notification ,But at the end of every video an expo tokens is retrieved, this token is used to send notifications to a specified device ,Since this is going to be very repetitive when i have alot of devices ,is there a way of getting all tokens and storing then maybe on firebase then with a single click send a notifications to all the devices ?
Maybe loop through the retrieved tokens
I have a node js app in mongodb cloud platform,which will be used for posting 1 million messages to a topic in GCP pubsub.Since the platform is not supporting the npm package #google-cloud/pubsub,we implemented it using the API reference for Pubsub.Upon load testing the app,I can see each message is taking 50 seconds for posting it to the topic.Ideally it should take less than 5 secs.It takes around 30 seconds for the access_token API call and 20 seconds for the message posting API call.Since each message posting is a independent event,we cannot maintain a session to store the access_token and reuse it and API_KEY authentication method is not available for GCP PubSub.Is the API method for gcp pubsub is very slow when compared to using library #google-cloud/pubsub ?.
Can anyone suggest a solution to improve performance of GCP PubSub using APIs
The PubSub client library are greatly optimized in several ways. The first one is the use of gRPC protocol instead of REST API. Then, there is message aggregation before a push to PubSub (500ms of wait by default). Then, there is various async mechanism to parallelize the processing.
So, a huge and great work done by the Client Library teams and hard (or expensive) to reproduce on your side. But you can, the sources are public, you can have a look to the client libraries!
The 30s for the access_token retrieval is too long. Are you sure that you haven't network issue? In any case, this token is valid for 1H. If you can reuse it in your subsequent call you will save a lot of time!
I am working on new project to display an online stock price screen for a user. We already have this in a combination of php, MySQL and AJAX, but it is very slow and lots of requests are generated on the server. So I want to change the technology.
I have the database in MySQL. One process is already updated: the last price of stock in my database. I fetch those records and display them in the screen. After searching Google, I feel I have to use socket.io, node.js and angularjs. After this I am planning the following:
Front End in angular.js
Socket.io with nodes.js
Nodes.js
Restful API call initiated on nodes.js every 10 seconds for page.php. This page will fetch all symbols of market (around 1000) from the MySQL database and send back a json object. (Can I directly call a MySQL query from node.js and received the json object, and will this reduce the php in-between?)
Socket.io emits this query to every client connect on the site.
Then the angular front-end will display only the symbol which is selected by the user and highlight the changes on the screen.
I have the following problems, as I have limited knowledge of the above technologies.
How do I receive the json object from socket.io into angular.js?
How can I make the logic in the angular page to display only the symbol which user selected from a 1000 symbols response and highlight the change price field only?
How will I connect three and server with MySQL or php?
One thing is read for middle ware i can use the expressJS.AS I want my front end in AngularJS how can i fit the express in between Angular and socket.io and node.js
You need to include socket.io client code on your site, and here is a good example how to turn an external library like socket.io into a service http://www.html5rocks.com/en/tutorials/frameworks/angular-websockets/
I think that the best solution here would be to subscribe via socket.io only the element user wants to see i.e. websockets for selected element and pooling every minute or so for other elements to not generate that much of a traffic on sockets
user opens element A
socket.emit('subscribe', {add: 'A'})
then user switch to element B
socket.emit('subscribe', {add: 'B', remove: 'A'})
How does automatic updates work in passbook available in backfield of the pass, how to use webserviceURL key to get update from the server.
in webserviceURL key i have provided remote path from where updated pass can be downloaded, but even after content changed in server, it does not reflects in pass.
This question has been asked so many times, in so many ways, in so many forums; mostly by people that are too lazy to read the manual, or are too inexperienced / incompetent to understand it.
The first paragraph of the Passbook Web Service Reference explains why simply adding a link to an updated pass will not work.
A REST-style web service protocol is used to communicate with your server about changes to passes, and to fetch the latest version of a pass when it has changed. The endpoints always begin with the web service URL, as specified in the pass, followed by the protocol version number. For example, a request for the latest version of the pass of type com.apple.pass.example and serial number ABC123 might look like the following:
The Passbook web service is an integral part of the Passbook eco system. Anyone wishing to issue passes that change their content (either in response to a push message or in response to a user requesting fresh content by pulling down on the back of the pass), needs to implement their own Passbook web service.
This entails building a server capable of responding to the following to authenticated requests from each device that has installed your pass.
There are 5 methods that your web service should respond to:
1. Registering a Device to Receive Push Notifications for a Pass
POST request to https://webServiceURL/v1/devices/deviceLibraryIdentifier/registrations/passTypeIdentifier/serialNumber
2. Getting the Serial Numbers for Passes Associated with a Device
GET request to https://webServiceURL/v1/devices/deviceLibraryIdentifier/registrations/passTypeIdentifier?passesUpdatedSince=tag
3. Getting the Latest Version of a Pass
GET request to https://webServiceURL/v1/passes/passTypeIdentifier/serialNumber
4. Unregistering a Device
DELETE request to https://webServiceURL/v1/devices/deviceLibraryIdentifier/registrations/passTypeIdentifier/serialNumber
5. Logging Errors
POST request to https://webServiceURL/v1/log
In order to have a pass respond to a manual refresh or push request you need to implement at least the first 3 methods. This is because the device will not issue any further requests until it has received a valid response to the registration request.
Furthermore, the web service must be available over https. An unsecured http service can be used for development, but production devices will only recognise a webServiceURL key that begins with https.