on 05-15-2013 6:12 PM
Hi All,
I got stuck somewhere where we are creating operations in offline mode.
scenario: I have create customer screen with few input parameters like name and address:
Now where i am confused is if user create 4 customers in offline mode, how to manage to update all 4 customers to SAP.
I know there is surrogate key which generate unique number, but i am confused here how to handle this.
Another thing, when i got my connectivity back do i need to call method onConnectSuccess.
Waiting for suggestions.
Regards
Saket
Dear Saket,
To create the customer in offline mode simply call the create operation on your MBO which is mapped with RFC to create customer at Backend... Also you need to put the operation in submitPending state.
if you are creating the customer 4 times then for every time your operation goes into the submitPending state NOw when your app come to online state do the synchronization.. (hope ur using onDemand policy)
At the back end, RFC will get call four times and it will create a 4 new customer that you have created in offline mode.
Kind Regards,
Amey
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Saket,
When you say "login to the app" this can mean a few things:
1) If you are talking about creating your data before going online then is correct and you must do an online sync first.
2) If you are talking about allowing a user that has previously synchronised to then create data while offline then that should be no problem - there are methods in the API that allow for you to logon to the on-device database in an offline fashion and allow you to create and prepare data for sending back to the server.
3) If you are talking about securing your app on the device - I.e. protect the data with a passcode or something along those lines, then you need to look at the SUPDataVault which is a secure store that uses 256bit AES encryption to protect certain data. So for example, when the user first sets up the app you could store their credentials into the data vault and then everytime they launch the app - prompt for the data vault passcode in order to retrieve the credentials to use the application.
On a final note, you should never be calling the on****Success or on******Failure methods directly. They are called ONLY by the SUP libraries in order to let you know that the state of the application has changed.
Hope that helps a bit,
Brenton.
Dear Saket,
Whatever Jitendra and Brenton are saying is the available way to use the application in offline mode.
Also, to use application in offline mode user had to have a one successful login when he/she was in online mode. SUP API provide a capability to allow user to login with the last successful login credentials when he was not in online mode.
Kind Regards,
-Amey
Hi Brenton,
I am talking about point 2, where user has already synched and trying to access app in offline mode and want to create data in offline mode,
if you can suggest any API which will allow user to login in offline mode and synch the data which were created offline mode, that will be great help.
Regards
Saket
Ahh OK excellent - this is not complicated at all so. When re-opening the application all you need to do is set all the connection profile and sync profiles up as you would normally, make sure you set any database encryption keys that you might have set on the database and make sure you are calling the correct method to start the underlying application (even though you are offline and will not be able to connect you need to do this).
I'm sure you have this anyway but make sure you allow for the reconnect scenario by calling startConnection rather than registerApplication:
if ([self.application registrationStatus] != SUPRegistrationStatus_REGISTERED) {
[self.application registerApplication:60];
}
else {
[SUPApplication startConnection:0];
}
Let me know if I've missed the mark on this answer or if you want me to go into more detail in a specific area.
Cheers,
Brenton.
Hello Saket,
When you register your application using registerApplication method, and if your registration is successful, then next time even if you dont have network and still you try to login then it will allow you to login, if your previous application registration is successful then your application simply start the connection.
Prior to 2.1.3 there is a method offLineLogin() which takes username and password as an argument but in 2.1.3 this method has been mark as deprecated. So not sure weather this method will work as per its behaviour or not.
Also, in one of your reply you have mention,
"if you can suggest any API which will allow user to login in offline mode and synch the data which were created offline mode, that will be great help."
for this statement I can only say that user can only login to the application in offline mode and do the operation on local database but he cannot do the sync in offline mode sync only happen when user is in network.
Hope this help.
Kind Regards,
-Amey
Brenton,
Sorry, was stuck in some other issues.
So again coming back to offline mode:
It will be grate if you provide your communication details so that i can mail you code snippet.
Thanks
Saket
Thanks Amey,
Actually the app is logged in successfully first time, and next time when i trying to login to app without internet connectivity, it tries to reach SUP server for doing all the same stuff which it was trying to do at first time, and gives error, i have confusion which API will allow user to login the already sync app in offline mode.
Help will really appreciated.
Regards
Saket
Dear Saket,
Basically there are different ways to achieve this task.
1. before SUP server release 2.1.3, the MBO Object api contains some method like LoginToSync(), offlineLogin(), onLineLogin()
LoginToSync() method itself calls offlineLogin() method (internally) when there is not network connectivity when user still tries to access the application i.e. tries to login.
2 But from SUP 2.1.3 and later release the approach has been changed and now you need to register you the application with respect to device. by using registerApplication api. Now in this scenario if you want that your application should work in offline mode then follow below approach [I am using the same with my sup application]
1. Register the application with sup server
User is by default authenticated when application register successfully
2. On successful registration store the username and password in to the device store
3. Now suppose you are in network mode and tries to access the application then
simply get the application instance and call the startConnection() method
4. But now suppose you are not in network mode [you can check that by using network api supported by device platform] and you want to access the application, then what ever credentials user has entered in the Login screen just verify those credentials with the one which you have stored in device store when application was successfully registered. If the credentials match then allow user to navigate in to the application.
below is the sample code snippet:
Note: this is only sample code. You can refer this to get the idea about offlineLogin scenario
**********************************************************************************
static boolean offlineLoginFlag = false;
public void TestOfflineLogin(){
Initialize application();
}
public viod Initialize application{
// Initialize Application settings
Application app = Application.GetInstance();
// The identifier has to match the application ID deployed to the SUP server
app.ApplicationIdentifier = "SUP101";
IApplicationCallback appCallback = new MyApplicationCallback();
app.ApplicationCallback = appCallback;
// set connection properties, login credentials, etc
ConnectionProperties connProps = app.ConnectionProperties;
LoginCredentials loginCred = new LoginCredentials("supAdmin", "supPwd");
connProps.LoginCredentials = loginCred;
SUP101DB.SetApplication(app);
if (app.RegistrationStatus != RegistrationStatus.REGISTERED)
{
// If the application has not been registered to the server, register now
app.RegisterApplication(<timeout_value>);
offlineLoginFlag =true
}
else
{
if(network availabe){
// start the connection to server
app.StartConnection(<timeout_value>);
}
else{
// retirve the last successful stored credential from the store and compare with the one entered by user
if(match){
//Navigate the user to login screen
}
else{
//display a invalid credentials pop up message to the user
}
}
}
if(offlineLoginFlag){
//set the offlineLoginFlag to false
offlineLoginFlag = false;
//store the application credentials to the device store.
}
}
**********************************************************************************
Hope this will help you to understand the offlineLogin concept.
This is the approach what I have following to achieve the offlineLogin scenario, If there any other alternate available then I request all the sup expert to comment your thoughts!!!
Kind Regards,
-Amey Baisane
User | Count |
---|---|
84 | |
10 | |
10 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.