Skip to content

NativeScript support

Contextual has developed a plugin for NativeScript. It is still in Beta testing, but here are the instructions for how to get the Beta plugin working with Android

From the sample app created with "tns create" these are the instructions to integrate the plugin.

Requirements

1 Set minSDKVersion

Go to /app/App_Resources/Android/app.gradle and change the minSdkVersion to at least 21

2 Add Contextual initialisation

Go to /app/App_Resources/Android/src/main/AndroidManifest.xml and under the application opening tag add the following snippet, replacing <YOUR_APP_KEY> with the App Key you are using in the Contextual dashboard.

1
2
3
<meta-data
            android:name="com.pointzi.APP_KEY"
            android:value="<YOUR_APP_KEY>" />

3 Set the MaterialComponents theme

Go to /app/App_Resources/Android/src/main/res/values/styles.xml and change

1
<style name="LaunchScreenThemeBase" parent="Theme.AppCompat.Light.NoActionBar"> 

to

1
2
<style name="LaunchScreenThemeBase" 
parent="Theme.MaterialComponents.Light.NoActionBar">

and

1
<style name="AppThemeBase" parent="Theme.AppCompat.Light.NoActionBar">
to

1
<style name="AppThemeBase" parent="Theme.MaterialComponents.Light.NoActionBar">

4. Add the Contextual plugin

Run on the root of your project

1
tns plugin add nativescript-pointzi

Contextual should be properly installed by then.

5 Identify pages

To identify pages so that you are able to run guides on them, you will need to follow the following instructions

On the ""loaded"" event of each page, add the import:

1
import { Contextual } from "nativescript-pointzi";

Then add this code inside the method changing <PAGE_NAME> to the name you want to refer to that page as:

1
new Pointzi().setViewName("<PAGE_NAME>");

6 Identify users

To identify a user, at any point after the app has started up or on your root page loaded event, run this line changing <USER_ID> to the identifier for this user:

1
new Pointzi().setUserId("<USER_ID>");
If you have any issues or need any help setting it up, don't hesitate to contact us at support@contextu.al.


Last update: 2022-02-14