Skip to Content
author's profile photo Former Member
Former Member

sybase 2.2 and ios


Hi,

Please could any one give me tutorial or exemple how to connect ios application with SAP system using sybase 2.2.

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

2 Answers

  • author's profile photo Former Member
    Former Member
    Posted on Dec 26, 2013 at 11:17 AM

    Hi,

    Check the below document and refer page 16 for importing libraries, define header section.

    Then do the following

    1. create a CallbackHandler class

    Add the following in CalbackHandler.h

    #import "SUPDefaultCallbackHandler.h"

    #import "SUPApplicationCallback.h"

    // These strings will be used to send out NSNotifications.

    #define ON_IMPORT_SUCCESS @"SUPImportSuccess"

    #define ON_LOGIN_SUCCESS @"SUPLoginSuccess"

    #define ON_LOGIN_FAILURE @"SUPLoginFailure"

    #define ON_CONNECT_SUCCESS @"SUPConnectSuccess"

    #define ON_CONNECT_FAILURE @"SUPConnectFailure"

    #define ON_REPLAY_SUCCESS @"SUPReplaySuccess"

    #define ON_REPLAY_FAILURE @"SUPReplayFailure"

    // For this example we are only handling a small subset of the notifications

    // defined in SUPCallbackHandler. Refer to the iOS Developer's Guide for SUP for more

    // information on when the other callbacks are used.

    @interface CallbackHandler : SUPDefaultCallbackHandler <SUPApplicationCallback,UIApplicationDelegate>

    {

    }

    + (CallbackHandler*)getInstance;

    @end

    2. Add the following in CallbackHandler.m file

    #import "CallbackHandler.h"

    #import "SUPSynchronizationStatus.h"

    #import "SUPConnectionUtil.h"

    #import "AppDelegate.h"

    #import "SUPPushNotification.h"

    @implementation CallbackHandler

    + (CallbackHandler*)getInstance

    {

    CallbackHandler* _me_1 = [[CallbackHandler alloc] init];

    [_me_1 autorelease];

    return _me_1;

    }

    - (void)sendNotification:(NSNotification *)notification

    {

    [[NSNotificationCenter defaultCenter] postNotification:notification];

    [notification release];

    }

    - (void)postNotification:(NSString *)notification withObject:(id)obj;

    {

    // All callback notifications other than onSubscribe: will happen on a thread other than the main UI thread. So, if you

    // want to update the UI in response to a callback you need to post the notification from the main thread.

    NSNotification *n = [NSNotification notificationWithName:notification object:obj];

    [n retain];

    [self performSelectorOnMainThread:@selector(sendNotification:) withObject:n waitUntilDone:NO];

    }

    - (void)onConnectionStatusChanged:(SUPConnectionStatusType)connectionStatus :(int32_t)errorCode :(NSString*)errorMessage

    {

    NSLog(@"=================================================");

    NSLog(@"onConnectionStatusChanged: status = %d, code = %d, message = %@",connectionStatus,errorCode,errorMessage);

    NSLog(@"=================================================");

    NSString *notification = nil;

    switch(connectionStatus)

    {

    case SUPConnectionStatus_CONNECTED:

    notification = ON_CONNECT_SUCCESS;

    break;

    case SUPConnectionStatus_DISCONNECTED:

    notification = ON_CONNECT_FAILURE;

    break;

    default:

    // Ignore all other status changes for this example.

    break;

    }

    if (notification != nil) [self postNotification:notification withObject:nil];

    }

    - (void)onApplicationSettingsChanged:(SUPStringList*)names

    {

    NSLog(@"================================================");

    NSLog(@"onApplicationSettingsChanged: names = %@",[names toString]);

    NSLog(@"================================================");

    }

    - (void)onRegistrationStatusChanged:(SUPRegistrationStatusType)registrationStatus :(int32_t)errorCode :(NSString*)errorMessage;

    {

    NSLog(@"=================================================");

    NSLog(@"onRegistrationStatusChanged: status = %d, code = %d, message = %@",registrationStatus,errorCode,errorMessage);

    NSLog(@"=================================================");

    }

    - (void)onDeviceConditionChanged :(SUPDeviceConditionType)condition;

    {

    NSLog(@"=================================================");

    NSLog(@"onDeviceConditionChanged: condition = %d",condition);

    NSLog(@"=================================================");

    }

    - (void)onHttpCommunicationError :(int32_t)errorCode :(NSString*)errorMessage :(SUPStringProperties*)responseHeaders

    {

    NSLog(@"=================================================");

    NSLog(@"onHttpCommunicationError: errorCode = %i error message =%@",errorCode,errorMessage);

    NSLog(@"=================================================");

    }

    - (void)onConnectionStatusChange:(SUPDeviceConnectionStatus)connStatus :(SUPDeviceConnectionType)connType :(int32_t)errorCode :(NSString *)errorString

    {

    NSString *notification = nil;

    switch(connStatus)

    {

    case CONNECTED_NUM:

    notification = ON_CONNECT_SUCCESS;

    break;

    case DISCONNECTED_NUM:

    notification = ON_CONNECT_FAILURE;

    break;

    default:

    // Ignore all other status changes for this example.

    break;

    }

    if (notification != nil) [self postNotification:notification withObject:nil];

    }

    - (void)onReplaySuccess:(id)theObject

    {

    MBOLogInfo(@"================================================");

    MBOLogInfo(@"Replay Successful");

    MBOLogInfo(@"=================================================");

    [self postNotification:ON_REPLAY_SUCCESS withObject:theObject];

    }

    - (void)onReplayFailure:(id)theObject

    {

    MBOLogInfo(@"================================================");

    MBOLogInfo(@"Replay Failure");

    MBOLogInfo(@"=================================================");

    [self postNotification:ON_REPLAY_FAILURE withObject:theObject];

    }

    - (void)onLoginSuccess

    {

    MBOLogInfo(@"================================================");

    MBOLogInfo(@"Login Successful");

    MBOLogInfo(@"=================================================");

    [self postNotification:ON_LOGIN_SUCCESS withObject:nil];

    }

    - (void)onLoginFailure

    {

    MBOLog(@"=============================");

    MBOLogError(@"Login Failed");

    MBOLog(@"=============================");

    [self postNotification:ON_LOGIN_FAILURE withObject:nil];

    }

    - (void)onSubscribeSuccess

    {

    MBOLogInfo(@"================================================");

    MBOLogInfo(@"Subscribe Successful");

    MBOLogInfo(@"=================================================");

    }

    - (void)onImportSuccess

    {

    MBOLogInfo(@"================================================");

    MBOLogInfo(@"import ends Successful");

    MBOLogInfo(@"=================================================");

    [self postNotification:ON_IMPORT_SUCCESS withObject:nil];

    }

    //The onSynchronize method overrides

    -(SUPSynchronizationActionType)onSynchronize:(SUPObjectList *)syncGroupList withContext:(SUPSynchronizationContext *)context{

    switch ([context status]) {

    case SUPSynchronizationStatus_STARTING:

    NSLog(@"SYNC STARTING >>>>>>>>");

    break;

    case SUPSynchronizationStatus_ERROR:

    NSLog(@"SYNC STATUS ERROR>>>>>>>>");

    break;

    case SUPSynchronizationStatus_FINISHING:

    NSLog(@"SYNC STATUS FINISHING>>>>>>>");

    break;

    case SUPSynchronizationStatus_ASYNC_REPLAY_UPLOADED:

    NSLog(@"ASYNC REPLAY FINISHED>>>>>>");

    break;

    case SUPSynchronizationStatus_ASYNC_REPLAY_COMPLETED:

    NSLog(@"ASYNC REPLAY COMPLETED>>>>>>>>>");

    break;

    case SUPSynchronizationStatus_DOWNLOADING:

    NSLog(@"SYNC DOWNLOADING>>>>>>>>>>>>>");

    break;

    case SUPSynchronizationStatus_STARTING_ON_NOTIFICATION:

    NSLog(@"SYNC STARTING ON NOTIFICATION>>>>>>>>>>>");

    break;

    case SUPSynchronizationStatus_UPLOADING:

    NSLog(@"SYNC STATUS UPLOADING");

    break;

    default:

    break;

    }

    return SUPSynchronizationAction_CONTINUE;

    }

    @end

    3. Create a ConnectionController class and add the following in .h file

    #import <Foundation/Foundation.h>

    #import "CallbackHandler.h"

    @interface ConnectionController : NSObject

    @property(nonatomic,retain)CallbackHandler *callbackHandler;

    +(void)beginApplicationSettings;

    -(BOOL)setupApplicationConnection;

    @end

    4. Add the following in ConnectionController .m file

    SUPApplication *app=[SUPApplication getInstance];

    [app setApplicationIdentifier:APPLICATION_IDENTIER];

    [app setApplicationCallback:self.callbackHandler];

    [APP_NAME_AppDB registerCallbackHandler:self.callbackHandler];

    //SYBASE CONTROL CENTER SETTINGS

    SUPConnectionProperties *property=[app connectionProperties];

    [property setServerName:server];

    [property setPortNumber:CONTROL_PORTNUMBER];

    [property setFarmId:farm];

    [property setUrlSuffix:CONTROL_URL_PREFIX];

    [property setNetworkProtocol:CONTROL_PROTOCOL];

    [property setSecurityConfiguration:CONTROL_SECURITY_CONFIG];

    /*

    //MANUAL REGISTRATION//

    SUPLoginCredentials *login=[SUPLoginCredentials getInstance];

    [login setUsername:@"dinesh"];

    [login setPassword:@""];

    [property setLoginCredentials:login];

    [property setActivationCode:CONTROL_ACTIVATION_CODE];

    */

    //AUTOMATIC REGISTRATION

    SUPLoginCredentials *login=[[SUPLoginCredentials alloc]initWithUsername:scc_username andPassword:scc_password];

    [property setLoginCredentials:login];

    [login release];

    if(![APP_NAME_AppDB databaseExists]){

    [APP_NAME_AppDB createDatabase];

    NSLog(@"DB CREATION");

    }

    else{

    NSLog(@"DB ALREADY EXISTS");

    }

    //SYBASE UNWIRED SERVER CONNECTION SETTINGS

    SUPConnectionProfile *connProfile=[APP_NAME_AppDB getSynchronizationProfile];

    [connProfile setNetworkProtocol:UNWIRED_NETWORK_PROTOCOL];

    [connProfile setPortNumber:UNWIRED_PORTNUMBER];

    [connProfile setServerName:server];

    [connProfile.syncProfile setDomainName:UNWIRED_SUP_DOMAIN];

    [connProfile setUser:UNWIRED_SUP_USER];

    [connProfile setPassword:UNWIRED_SUP_PASSWORD];

    [connProfile.syncProfile enableTrace:YES];

    [connProfile setAsyncReplay:NO];

    [APP_NAME_AppDB setApplication:app];

    @try{

    if([SUPApplication registrationStatus]==SUPRegistrationStatus_REGISTERED)

    {

    [app startConnection:0];

    NSLog(@"Start app Connection");

    }

    else

    {

    [app registerApplication:0];

    NSLog(@"Register app Connection");

    [app release];

    return YES;

    }

    }

    @catch(SUPApplicationTimeoutException *pe){

    NSLog(@"%@ : %@",[pe name],[pe message]);

    }

    5.Add the following code in button action of main view controller class

    #import "ConnectionController.h"

    #import "SUPApplication.h"

    -(void)loginAction:(id)sender{

    @try{

    if([MessagingClientLib isMessagingDBExist])

    [MessagingClientLib resetMessagingState];

    [ConnectionController beginApplicationSettings];

    }

    @catch (NSException *exception) {

    NSLog(@"ERROR--ERROR NAME %@ : ERROR REASON %@",[exception name],[exception reason]);

    }

    }

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Dec 26, 2013 at 02:27 PM

    Hi,

    Check the following blog,

    SAP Mobile Platform

    Regards

    Tahir

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.