Initialization and Authorization of the EngageSDK
Once you have integrated the EngageSDK into your app, you will need to initialize it (both iOS and Android) and additionally, explicitly enter your app’s username and password (Android only) so that it may login to the Locally platform.
SDK Initialization
Android Applications
The following initialization must be included in your app in order to use Locally’s EngageSDK features:
class Activity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_layout)
EngageSDK.init(this)
...
}
}
iOS Applications
In order to initialize Locally’s SDKEngage framework, you’ll need to add your credentials to the initialization call on the didFinishLaunchingWithOptions of your App:
import LocallyEngageSDK
import UIKit
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
Engage.initialize(username: "YOUR USERNAME", password: "YOUR PASSWORD")
return true
}
}
Log Your Android App into the Locally Platform
After initialization, your app will need to log in to the Locally Platform using your app’s username and password.
private fun performLogin(){
EngageSDK.login("YOUR APP USERNAME", "YOUR APP PASSWORD") { status, message ->
when(status) {
AuthStatus.SUCCESS -> { /* login success */ }
AuthStatus.UNAUTHORIZED -> { /* wrong username/password */ }
AuthStatus.CONNECTION_ERROR -> { /* failed trying to connect */ }
AuthStatus.UNKNOWN_ERROR -> { /* unknown error */ System.out.println(message) }
}
}
}
Depending on the response from the server, this method will return the following AuthStatus
:
- SUCCESS
- UNAUTHORIZED
- CONNECTION_ERROR
- UNKNOWN_ERROR