The stripe terminal connectiontoken has already been redeemed - xamarin.ios

I'm integrating stripe terminal sdk into our app.
Currently, once the user is connected to the chip reader device, it will be connected for the lifetime of the app activity.
The only way to disconnect it and reconnect to another chip reader device is to kill the app and re-pair with that new device.
So here is my current process:
init the sdk via setTokenProvider, somewhere in the beginning
discover readers
connect to selected reader
Now below is the new process that im trying to implement:
init the sdk via setTokenProvider, somewhere in the beginning
discover readers
connect to selected reader
disconnect current reader
connect to a different reader. This is the part where it threw up the error The stripe terminal connectiontoken has already been redeemed. Please generate a new one using v1/terminal/connection_token
I can generate the new token any time i want, but how do i set it in the sdk? i have tried just calling the setTokenProvider the second time, but that of course crashed the app as it stated in the stripe doc that settokenprovider should only be called once.
So has anyone else ever tried to implement this process of giving the user the option of switching between devices without having to kill the app? any pointer would be appreciated thanks!

Found a solution by reading the doc on stripe's website... i know!
Turns out when we connect to a new device, the sdk calls the fetchconnectiontoken method automatically. So what I needed to do was grab a new token before connecting to the new device.

Related

How do I receive a message in flutter when phone is connected to network?

I'm building a chat application using socket_io_client with flutter and node.js server. Everything works fine but my Question is, How do I receive all the messages when the phone is not connected to a network? Do I have to store these pending messages in the database like a queue and show them to the user when he is back online or is there any other strategy to do so with socket.io?
I solved it.
I have used store package in my node.js. This will store all the users who are online and whenever a user posts any data from my flutter application, I will first check if the receiver is online and then I will emit the data if the user is online or I will store it in the server itself with receiver ID using the same store package. Now when the user is back online I will just check if the user's data list is empty, if not I will start emitting and deleting from the list until the list is empty.

How to keep information synchronized between the cloud and the device

I'm coding a project which needs cloud control device operation, and want to keep information in sync.
The cloud needs to know the state of device, such as when the network is interrupted and when the network is restored.
When the network is restored, the modified information on the cloud is synchronized to device.
anyone got an idea of how my approach should be like? any tips?
I intend to add resident programs in the background at both ends to determine, but in fact, it is impossible for the cloud in the project to connect only one device, and multiple apps may run in one device, which is very tedious to do. Is there any simple component to realize this function?
I wish control information and data information to be synchronized on the cloud and device
Based on your tag, I'm assuming that you are using MQTT as a messaging protocol for your system. If so, to address your need for tracking the device-cloud connection state, MQTT specifies a feature called "Last Will and Testament".
From the MQTT 3.1.1 Standard Section 3.1.2.5:
If the Will Flag is set to 1 this indicates that, if the Connect request is accepted, a Will Message MUST be stored on the Server and associated with the Network Connection. The Will Message MUST be published when the Network Connection is subsequently closed unless the Will Message has been deleted by the Server on receipt of a DISCONNECT Packet [MQTT-3.1.2-8].
This can be leveraged to let the remote MQTT client on the cloud know when the device is connected and when it disconnects by publishing an online payload to a topic (for example) device/conn_status after a successful connection, and registering a Last Will offline message to the same topic. Now, whenever the device client goes offline, the broker will publish the offline payload on his behalf to the cloud client that can now act accordingly.

TokBox one-to-one Text & Video Chat - Android

As per our client need in mobile application the Publisher needs to initiate the session and show the text chat first and same as when a Subscriber joins the session, he starts with the text chat. If the subscriber wants to start & join video chat, he can ask the publisher and starts the video chat once publisher accepts & started.
Now the issue is if the Publisher initiates the session & press home button. App does not gets internet service, due to this the session disconnects after few auto reconnecting try outs.
So we planned to re-initiate the same session with same session id & token, once the Publisher resumes the app.
In this latest sample app (https://github.com/opentok/accelerator-sample-apps-android) we could not able to re-initiate the session. But in the previous example with the following package compile 'com.opentok.android:accelerator-pack:+' we can achieve connecting to session, But the text chat session is not connecting.
Please guide me. Thanks in advance.
Push HOME button should not cut internet connection. Actually, normal behaviour is to keep audio streaming so you have to mute it on onPause()
If you are suffering disconnections for any reason and you can't solve it, you should not try to reuse a session. It is recommended to create a new one.

How to disconnect FireBase sockets?

I am using firebase in NodeJs for getting motion detection events from Nest Camera.
I am connecting using the following code as I need multiple socket connections for each nest user.
this.context = new Firebase.Context();
this.firebaseClient = new Firebase(config.nest.firebaseSocketUrl, this.context);
I want to disconnect a particular socket whenever a user changes its mode to standby or home.
As per firebase documentation, you can use Firebase.goOffline() which is not useful in my case. How can I disconnect a specific firebase socket?
Firebase Engineer here,
I've answered a similar question regarding how Nest and Firebase interact here, but I'll provide a little more color on how you can get data from multiple Nest devices on a single client.
In short, Nest stores data in a structure that looks like:
users
$userID
devices
$deviceID
// info about devices
When you call authWithCustomToken(), you're taken down to the appropriate $userID, and can subscribe to changes on those users' devices. This means you can't really access data across multiple users' devices since by authenticating you "move down the tree" to that user data. There's no way to move up (typically you could call parent(), but this doesn't work in Nest Firebase land).
Since a Firebase realtime database connection takes a single auth token per conncetion, you would have to auth() and unauth() multiple times to do this (going offline and online doesn't really do it, as we'll continue to use the same connection), and I highly suggest you avoid doing this, as it won't scale well.
Instead, you should use the streaming REST API, which allows you to create streaming REST connections, each authenticated with the user token. You can also control when these connections are open/closed. It's a little more work to manage, but if you're aiming for granular control, this is the level of control you're looking for. Some examples are here.
We're working with Nest to create a better experience here, but for now this is what we both recommend.

Sending SMS using Java ME application

I want to a Java ME application that transfers any SMS received to a PC using bluetooth. The PC can then direct the Java ME application via bluetooth to send a response SMS. Is there library available for this architecture or I have to design it myself?
Is this approach correct or a better one exists? I want to use bluetooth as then I will not have dependency on the cable.
You'll need to create this yourself, however you'll find that you can't do what you want with J2ME.
J2ME can't access any old SMS that the handset receives, only ones sent to a specific port upon which the MIDlet is listening. So to get all the other SMSes, create a bluetooth serial/dial-up connection to your handset in the way I've described in this answer.
Create a PC client which repeatedly issues AT+CGML commands (as described in the AT command set document linked to in the answer above), to see when an SMS has been received. Use AT+CGMR to read and parse the message text. Then use AT+CGMS to sent a response. This can all be done over bluetooth.
It's better to use the serial connection to send a response, because a MIDlet cannot usually be triggered to open based on incoming bluetooth data.
Hope this helps.
You may have already achieved your task, anyway for the reference I think it is much better if you try using Gammu . I'm using it for the same task (Send / receive SMS through PC ) with a simple bat file I have written, works like a charm.
Anyway you don't need any J2me program for this.
Wammu takes care of making the connection to phone and sending AT commands.

Resources