Connecting Through a Relay Server

An iOS RBS client that connects through a Relay Server needs two different farm IDs: one for a messaging client connection to register the application, and the RBS connection for database synchronization.

In your iOS application, set up the messaging client and database connection through Relay Server. Note that, in most cases, the application template already contains settings for the RBS connection so you do not need to set any properties. The settings from the template are downloaded to the client after registration is completed. However, it may be necessary in a development environment to directly manipulate the settings.

  1. To set up a messaging client connection, use:
    SUPApplication * app = [SUPApplication getInstance];
    
    // should be same as application id from SCC
    [app setApplicationIdentifier:@”appId”]; 
    SUPConnectionProperties* props = app.connectionProperties;
    [props setServerName:serverName];
    [props setPortNumber:80]; // or 443 for HTTPS
    [props setNetworkprotocol:@"http"]; // or https for secure connection
    [props setUrlSuffix:@""];
    [props setFarmId:@"farmIDMBS"];
    SUPLoginCredentials* login = [SUPLoginCredentials getInstance];
    login.username = @"userName"; // same as in Application Connection
    login.password = nil;
    props.loginCredentials = login;
    props.activationCode = @"123"; // same as in Application Connection
    props.securityConfiguration = @"admin";
  2. To set up a database connection:
    • If the application connection template on SCC is configured with all the required Relay Server information, application code only needs to do:
      SUPConnectionProfile *sp = [SUP101SUP101DB getSynchronizationProfile];
      [sp setUser:@"supAdmin"];
      [sp setPassword:@"password"];
      [sp setAsyncReplay:NO];
    • Otherwise, application code needs to fill all the Relay Server information before doing data synchronization:
      SUPConnectionProfile *sp = [SUP101SUP101DB getSynchronizationProfile];
      [sp setUser:@"supAdmin"];
      [sp setPassword:@"password"];
      [sp setAsyncReplay:NO];
      
      [sp setServerName:@"relayServerHostName"];
      [sp setPortNumber:443]; // or 80 for http
      [sp setNetworkProtocol:@"https"];
      // certificateName: this should come from the relay server and should be 
      // included in the Resource folder of the XCode project
      [sp setNetworkStreamParams:@"trusted_certificates=certificateName;compression=zlib;url_suffix=urlSuffixRBS"];
      
      Note: urlSuffixRBS needs to match the exact string of Relay Server RBS url_suffix configuration.

The above code should be done before doing any data synchronization (including subscribe/onlineLogin).