Migrating iOS Applications

Migrate iOS Online Data Proxy applications from 2.1 ESD #3 (or earlier) to 2.2.

These steps use an example scenario that includes before and after code snippets, removed code snippets, and additional information.

  1. Modify user registration code, and all APIs related to registration.
    In the following before and after code examples, which show an automatic registration scenario:
    • The user manager class is renamed to comply with Sybase Unwired Platform naming standards.
    • Error handling has been changed from exceptions in 2.1 ESD #3 or earlier to standard error objects in 2.2.
    • With 2.2, asynchronous user registration follows the delegation design pattern of iOS, that is, the application developer implements an ODPUserManagerDelegate to receive failure or success notifications, compared to the behavior in earlier versions, where application-defined selectors were assigned for success and failure callbacks.
    • The asynchronous registration call has been merged with the normal registration call, and a simple Boolean determines whether the call is synchronous.
    Before:
    @try 
    {
        if ([LiteSUPAppSettings isSUPKeyProvisioned]) {
            [LiteSUPUserManager clearServerVerificationKey];
        }
        LiteSUPUserManager* userManager = [LiteSUPUserManager getInstance:@"NewFlight"];
    		
        [ODPClientListeners setCertificateChallengeListenerDelegate:self];
        [ODPClientListeners setHTTPAuthChallengeListenerDelegate:self];
        [ODPClientListeners setHTTPErrorListenerDelegate:self];
    
        [userManager setDelegate:self];
        [userManager setDidFailToRegisterUser:@selector(registrationSuccessful:)];
        [userManager setDidSuccessfulUserRegistration:@selector(registrationFailed:)];
    
        [userManager setConnectionProfile:@"10.53.138.119" withSupPort:5001 withServerFarmID:@"0"];
        [userManager registerUser:@"supuser" withSecurityConfig:@"HttpAuth" withPassword:@"s3puser"];
    }
    @catch (NSException *exception)
    {
        NSLog(@"%@", [exception reason]);
    }
    
    After:
        if ([ODPAppSettings isServerKeyProvisioned]) {
            [ODPClientConnection clearServerVerificationKey];
        }
    ODPUserManager* userManager = [ODPUserManager getInstance:@"com.sap.NewFlight"];
    [ODPClientListeners setCertificateChallengeListenerDelegate:self];
    [ODPClientListeners setHTTPAuthChallengeListenerDelegate:self];
    [ODPClientListeners setHTTPErrorListenerDelegate:self];    
    
    [userManager setDelegate:self];
    
    [userManager setConnectionProfileWithHost:@"10.53.138.119" port:5001 farm:@"0" error:nil];
    NSError* regError = nil;
    [userManager registerUser:@"supuser" securityConfig:@"SSO" password:@"s3puser" error:&regError isSyncFlag:NO];
    
    if (regError) {
        NSLog(@"%@", regError);
    }
    Removed:
    [userManager registerUser:@"user" withSecurityConfig:@"sec" withPassword:@"pwd" withVaultPassword:@"vaultpwd"];
    [userManager registerUserAsynchronousWithUserName:@"user" activationCode:@"code"];
    [userManager registerUserAsynchronousWithUserName:@"user" securityConfig:@"sec" password:@"pwd"];
    [userManager registerUserAsynchronousWithUserName:@"user" securityConfig:@"sec" password:@"pwd" vaultPassword:@"vaultpwd"];
    [userManager setConnectionProfileFromAfaria:url appUrlScheme:urlScheme];
    NSMutableDictionary* settings = [userManager getSettingsFromAfariaWithUrl:url UrlScheme:urlScheme];
  2. Modify data fetch-related code.
    There are no major differences in using the SDMRequesting interface with Sybase Unwired Platform 2.2. All basic API code remains the same. The renaming of the ODP request call is abstracted by the SDMRequestBuilder and does not affect the application. In the following before and after example for data fetch code:
    • One major difference is XCSRF handling for the client. With 2.2, clients are responsible for token persistence during the session. Enable XCSRF handling by calls to a simple method in the SDMRequesting interface. In 2.1 ESD #3 and earlier, fetching the token and passing it in subsequent update calls was handled by the application itself.
    • The new get Endpoint call method returns an error in case of failure when fetching the endpoint. You can write your application to receive the error or not. This holds true for the push Endpoint method as well.
    Before:
    id<SDMRequesting> request = [SDMRequestBuilder requestWithURL:[NSURL URLWithString: [LiteSUPAppSettings getApplicationEndPoint]];
    [request setUsername:@"user"];
    [request setPassword:@"pwd"];
    [request setDelegate:self];
    [request setRequestMethod:@"GET"];
    [request addRequestHeader:@"X-CSRF-Token" value:@"Fetch"];
    [request setDidFailSelector:@selector(requestFailed:)];
    [request setDidFinishSelector:@selector(requestFinished:)];
    [request startAsynchronous];
    
    NSString* xCsrfToken = [[request responseHeaders] objectForKey:@"X-CSRF-TOKEN"];
    After:
    [SDMRequestBuilder enableXCSRF:YES];
    id<SDMRequesting> request = [SDMRequestBuilder requestWithURL:[NSURL URLWithString: [ODPAppSettings getApplicationEndpointWithError:nil]]];
    [request setUsername:@"user"];
    [request setPassword:@"pwd"];
    [request setDelegate:self];
    [request setRequestMethod:@"GET"];
    [request setDidFailSelector:@selector(requestFailed:)];
    [request setDidFinishSelector:@selector(requestFinished:)];
    [request startAsynchronous];

    Removed: nothing has been removed from the SDMRequesting interface.

  3. Modify user deletion code, and related API code.

    The difference here is the restructuring of classes. The message to stop the client has been renamed and grouped under a different class, and exception handling has been replaced with error handling using the standard error object.

    Before:
    @try {
        LiteSUPUserManager* userManager = [LiteSUPUserManager getInstance:@"NewFlight"];
        [userManager shutDown];
        [userManager deleteUser];
    }
    @catch (NSException *exception) {
        NSLog(@"%@", [exception reason]);
    }
    After:
    ODPUserManager* userManager = [ODPUserManager getInstance:@"com.sap.NewFlight"];
    ODPClientConnection* clientConnection = [ODPClientConnection getInstance:@"com.sap.NewFlight"];
    [clientConnection stopClient];
    NSError* error = nil;
    [userManager deleteUserWithError:&error];

    Removed: nothing has been removed from the interface.

  4. Modify APNS code, and related API code.

    This section discusses the client-side API, which gets the device token and passes it to Unwired Server. The only major change is renaming the class that holds these methods.

    Before:
    [LiteSUPMessagingClient setupForPush:app];
    [LiteSUPMessagingClient deviceTokenForPush:app deviceToken:token];
    [LiteSUPMessagingClient pushNotification:app notifyData:dataDict];
    [LiteSUPMessagingClient pushRegistrationFailed:app errorInfo:error];
    
    In version 2.1 ESD #3, online push with payload was achieved with setDelegate calls. Also, a new delegate SDMSUPPushDelegate has been adapted, and its method pushNotificationReceived: implemented.
     [SUPUtilities setDelegate:self];
    The delegates for these methods have remained the same; the information has not been repeated here.
    After:
    [ODPClientConnection setupForPush:app];
    [ODPClientConnection deviceTokenForPush:app deviceToken:token];
    [ODPClientConnection pushNotification:app notifyData:dataDict];
    [ODPClientConnection pushRegistrationFailed:app errorInfo:error];
    In version 2.2, the online push with payload calls were adapted to the delegate ODPPushDelegate, and its method pushNotificationReceived: implemented.
    [ODPClientConnection registerForPayloadPush:self];

    Removed: nothing has been removed from the interface.

  5. Modify certificate management API code sections.
    Before:
    LiteSUPCertificateStore* store = [LiteSUPCertificateStore getInstance];
    NSString* base64string = [store getSignedCertificateFromFile:filePath withCertificatePassword:password];
    After:
    NSString* base64string = [ODPCertificateManager getSignedCertificateFromFile:filePath withCertificatePassword:password];
    Removed:
    LiteSUPCertificateStore* store = [LiteSUPCertificateStore getInstance];
    [store getSignedCertificate:cert withCertificatePassword:password];
    [store getSignedCertificateFromAfariaForURL:url withUsername:username withPassword:password];
    [store getSignedCertificateFromAfariaForURLScheme:urlScheme withUsername:username withPassword:password];
    [store getSignedCertificateFromServer:server withPassword:password withCertificatePassword:passCert];
    Note: These methods were deprecated in 2.1 ESD #3, and have been removed in 2.2.
  6. Make modifications needed to implement additional changes and new features, then recompile your code if required.

    Since Afaria is a standalone, separately consumable library in version 2.2, no methods related to Afaria are exposed as a part of the Online Data Proxy interface. Application developers must consume the Afaria library directly.