Initializing the BitplacesSDK instance

The BitplacesSDK class is your main point of contact with the Bitplaces SDK. It will let you control the location monitoring, manage bitplaces and channels, and access the user's message inbox.

Before you use BitplacesSDK in a given session of your app it is necessary to initialize it. You can perform the initialization by invoking its static start(Context, String, String, String, boolean, BitplacesOperationCompletionHandler) method.

For best monitoring results, we strongly recommend that you perform the SDK initialization in your application's [onCreate()|https://developer.android.com/reference/android/app/Application.html#onCreate()] method.

Here is an example:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
BitplacesSDK.start(context, customerID, customerSecret, uaReleaseID, useFCM,
    new BitplacesOperationCompletionHandler<Void>() {
                    @Override
                    public void onOperationComplete(int resultCode, Void resultData) {
                        if (ResultCode.fromCode(resultCode).isSuccessful()) {
                            // From this point on you know that the SDK initialization was successful.
                        } else {
                            // The SDK initialization failed. If you know the customer credentials were correct,
                            // try again later. Don't call any other SDK methods until the initialization is
                            // successfully completed.
                        }
                    }
                });

This method expects the following parameters:

  • An android.content.Context instance belonging to your app.
  • Your customer ID and customer secret for the Bitplaces platform.
  • The UA release ID created for your application through our Cloud Management Interface (e.g. "1.0.0").
  • A boolean flag indicating whether your app is using FCM or GCM as its push notification provider.
  • A BitplacesOperationCompletionHandler that will be notified of the result of the initialization attempt. This is to ensure that the SDK has initialized itself correctly and has established a first connection with the Bitplaces backend.

Alternatively, you can use for initialization the start(Context, String, String, String, String, boolean, BitplacesOperationCompletionHandler) method instead, which accepts an additional parameter: an arbitrary string identifier (called foreignUAInstanceId) that you can use to link your application instance with this SDK instance.

The start() methods return an instance of the BitplacesSDK class. Because this class is implemented as a singleton, there will be only one BitplacesSDK instance in your app, and you can get a reference to it by invoking

1
BitplacesSDK.getInstance();

Please note that getInstance() will throw an IllegalStateException if you have not started the SDK previously with the start method.