Hoppa till huvudinnehåll
Integrate Parakey in your app

Use deep linking to integrate your own app with the Parakey app

Emil Janitzek avatar
Skrivet av Emil Janitzek
Uppdaterad för mer än 8 månader sedan

Unlocking requires the user to download the Parakey app in order to securely connect to the lock's hardware. Parakey's API and app integration make the experience as simple as possible for your users by either implementing URL app linking or Native app linking.

Parakey assets

We are happy to assist you with assets for your app, such as buttons or the Parakey logo. Please contact us and explain your needs and we will do our best to help you.

URL Query Parameters

There are three valid query parameters for both iOS and Android. All parameters are optional and can be used with both URL app linking and native app linking.

username

Used to populate the user's email address field of the login screen.

code

Used for automatically signing in together with the username parameter.

urlscheme

The user will be automatically redirected back to your app after successfully performing an unlock in the Parakey app.

URL app linking

The simplest way to integrate Parakey in your app is through app linking, you can create a link both from your website or within your app. Just add a link to https://app.parakey.co/start and if the user does not have the app installed they will be forwarded to either App Store for iOS or Google Play for Android. If they have the app installed the app will start instead.

Native app linking

We also support native app linking with URL schemes, this will guarantee the best experience if you have your own app. But it is up to your app to handle cases when the Parakey app isn't installed and guide the user to the correct app store.

iOS

Step 1

The deeplink is registered at: parakeyapp://parakey

Step 2
Create a url with params:

let url = URL(string: "parakeyapp://parakey?username=[YOUR USER NAME]&code=[YOUR PASSWORD]&urlscheme=[YOUR APP’s URL SCHEME]")

Step 3 (Optional)

Redirecting back to your app after a successful unlock requires a custom URL scheme.

Create a custom URL scheme in your info.plist by adding a URL types > URL identifier > URL Schemes. This is the value send in your URL string urlscheme=exampleSchem

Example:

parakeyapp://parakey?urlscheme=exampleScheme

Step 4
Open the deep link:

UIApplication.shared.open(url)

Android

Step 1
Create URI from: parakeyapp://parakey
Example:

parakeyapp://[email protected]

Step 2
Create Intent with URI:

new Intent(Intent.ACTION_VIEW, unlockURI)

Step 3
Start activity for result

startActivityForResult(parakeyIntent, PARAKEY_REQUEST_CODE)

Step 4
If onActivityResult(...) is called with:

  1. RESULT_OK, then everything went ok
    - In case there are any Parakey-related problems, the application remains in the foreground to allow the user to try again. As soon as we reach a successful operation the user is sent back.

  2. RESULT_CANCEL, then that means the user canceled to process along the way.

Complete code example

public class ParakeyDemoActivity extends Activity {
...
private void onOpenWithParakeyClick() {
Intent intent = new Intent(
Intent.ACTION_VIEW,
Uri.parse("parakeyapp://parakey?username=[username]")
);
if (intent.resolveActivity(getPackageManager()) == null) {
// Parakey not installed
// Show appropriate message
return;
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == PARAKEY_REQUEST_CODE) {
if (resultCode == Activity.RESULT_OK) {
//On successful open
} else if (resultCode == Activity.RESULT_CANCEL) {
//If user cancelled along the way
}
}
}
...
}

Fick du svar på din fråga?