Registering a User

Register a user using a predefined authentication mechanism asynchronously.

Initialize the ClientConnection class using SMPClientConnection* clientConn = [SMPClientConnection initializeWithAppID:@"application ID" domain:@"domain" secConfiguration:@"secconfig"];
SMPClientConnection  *clientConn=[ SMPClientConnection   initializeWithAppID : @”com.sap.NewFlight”   domain : @”default”   secConfiguration : @”HttpAuth” ]; 
Provide server details such as host and port, and set enableHTTP to Yes for HTTP Request. By default, the connections are HTTPS, using [clientConn setConnectionProfileWithHost:host port:port farm:farm relayServerUrlTemplate:relayserverurltemplate enableHTTP:isHttpRequest];
[clientConn setConnectionProfileWithHost:@”10.66.187.60”
        port:@”8000” farm:nil  relayServerUrlTemplate:nil enableHTTP:YES];   

Set the delegate in case of asynchronous registration. This class has to implement SMPUserManagerDelegate to get the callback

[SMPUserManager setDelegate:self];

Initialize the UserManager with clientConnection as one of the parameter and using SMPUserManager* userManager = [SMPUserManager initializeWithConnection:clientConn];

SMPUserManager *userManager = [SMPUserManager initializeWithConnection:clientConn];   
Asynchronously register the user using [userManager registerUser:@"username" password:@"password" error:&error isSyncFlag:NO];
Note: The isSyncFlag can be set to YES (for synchronous onboarding) or NO (for asynchronous onboarding).
[userManager registerUser:@”supuser” password:@”s3puser” error :nil  isSyncFlag:NO ]; 

Implement these two callbacks for successful registration or registration failure.

-(void)userRegistrationSuccessful:(SMPUserManager *)userManager 
                  {                                                                             
                   //Registration Successful 
            /* Get the Application connection ID send by server after successful registration using 
         [userManager applicationConnectionID] which can be set using       
        [clientConn setApplicationConnectionID:ApplicationConnectionId]; whenever application
        restarts. */
   
               NSString *appConnID=[userManager applicationConnectionID];
                 
                } 
                  -(void)userRegistrationFailed:( SMPUserManager *)userManager 
                {                                
                  NSError  *error=[userManager registrationError];  
                  NSLog(@"User Registration Failed with error:   %@",[error description]);
                }