Making Changes to Application Registration

This task is not required if your application is built with SDK version 2.1 ESD #2. For applications built with SDKs prior to 2.1 ESD #2, make changes to the application to allow it to register.

  1. The Application APIs (SUPApplication class) are required for managing application registrations, connections, and context. Rewrite the initialization code in your application to use the Application APIs. For information on the Application interface, search for Application APIs in the Developer Guide for your platform.

    For iOS applications, the Messaging Client API has been removed. Replace references in your application to the Messaging Client API (SUPMessage class) with the appropriate use of the Application APIs (SUPApplication).

  2. Callbacks related to application events are now contained in a separate ApplicationCallback interface. Rewrite your application code to use this interface. For information on the ApplicationCallback interface, search for Callback and Listener APIs in the Developer Guide for your platform.
  3. Complete application registration through an automatic or manual process. See the Application and User Management Overview topic group in SAP Control Center for SAP Mobile Platform.

    Use the SUPApplicationCallback APIs to check that the application successfully registered and the messaging client connection is established.

The following is sample code from the SUP101 project for ApplicationCallbackHandler.

#import "SUPApplicationDefaultCallback.h"

// These strings will be used to send out NSNotifications.
#define ON_CONNECTING  @"SUPConnecting"
#define ON_CONNECT_FAILURE @"SUPConnectFailure"
#define ON_CONNECT_DISCONNECT @"SUPConnectDisconnect"
#define ON_CONNECT_SUCCESS @"SUPConnectSuccess"
#define ON_REGISTER_SUCCESS @"SUPRegisterSuccess"
#define ON_REGISTER_FAILURE @"SUPRegisterFailure"

@interface ApplicationCallbackHandler : SUPApplicationDefaultCallback
{
    
}

+ (ApplicationCallbackHandler*)getInstance;
@end
#import "ApplicationCallbackHandler.h"



@implementation ApplicationCallbackHandler

+ (ApplicationCallbackHandler*)getInstance
{
    ApplicationCallbackHandler* _me_1 = [[ApplicationCallbackHandler alloc] init];
    [_me_1 autorelease];
    return _me_1;
}


- (void)notify:(NSNotification *)notification
{
     [[NSNotificationCenter defaultCenter] postNotification:notification];
}

- (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_CONNECTING:
            notification = ON_CONNECTING;
            break;
        case SUPConnectionStatus_CONNECTION_ERROR:
            notification = ON_CONNECT_FAILURE;
            break;
        case SUPConnectionStatus_CONNECTED:
            notification = ON_CONNECT_SUCCESS;
            break;
        default:
            // Ignore all other status changes for this example.
            break;
    }
    
    if (notification != nil)
    {
         NSNotification *n = [NSNotification notificationWithName:notification object:nil];
         [self performSelectorOnMainThread:@selector(notify:) withObject:n waitUntilDone:NO];
    }
    
}


- (void)onRegistrationStatusChanged:(SUPRegistrationStatusType)registrationStatus :(int32_t)errorCode :(NSString*)errorMessage;
{
    NSLog(@"=================================================");
    NSLog(@"onRegistrationStatusChanged: status = %d, code = %d, message = %@",registrationStatus,errorCode,errorMessage);
    NSLog(@"=================================================");
    
    if (registrationStatus == SUPRegistrationStatus_REGISTRATION_ERROR)
    {
        
        NSNotification *n = [NSNotification notificationWithName:ON_REGISTER_FAILURE object:nil];
        [self performSelectorOnMainThread:@selector(notify:) withObject:n waitUntilDone:NO];
    }
    
    if (registrationStatus == SUPRegistrationStatus_REGISTERED)
    {
        
        NSNotification *n = [NSNotification notificationWithName:ON_REGISTER_SUCCESS object:nil];
        [self performSelectorOnMainThread:@selector(notify:) withObject:n waitUntilDone:NO];
    }

}

@end