Installation

Installation

On GitHub, you will find the SDKs for Android and iOS. A sample app is included in each repository inside a folder titled Example.

Android

In your existing Android application, open your build.gradle file and add the following dependencies:

// SDK dependency
compile 'com.digital2go:sdk:1.0.0'
    
// External dependencies
compile 'com.google.android.gms:play-services-gcm:9.0.2'
compile 'com.google.android.gms:play-services-auth:9.0.2'
compile 'com.google.android.gms:play-services:9.0.2'
compile 'com.google.maps.android:android-maps-utils:0.4.+'
compile 'com.android.support:multidex:1.0.1'
compile 'com.google.android.gms:play-services-ads:9.0.2'
compile 'com.kontaktio:sdk:3.0.0'
compile 'com.squareup.okhttp3:okhttp:3.4.1'
compile 'com.squareup.retrofit:retrofit:1.9.0'
    
// Push Notifications
compile 'com.google.firebase:firebase-messaging:9.0.2'
compile 'com.amazonaws:aws-android-sdk-sns:2.2.11'

Also in your build.gradle file, enable the multidex in your defaultConfig{} as shown below:

defaultConfig {
	....
	multiDexEnabled true
	...
}

Now, go into your strings.xml file located at app -> src -> main -> res -> values -> strings.xml and add the following:

<string name="kontakt_io_api_key">YOUR KONTAKTIO API KEY</string>
<string name="aws_key">YOUR AWS KEY</string>
<string name="aws_secret">YOUR AWS SECRET</string>
<string name="app_name">YOUR APP NAME WITHOUT SPACES</string>
<string name="d2go_app_name">YOUR D2GO APP USERNAME</string>
<string name="d2go_app_pass">YOUR D2GO APP PASSWORD</string>

To make use of the SDK, you need to start with the initContext represents application context and the token attribute stands for value provided by the Firebase Cloud Messaging.

public class Activity extends AppCompatActivity {
  private String firebaseToken;
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity);
          firebaseToken = FirebaseInstanceId.getInstance().getToken();
          ... 
      }
      @Override
      protected void onResume() {
          super.onResume();
          D2GOSDK.init(getApplicationContext(), firebaseToken);
          ...
      }
  }

iOS

To create a new project in Xcode, click File -> New -> Project, then select your template, indicate your product name, organization name, organization identifier, and select the Swift programming language.

Our example iOS app uses Amazon Web Services (specifically, Cognito) to handle the creation, confirmation, and authentication of user accounts. If you wish to add this functionality to your project, add the Amazon static libraries. This can be accomplished by right-clicking under your app folder, creating a new group, renaming it to “AmazonServices”, and copying the Amazon iOS SDK folder into this group.

We use Kubernetes to deploy, scale, and manage our application. To use it, you must prepare your AWS account for use with the Kubernetes CLI tool, which requires setting up an IAM user. More information is available here.

Run ruby pod init inside your project folder to create a podfile. Add the D2GOClient pod and its dependencies to your podfile as shown below:

source 'https://github.com/CocoaPods/Specs.git'

platform :ios, '10.0'
    use_frameworks!
    target :'YourAppName' do
        ...
        pod 'AWSCore', '~> 2.4.12'
        pod 'AWSMobileAnalytics', '~> 2.4.12'
        pod 'AWSCognitoIdentityProvider', '~> 2.4.12'
        pod 'AWSSNS', '~> 2.4.12'
        pod 'AWSS3', '~> 2.4.12'
        pod 'KontaktSDK'
        pod 'KeyChainSwift'

        pod 'D2GOClient'
        ...
end

Next, you need to insert some keys into your Info.plist file as demonstrated below:

<key>D2GOApiLoginPassword</key>
<string>XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX</string>
<key>D2GOApiLoginUsername</key>
<string>XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX</string>

<!-- Contact Digital2Go SDK support -->
<key>CognitoUserPoolAppClientID</key>
<string>XXxxXxxxxXXXxxxXXxxxXxxxx</string>
<key>CognitoUserPoolAppClientSecret</key>
<string>xxxxxxxxXxxXXXxxxxXXXXxxXXXxxxxxxxxXXXXXxxxXXxxxxxxx</string>
<key>CognitoUserPoolID</key>
<string>us-east-1_xxxxxxxxx</string>
<key>SNSAccessKey</key>
<string>XXXXXXXXXXXXXXXXXXXX</string>
<key>SNSSecretKey</key>
<string>xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx</string>

<key>AWS</key>
<key>IdentityManager</key>
<key>Default</key>
<key>CredentialsProvider</key>
<key>CognitoIdentity</key>
<key>Default</key>
<key>PoolId</key>
<string>us-east-x:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx</string>
<key>Region</key>
<string>USEastx</string>

In reference to the code snippet shown above, the D2GOApiLoginPasswordD2GOApiLoginUsernameD2GOBeaconUUIDForD2Go, and D2GOKonkaktAPIKey keys can be obtained via the D2GO platform.

The CognitoUserPoolAppCleintIDCognitoUserPoolAppClientSecret, and CognitoUserPoolID keys can be obtained upon creating an Amazon Web Services account and creating a Cognito User Pool.

The SNSAccessKey and SNSSecretKey keys can be acquired via our login API (see the authorization section for more details).

You should also copy and paste the following authorizations for location services into your Info.plist file:

<key>NSLocationAlwaysAndWhenInUseUsageDescription</key>
<string>App explanation for always: "Need permission to spot iBeacons" If your only allow access to your location while your are using the app, some features may not work while this app is in the background.</string>
<key>NSLocationWhenInUseUsageDescription</key>
<string>Do you allow this app to know your current location?</string>