QuickFIX/J - how to stop Initiator automatic logon - quickfixj

We have implemented initiator , web bases where user login by entering the session ID details like beginstring, compid,targetcompid.
Now, we are facing scenario where, first time, due to some reason,it got disconnecting message.
But after some time, it will automatically logon. And appear suddenly as connected in users table.
So how can we stop that ?
We want that, once he got disconnected message ,for him it should be disconnected only until he enters the details again ?

To prevent automatic logon of Initiator you could use one of these ways:
Call logout() on the session. This will set the session to disabled which will prevent reconnection. If it is OK to relogin, call logon().
Implement ApplicationExtended.canLogon() and return false. If it is OK to relogin, return true.

Related

QuickFIX/J - how to handle End Of Stream

I am new to QuickFIX/J.
Creating initiator using websocket(frontend-angular, backend-Springboot websocket). Using w.3.
I would like to handle session expired issue. When the FIX server session is expired, it is sending Logout with reason session deactivated. That works fine for already connected connection/session.
Now, after this, trying to initiate connection, it keeps calling back logout and toAdmin with repeating event/error on screen log (as event) "Disconnecting, End Of Stream encountered".
I would like to handle this scenario and want to capture this in my code so that proper message to UI will be sent.
I don't know which QuickFIX/J version you are using, but on versions up to 2.2.0 you could implement the quickfix.SessionStateListener in your application and utilize its onDisconnect() callback.
If you are even using version 2.3.0 you could also use onConnectException() which will handle some additional scenarios that the first callback does not cover.

App Tracking Transparency reset after user choice

I've just implemented the ATT request in my applications. It appears at the app first opening but I would like to show it again if the user wants to change his preferences from the app settings (internal).
I tried to call the requestTrackingAuthorization method again but it enters immediately to the completion handler. Is there a way to reset the status?

Firebase - clear cached subscriptions after .delete()

When a user logs out, I do:
FIRInstanceID.instanceID().delete(handler: { (error) in })
Which should (?) invalidate the token and unsubscribe from all topics.
It works, but logging in with the same device and calling FIRInstanceID.instanceID().token() (from notification when it's ready), I get the same token (not really a problem, but unexpected). However; subscribing to topics (upon login for instance) seems to be cached in the device from the previous login, so it doesn't make a network call, meaning the token will not be associated with any topics on the FCM side. Assume it's the same user doing a relog; the topics he/she wants to subscribe to are the same as before delete().
I can verify this by querying https://iid.googleapis.com/iid/info/<token> with the token: Even after calling subscribeToTopic in my app, the list of topics remains empty. Normally this call results in the -5 error (described here https://github.com/firebase/quickstart-ios/issues/146) when subscribing to multiple topics, but nothing happens, indicating to me that the application thinks it's already subscribed to the topics and hence does nothing.
So - how can I unsubscribe from all topics upon logout, and successfully resubscribe when logging in? Looping the topics and doing unsubscribeFromTopic seems a little hacky to me.
Instead you can disconnect the user from getting push notifications by doing FiRMessaging.messaging.disconnect()
And connect the user when he logs back in

What is the equivalent of iOS applicationWillTerminate in IBM MobileFirst Hybrid app?

Scenario:
I want to call the logout function if the app is terminated. I'm able to do it using native code:
- (void)applicationWillTerminate:(UIApplication *)app
{
// Run Logout function
}
Problem:
How to do it in IBM mobilefirst hybrid app?
// ************************************************
Edited
First of all, user login in to the app, if the user key in the correct user id and password, it will add the userIdentity into "loginRealm".
WL.Server.setActiveUser("loginRealm", userIdentity);
Next, user closes the apps without logout. So, when the user login for the another time, MFP server will not return any feedback since it will hit this exception:
Cannot change identity of an already logged in user in realm
'loginRealm'. The application must logout first.
Hence, I have to logout the user from MFP server by setting the "loginRealm" to null in adapter;
WL.Server.setActiveUser("loginRealm", null);
The above line of code is in the logout function defined in authentication-config.xml.
The client side device runs this line of code and it will trigger the logout function. Besides, it will reload the App upon success:
WL.Client.logout('loginRealm', {
onSuccess: WL.Client.reloadApp
});
Steps that I've tried:
1) At WlcommonInit() I added WL.Client.updateUserInfo(); and if WL.Client.isUserAuthenticated("loginRealm") return true I will logout the user from server. However, WL.Client.isUserAuthenticated("loginRealm") will always return false. This is because, it needs to take sometime around (30seconds to 2 minutes) for the flag to turn true after WL.Client.updateUserInfo();. So my login still fail and hit the same error.
2) I tried to logout the users during the user click login button. But the app will refresh and return to login page again due to reloadApp. The logout code I get from IBM mobilefirst website. So user need to click and type 2 times in order to login into the main menu.
WL.Client.logout('loginRealm', {
onSuccess: WL.Client.reloadApp
});
Am I doing it wrongly? Or are there any other methods to get WL.Client.isUserAuthenticated("loginRealm") return true instantly after WL.Client.updateUserInfo(); ? Can we remove the reload app line of code in logout function?
I don't think this is doable, because that logout function (in MFP) will require server connectivity (request and response) and if the app is by then killed, I think it's going to cause unpredictable results.
Note though that it seems to be not recommended to use that function anyway? applicationWillTerminate when is it called and when not
What you should do perhaps in order to simulate it, is to logout-on-login, so that it would appear that the app is logged out when opening it. You can extend the duration of the splash screen so that the end-user will not see that s/he is logged in (in case the session was still alive between the closing and re-opening of the app), until really logged out and then you can display the login screen again or any other required screen.

What is the proper way to handle FBSessionStateClosedLoginFailed with iOS FB SDK 3.1.1

When my app needs to e.g. read from a user's facebook, it checks the current state the active FBSession. For the e.g. FBSessionStateOpen, it knows it can just request the information from Facebook, whereas for FBSessionStateCreatedTokenLoaded it must call openWithCompletionHandler. What FBSession method should be called if the current state is FBSessionStateClosedLoginFailed?
That means that a login attempt failed. When this happens for me I - closeAndClearTokenInformation and alert the user that login failed and ask him if he wants to login again.
In short:
In Facebook sample
https://developers.facebook.com/docs/tutorials/ios-sdk-tutorial/
When such condition occurred, their sample code will call a loginViewController or equivalent.
This is their comments when falling into this condition.
"if the token goes invalid we want to switch right back to the login view, however we do it with a slight delay in order to account for a race between this and the login view dissappearing a moment before "
P.S. I fixed this error my solving Facebook open graph setups and study more on the Scrumptious example such as "return [FBSession.activeSession handleOpenURL:url];" and "[FBSession.activeSession handleDidBecomeActive];"
In long:
This is taken from official FB doc.
http://developers.facebook.com/docs/reference/ios/3.1/class/FBSession#FBSessionState+enum
Given this is the precondition and it has passed other enum states and not a connection error:
"FBSessionStateClosedLoginFailed
Closed session state indicating that a login attempt failed"
It didn't explicitly said the problem. It may be the cached misinformation. Personally and most carefully, I would call '- (void)closeAndClearTokenInformation;", this method would clean up every cache info and show a error message such as "invalid login, please try again" to the client/user.
Then, allow the client the options to do a clean slate login again or skip this process if possible.
HTH

Resources