Synaps integrates its workflow easily on Android devices without extra packages or SDK. Thanks to Intent and Deep Links. Here is a guided tour of how integrating Synaps on native Android.
1. Create a Synaps app
To start, you need to create an app. After logged in to your Synaps Manager interface, just click on New app. Go to integration tab and copy your Synaps API Key
2. Integrate Synaps Sessions with your Private API
As you are dealing with a mobile app, no sensitive information should appear on it. You should store no credentials, passwords, API Keys directly in your mobile codebase as it can easily be accessed by anyone.
The most common way to deal with sensitive information is to call your Private API and set a authorization mechanism using access token for instance. This mechanism will lets you call the API with a time-based token and will keep every sensitive data in your backend.
Synaps API Key is a sensitive information. This key will lets you generate new verification sessions and access sessions information.
Synaps Session ID is not a sensitive information. This Session ID has been built for front-end. It can be exposed publicly without any problem because it exposes no user information. It has been designed to only upload information.
As you are designing an Android app and as it is considered as a front-end (publicly accessible), your goal is to call your private API that will generates a Synaps Session ID for you.
3. Create a simple android app
Open Android Studio and click "Start a new Android Studio Project"
2. Select "Empty Activity"
3. Name your app and click "Finish"
4. App Created!
The following screen is the basic app directory with base code.
5. Add verify button
Go to your activity_main.xml located at app/src/main/res/layout/activity_main.xml, add a button and set the ID as verify_btn
deepLink is the scheme that you previously added in your AndroidManifest.xml to authorized web browser to be redirected to your app using this scheme. In other words, you authorized anyone to go to your app simply by typing in safari com.synaps.verify://back. Once the user will click "back to app", Synaps will trigger this deepLink and you will be able to handle the callback.
Add custom scheme to your AndroidManifest.xml
Open your AndroidManifest.xml and add the following code
Change com.synaps.sample with your own android:scheme and back with your own android:host
The above chunk of the code is triggered when the user come back to your app. At this moment, you have to handle your business logic. The most common way is to call your Private API to pull data from Synaps about the current authenticated user.
// Handle Callback
val action:String?= intent?.action
val data:Uri?= intent?.data
// Call to Private API
Toast.makeText(getApplicationContext(),"Pull data from Private API",Toast.LENGTH_SHORT).show();
Synaps Session Link
The Synaps Session Link will remains approximately always the same only session_id and service parameters will change for Android integration.