IBM Cloud Docs
Initializing BMSClient

Initializing BMSClient

BMSCore provides the HTTP infrastructure that the other IBM Cloud® Web and Mobile services client SDKs use to communicate with their corresponding IBM Cloud services.

Initializing your Android app

You can either download and import the BMSCore package to your Android Studio project, or use Gradle.

  1. Import the Client SDK by adding the following import statement at the beginning of your project file:

    import com.ibm.mobilefirstplatform.clientsdk.android.core.api.*;
    
  2. Initialize the BMSClient SDK in your Android application by adding the initialization code in the onCreate method of the main activity in your Android app, or in a location that works best for your project.

    BMSClient.getInstance().initialize(getApplicationContext(), BMSClient.REGION_US_SOUTH); // Make sure that you point to your region
    

    Initialize the BMSClient with the bluemixRegion parameter. In the initializer, the bluemixRegion value specifies which IBM Cloud deployment you are using, for example, BMSClient.REGION_US_SOUTH, BMSClient.REGION_UK, or BMSClient.REGION_SYDNEY.

Initializing your iOS app

You can use CocoaPods or Carthage to get the BMSCore package.

  1. To install BMSCore by using CocoaPods, add the following lines to your Podfile. If your project doesn't have a Podfile yet, use the pod init command.

    use_frameworks!
    
    target 'MyApp' do
      pod 'BMSCore'
    end
    

    Then run the pod install command, and open the generated .xcworkspace file. To update to a newer release of BMSCore, use pod update BMSCore.

    For more information about using CocoaPods, see the CocoaPods Guides.

  2. To install BMSCore by using Carthage, follow these instructions.

    1. Add the following line to your Cartfile:

      github "ibm-bluemix-mobile-services/bms-clientsdk-swift-core"
      
    2. Run the carthage update command.

    3. After the build is finished, add BMSCore.framework to your project by following Step 3 in the Carthage instructions.

      For apps that are built with Swift 2.3, use the carthage update --toolchain com.apple.dt.toolchain.Swift_2_3 command. Otherwise, use the carthage update command.

  3. Import the BMSCore module.

    import BMSCore
    
  4. Initialize the BMSClient class by using the following code.

    Place the initialization code in the application(_:didFinishLaunchingWithOptions:) method of your app delegate, or in a location that works best for your project.

    BMSClient.sharedInstance.initialize(bluemixRegion: BMSClient.Region.usSouth) // Make sure that you point to your region
    

    Initialize the BMSClient with the bluemixRegion parameter. In the initializer, the bluemixRegion value specifies which IBM Cloud deployment you're using, for example, BMSClient.Region.usSouth, BMSClient.Region.unitedKingdom, or BMSClient.Region.sydney.

Initializing your Cordova app

  1. Add the Cordova plug-in by running the following command from your Cordova app root directory:

    cordova plugin add bms-core
    
  2. Initialize the BMSClient class in your Cordova app by adding the initialization code in the main JavaScript file, or in a location that works best for your project.

    BMSClient.initialize(BMSClient.REGION_US_SOUTH);
    

    Initialize the BMSClient with the bluemixRegion parameter. In the initializer, the bluemixRegion value specifies which IBM Cloud deployment you're using, for example, BMSClient.REGION_US_SOUTH, BMSClient.REGION_UK, or BMSClient.REGION_SYDNEY.