How to call vanillaNAV from other apps (vanillaNAV app is installed)


You can use the vanillaNAV navigation functionality from inside your app. VanillaNAV offers an interface that allows you to access the navigation screen from your app. The communication is based on standard mechanisms like Intents (Android) and URL calls (iOS). 

 

 

Through the interface, we offer access to the navigation screen of vanillaNAV. This is the screen where the camera image is displayed and the user is asked to scan a navigation marker. When scanning such a marker, he will see the AR indication pointing the direction to the selected POI. By clicking “back” (back key on Android devices and the back arrow on iOS smartphones) the user leaves the navigation are gets back to the screen from where he started the navigation.

 

An example use case could be the following:

  1. A specific exhibition app is available, let’s call it exhibition app. Different exhibitors have a booth at this fair and these booths are the POIs the users of the app can navigate to.
  2. In this exhibition app, there is a list of all exhibitors with some detailed information about them. For each exhibitor, there is also a “navigate to” button.
  3. When clicking this button, the exhibition app calls the vanillaNAV app specifying as a parameter the POI to navigate to, in this case the booth of this specific exhibitor.
  4. The vanillaNAV app is opening in the navigation screen and the user can navigate to that booth.
  5. If the user presses back on his smartphone, the vanillaNAV navigation screen is closed and the user gets back to the exhibition app on the page of the exhibitor where he pressed “navigate to”.
  6. Thus, the integration is seamless on the smartphone. For the user of the app it looks like he is using just one app (the exhibition app in this example).

 When clicking the “navigate to” button and the vanillaNAV app is not installed yet, the user is directed automatically to the vanillaNAV page in the app store so that he can download the app.

 

Here you can find a sample application for Android showing how to use the vanillaNAV interface. 

Here you can find a sample for iOS showing how to use the vanillaNAV interface. 

 

Below you can find code samples for Android showing the implementation of the navigation interface and for iOS showing how to access vanillaNAV from your app:

 

Android Java:

import android.content.ActivityNotFoundException;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;

public class VanillaNav {
    /**
     * Show the navigation screen for a location
     *
     * @param context       used to call [email protected] Context#startActivity(Intent)}
     * @param venueId       from the <a href="http://www.vanillanav.com/admin">admin panel</a>
     * @param destinationId used to reference a location, this field is editable in the <a href="http://www.vanillanav.com/admin">admin panel</a>
     */
    public static boolean navigate(Context context, long venueId, long destinationId) {
        try {
            Intent intent = new Intent();
            intent.setClassName("net.rosoftlab.nav", "net.rosoftlab.nav.ui.navigation.NavigationActivity");
            intent.putExtra("venueId", venueId);
            intent.putExtra("destinationId", destinationId);
            context.startActivity(intent);
            return true;
        } catch (ActivityNotFoundException | IllegalArgumentException e) {
            Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=net.rosoftlab.nav"));
            context.startActivity(intent);
        } catch (SecurityException e) {
            //invalid VN Version
        }
        return false;
    }
}

iOS Swift:

//example URL: vanillanav:navigateTo?venueId=8037&referenceId=19144
public func navigate(venueId: Int, destinationId: Int) -> Bool {
    let navigateUrl = NSURL(string: "vanillanav:navigateTo?venueId=\(venueId)&referenceId=\(destinationId)")!
    let sharedApp = UIApplication.sharedApplication()
    if sharedApp.canOpenURL(navigateUrl) {
        sharedApp.openURL(navigateUrl)
        return true
    } else {
        let storeUrl = NSURL(string: "itms-apps://itunes.apple.com/ro/app/vanillanav/id1007116984")!
        sharedApp.openURL(storeUrl)
        return false
    }
}

 

Tags: mobile app
Last update:
2017-03-07 16:59
Author:
Marlene Lange
Revision:
1.13
Average rating:0 (0 Votes)

You cannot comment on this entry

Chuck Norris has counted to infinity. Twice.