Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Added resources section.

...

  1. Implement the GreenIDListener interface on your activity, for example:

    Code Block
    languagejava
    themeConfluence
    titleGreenIDActivity.kt
    class GreenIDActivity :  AppCompatActity(), GreenIDListener {
    	
    	override fun onGreenIDSuccess(resultCode: Int, verificatationToken: String?, verificationStatus: String?) {
        	// Your business logic here 
    	}	
    
    	override fun onGreenIDFailed(resultCode: Int, message: String?, description: String?) {
    		// Handle all failures
    		when (result) {
    			ResultCode.NO_NETWORK -> noNetwork()
    			ResultCode.BACK -> userPressedBack()
    			else -> handleGeneralGreenIDError(resultCode,message)
    		}
    	}
    }
    


    Note
    • Override is a required keyword in Kotlin.
    • When overriding a function, you do not have specify the access scope:
      • Public stays public,
      • Protected stays protected!


  2. Write a function to start the GreenID™ SDK:

    Code Block
    languagejava
    titleGreenActivity.kt
    // In GreenActivity.kt
    
    private fun startGreenID() {
    
    	val configBundle = Bundle().apply {
    		putString("accountId", "account-id-as-provided")
    		putString("baseUrl", "https://simpleui-uat1.vixverify.com/") // Change this
    		putString("apiCode", "api-code-as-provided")          
    		putString("countryCode", "XX")
    		putString("mode", "onboarding")         
    	}
    
        GreenID.getInstance(applicationContext).start(configBundle, this)	
    }


  3. Start the GreenID™, for example on a button/view click:

    Code Block
    // onCreate: 
    
    startGreenIdBtn.setOnClickListener { startGreenID() }


Kotlin Resource for Java/Android Developers

ResourceURL
Web console to try out Kotlin within your browser.https://play.kotlinlang.org
Official Kotlin Referencehttps://kotlinlang.org/docs/reference/
Official Android Kotlin Documentation https://developer.android.com/kotlin/
Cheat Sheethttps://blog.kotlin-academy.com/kotlin-cheat-sheet-1137588c75a